mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
be: make the code in bufferevent_socket_connect() more reliable
There is one icky in case for windows: if (sa) { #ifdef _WIN32 if (bufferevent_async_can_connect_(bev)) { bufferevent_setfd(bev, fd); r = bufferevent_async_connect_(bev, fd, sa, socklen); if (r < 0) goto freesock; bufev_p->connecting = 1; result = 0; goto done; - } else + } else { #endif r = evutil_socket_connect_(&fd, sa, socklen); if (r < 0) // Previosly this line was executed // regardless of bufferevent_async_can_connect_(), but the case under // bufferevent_async_can_connect_() always does goto, so it is 100% the // same code, but just to make it more cleaner goto freesock; +#ifdef _WIN32 + } +#endif }
This commit is contained in:
parent
3201009b3f
commit
85a0ec9b2d
@ -411,11 +411,14 @@ bufferevent_socket_connect(struct bufferevent *bev,
|
||||
bufev_p->connecting = 1;
|
||||
result = 0;
|
||||
goto done;
|
||||
} else
|
||||
} else {
|
||||
#endif
|
||||
r = evutil_socket_connect_(&fd, sa, socklen);
|
||||
if (r < 0)
|
||||
goto freesock;
|
||||
#ifdef _WIN32
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef _WIN32
|
||||
/* ConnectEx() isn't always around, even when IOCP is enabled.
|
||||
|
Loading…
x
Reference in New Issue
Block a user