-
Notifications
You must be signed in to change notification settings - Fork 164
Socket leakage on error #6
Comments
Thanks for the heads up, looking now. |
Cleanup open file descriptors when bind_sockaddr fails. Thanks to @hyperblast for reporting this issue #6
Hi again @hyperblast - I just pushed a quick patch here d13b72b Seems to fix it; any suggestions? |
Hi @NathanFrench, thanks for the fix. I think it resolves the first issue, but second one still remains.
Normally Assuming I understood libevent sources right
So to sum up, I think that P.S. Thanks for having this project up and running. Keep it up! |
Hold up the same error checking standards as its owner :)
I'm not too familiar with Libevent's listener backend, but I think you're right. 18f7ec0 has been updated. |
Hi Nathan, I think the fix has possibly unintended side effect of changing It's a public function that could be called by library users directly (e.g. not via New behavior might be a good thing, but it's worth noting that this is a breaking change. |
We already make a determination on the ownership of a /connection/, which must be relinquished if the take_ownership function is called. But we don't do the same for file descriptors. A user can pass their own file descriptor in, and we claim ownership, should we add a flag that specifically designates the owner of the file descriptor? Or maybe a better tree of perms: base [api owned] -> server [api owned] -> connection [user/api owned] -> request -> [user/api owned] |
Ok, so this change technically should not break users if they used the function documentation :D. We weren't conforming to the documentation. d0347dc should address most of these issues including an extra note. |
It seems I've referenced wrong function in my previous comment, but you've already figured out what I've actually meant. Thank you.
Having externally owned socket might have a use-case. For example some kind of sort-restart. User wants to keep the listening socket, but recreate |
I merged the changes with the proper checking and logic. (#8) Not sure how to deal with clashes between libevent and evhtp other than sending in a patch. I think the ownership discussion here should be another ticket. |
Moved the rest to #9 |
evhtp_bind_sockaddr()
does not close created socket ifbind()
fails:https://github.com/criticalstack/libevhtp/blob/develop/evhtp.c#L3668
if
evhtp_accept_socket()
fails for some reason, socked is leaked as well:https://github.com/criticalstack/libevhtp/blob/develop/evhtp.c#L3673
The text was updated successfully, but these errors were encountered: