Skip to content
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

proposal: net: UnixListener: provide a way to get the unlink attribute #54161

Open
frankli0324 opened this issue Aug 1, 2022 · 2 comments
Open

Comments

@frankli0324
Copy link

#11826 prevents listeners not created by the process to be unlinked.
#13877 allows devs to explicitly specify whether go should unlink a listener

why does go design a setter SetUnlinkOnClose but not a getter? was there any concerns?
would golang provide a getter?

@frankli0324 frankli0324 changed the title proposal: provide a way to get the unlink attribute of UnixListener. affected/package: net proposal: net/UnixListener provide a way to get the unlink attribute. Aug 1, 2022
@gopherbot gopherbot added this to the Proposal milestone Aug 1, 2022
@ianlancetaylor ianlancetaylor changed the title proposal: net/UnixListener provide a way to get the unlink attribute. proposal: net: UnixListener: provide a way to get the unlink attribute Aug 2, 2022
@ianlancetaylor
Copy link
Contributor

Are there cases where a getter is useful? We didn't provide one because it's hard to see a use case.

@ianlancetaylor ianlancetaylor added this to Incoming in Proposals (old) Aug 2, 2022
@frankli0324
Copy link
Author

frankli0324 commented Aug 2, 2022

it's actually a very specific case, but I felt it could be generalized...
I came along with some lines of code which enumerates all file descriptors, and SetUnlinkOnClose(false) if listener.(UnixListener). it passes these file descriptors to a subprocess created by StartProcess. by doing this, it achieves graceful restart. on startup, the code SetUnlinkOnClose(true) on all the listeners passed to it, removing all the file descriptors the parent passed to the child.
however, the common sense is that a listener should not be unlinked if it's not created by the process. so the parent process have to tell the child which fds are to be preserved by passing a list.
without the getter, the parent process have to maintain a list containing all the fds to be preserved upon creating the listeners, this adds complexity, concurrency locks (listeners are created asynchronously) and of course an extra global variable. but with a getter, the parent process only have to build that list when forking the child process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Incoming
Development

No branches or pull requests

3 participants