[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Handle more errnos from accept() without closing the connec...
- To: or-cvs@freehaven.net
- Subject: [or-cvs] Handle more errnos from accept() without closing the connec...
- From: nickm@seul.org (Nick Mathewson)
- Date: Sat, 23 Oct 2004 20:55:20 -0400 (EDT)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Sat, 23 Oct 2004 20:55:53 -0400
- Reply-to: or-dev@freehaven.net
- Sender: owner-or-cvs@freehaven.net
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv11135/src/or
Modified Files:
connection.c
Log Message:
Handle more errnos from accept() without closing the connection. This may fix a bug that could close OR listeners when (a) TCP connections were hung up before accept() could be called, or (b) during FD exhaustion.
Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.266
retrieving revision 1.267
diff -u -d -r1.266 -r1.267
--- connection.c 16 Oct 2004 22:14:51 -0000 1.266
+++ connection.c 24 Oct 2004 00:55:18 -0000 1.267
@@ -385,11 +385,17 @@
news = accept(conn->s,(struct sockaddr *)&remote,&remotelen);
if (news == -1) { /* accept() error */
- if(ERRNO_IS_EAGAIN(tor_socket_errno(conn->s))) {
+ int e = tor_socket_errno(conn->s);
+ if (ERRNO_IS_ACCEPT_EAGAIN(e)) {
return 0; /* he hung up before we could accept(). that's fine. */
+ } else if (ERRNO_IS_ACCEPT_RESOURCE_LIMIT(e)) {
+ log_fn(LOG_WARN,"accept failed: %s. Dropping incomming connection.",
+ tor_socket_strerror(e));
+ return 0;
}
/* else there was a real error. */
- log_fn(LOG_WARN,"accept() failed. Closing listener.");
+ log_fn(LOG_WARN,"accept() failed: %s. Closing listener.",
+ tor_socket_strerror(e));
connection_mark_for_close(conn);
return -1;
}