mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
listener: Preserve last error in evconnlistener_new_bind() before close
In function evconnlistener_new_bind() after go to "err:", The evutil_closesocket() would clear the error code( I found this under Windows ). User can not use EVUTIL_SOCKET_ERROR() to get the evconnlistener_new_bind()'s failing error. I add a err_code variable to store and restore the last error code. v2: rebased by azat to make the patch simpler
This commit is contained in:
parent
7aeecb60c4
commit
d96457e132
@ -275,9 +275,14 @@ evconnlistener_new_bind(struct event_base *base, evconnlistener_cb cb,
|
||||
|
||||
return listener;
|
||||
err:
|
||||
{
|
||||
int saved_errno = EVUTIL_SOCKET_ERROR();
|
||||
evutil_closesocket(fd);
|
||||
if (saved_errno)
|
||||
EVUTIL_SET_SOCKET_ERROR(saved_errno);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
evconnlistener_free(struct evconnlistener *lev)
|
||||
|
Loading…
x
Reference in New Issue
Block a user