]> granicus.if.org Git - libevent/commitdiff
call setsockopt correctly on connecting() IOCP-bufferevents so shutdown() will work
authorNick Mathewson <nickm@torproject.org>
Fri, 22 Apr 2011 14:54:02 +0000 (10:54 -0400)
committerNick Mathewson <nickm@torproject.org>
Sat, 23 Apr 2011 05:46:39 +0000 (01:46 -0400)
bufferevent_async.c

index b7284fda6cb2dbeab9fcfcdb5b68a14445e3a02b..76a161623bf708850ebca374a43b0d6d061a9c07 100644 (file)
 #include "util-internal.h"
 #include "iocp-internal.h"
 
+#ifndef SO_UPDATE_CONNECT_CONTEXT
+/* Mingw is sometimes missing this */
+#define SO_UPDATE_CONNECT_CONTEXT 0x7010
+#endif
+
 /* prototypes */
 static int be_async_enable(struct bufferevent *, short);
 static int be_async_disable(struct bufferevent *, short);
@@ -403,11 +408,15 @@ connect_complete(struct event_overlapped *eo, ev_uintptr_t key,
 {
        struct bufferevent_async *bev_a = upcast_connect(eo);
        struct bufferevent *bev = &bev_a->bev.bev;
+       evutil_socket_t sock;
 
        BEV_LOCK(bev);
 
        EVUTIL_ASSERT(bev_a->bev.connecting);
        bev_a->bev.connecting = 0;
+       sock = _evbuffer_overlapped_get_fd(bev_a->bev.bev.input);
+       /* XXXX Handle error? */
+       setsockopt(sock, SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, NULL, 0);
 
        if (ok)
                bufferevent_async_set_connected(bev);