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:
Azat Khuzhin 2024-05-06 08:50:36 +02:00
parent 3201009b3f
commit 85a0ec9b2d

View File

@ -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.