-
Notifications
You must be signed in to change notification settings - Fork 10.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
call grpc_init for GoogleDefaultCredentials #2879
Conversation
Fixes #2290 |
@@ -61,6 +62,7 @@ std::shared_ptr<Credentials> WrapCredentials(grpc_credentials* creds) { | |||
} // namespace | |||
|
|||
std::shared_ptr<Credentials> GoogleDefaultCredentials() { | |||
GrpcLibrary init; // To call grpc_init(). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we do that in grpc_google_default_credentials_create
instead? What happens if we just use the C API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From https://github.com/grpc/grpc/blob/master/include/grpc/grpc.h#L378, it seems we should do it in the C++ layer. Maybe even add it to all the XXCredentials() functions just to be safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh I see. you're right because C callers have to already call grpc_init
explicitly. Sorry about that.
Now I agree with you that every entry point in the Cpp layer where this is not called should be fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done for all secure credentials.
LGTM. Will merge when jenkins is greenish. |
call grpc_init for GoogleDefaultCredentials
The grpc_google_default_credentials_create call assumes grpc_init has been called, or it will crash if hit the gce detection part. Our C++ wrapper call grpc_init when a Credentials object is created and thus is too late.
I think default credentials is the only one with the problems as all others have trivial create() calls.