-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
plugins, runtime: Add visibility for server init #3706
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -438,9 +438,13 @@ func (rt *Runtime) Serve(ctx context.Context) error { | |
signalc := make(chan os.Signal, 1) | ||
signal.Notify(signalc, syscall.SIGINT, syscall.SIGTERM) | ||
|
||
// Note that there is a small chance the socket of the server listener is still | ||
// closed by the time this block is executed, due to the serverLoop above | ||
// executing in a goroutine. | ||
rt.serverInitMtx.Lock() | ||
rt.serverInitialized = true | ||
rt.serverInitMtx.Unlock() | ||
gshively11 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
rt.Manager.ServerInitialized() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there's a race condition here because there's no guarantee that the socket will have been opened. The @gshively11 if you agree w/ the above and are okay with the potential race condition, just include a comment here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, good catch. I think we're probably OK with this race condition, I'll add the comment. If it does end up being an issue, a modification as you described shouldn't be a breaking change, so it should be easy to implement if we need it. |
||
|
||
logrus.Debug("Server initialized.") | ||
|
||
|
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.
Nit: It would be great if you could add a comment as to what you're trying to test in the 2 test cases below. It's not clear to me at least.
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.
Thanks, I somehow missed you weren't calling
ServerInitialized()
in the second case.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 definitely was calling it lol, and it was passing because I was erroneously using
return
above it instead ofbreak
. So good catch 😁