summaryrefslogtreecommitdiff
path: root/listener.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2010-11-04 15:40:44 -0500
committerNick Mathewson <nickm@torproject.org>2010-11-05 10:12:06 -0400
commit52aa419bf69bc2f46f203800919abcfc25ea98fe (patch)
treefee671835fec3efa01fde1618ed13c41dda9460b /listener.c
parent229714d123824d686bece18e6d2d157ed401abd4 (diff)
downloadlibevent-52aa419bf69bc2f46f203800919abcfc25ea98fe.tar.gz
Set SO_UPDATE_ACCEPT_CONTEXT on sockets from AcceptEx so that shutdown() can work
Based on patch (and lots of debugging work) by Kelly Brock.
Diffstat (limited to 'listener.c')
-rw-r--r--listener.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/listener.c b/listener.c
index 5a521985..32d5b768 100644
--- a/listener.c
+++ b/listener.c
@@ -526,6 +526,8 @@ start_accepting(struct accepting_socket *as)
goto report_err;
}
+ /* XXXX It turns out we need to do this again later. Does this call
+ * have any effect? */
setsockopt(s, SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT,
(char *)&as->lev->fd, sizeof(&as->lev->fd));
@@ -609,6 +611,12 @@ accepted_socket_invoke_user_cb(struct deferred_cb *dcb, void *arg)
sock = as->s;
cb = lev->cb;
as->s = INVALID_SOCKET;
+
+ /* We need to call this so getsockname, getpeername, and
+ * shutdown work correctly on the accepted socket. */
+ /* XXXX handle error? */
+ setsockopt(as->s, SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT,
+ (char *)&as->lev->fd, sizeof(&as->lev->fd));
}
data = lev->user_data;