[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[or-cvs] enforce maxconn; bugfix to not tear down the parent when we...
- To: or-cvs@freehaven.net
- Subject: [or-cvs] enforce maxconn; bugfix to not tear down the parent when we...
- From: arma@seul.org (Roger Dingledine)
- Date: Tue, 3 Sep 2002 14:36:44 -0400 (EDT)
- Delivered-To: archiver@seul.org
- Delivered-To: or-cvs-outgoing@seul.org
- Delivered-To: or-cvs@seul.org
- Delivery-Date: Tue, 03 Sep 2002 14:36:47 -0400
- Reply-To: or-dev@freehaven.net
- Sender: owner-or-cvs@freehaven.net
Update of /home/or/cvsroot/src/or
In directory moria.seul.org:/home/arma/work/onion/cvs/src/or
Modified Files:
config.c connection.c main.c
Log Message:
enforce maxconn; bugfix to not tear down the parent when we hit maxconn
Index: config.c
===================================================================
RCS file: /home/or/cvsroot/src/or/config.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- config.c 23 Aug 2002 06:49:43 -0000 1.12
+++ config.c 3 Sep 2002 18:36:40 -0000 1.13
@@ -218,6 +218,12 @@
code = -1;
}
+ if ( options->MaxConn >= MAXCONNECTIONS )
+ {
+ log(LOG_ERR,"MaxConn option must be less than %d.", MAXCONNECTIONS);
+ code = -1;
+ }
+
if ( options->TrafficShaping != 0 && options->TrafficShaping != 1 )
{
log(LOG_ERR,"TrafficShaping option must be either 0 or 1.");
Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- connection.c 27 Aug 2002 19:28:35 -0000 1.16
+++ connection.c 3 Sep 2002 18:36:40 -0000 1.17
@@ -122,8 +122,10 @@
crypto_free_cipher_env(conn->b_crypto);
}
- if(conn->s > 0)
+ if(conn->s > 0) {
+ log(LOG_INFO,"connection_free(): closing fd %d.",conn->s);
close(conn->s);
+ }
free(conn);
}
@@ -156,11 +158,14 @@
fcntl(s, F_SETFL, O_NONBLOCK); /* set s to non-blocking */
conn = connection_new(type);
- if(!conn)
+ if(!conn) {
+ log(LOG_DEBUG,"connection_create_listener(): connection_new failed. Giving up.");
return -1;
+ }
conn->s = s;
if(connection_add(conn) < 0) { /* no space, forget it */
+ log(LOG_DEBUG,"connection_create_listener(): connection_add failed. Giving up.");
connection_free(conn);
return -1;
}
@@ -192,7 +197,7 @@
log(LOG_ERR,"connection_handle_listener_read(): accept() failed. Closing.");
return -1;
}
- log(LOG_DEBUG,"Connection accepted on socket %d.",news);
+ log(LOG_INFO,"Connection accepted on socket %d (child of fd %d).",news, conn->s);
fcntl(news, F_SETFL, O_NONBLOCK); /* set news to non-blocking */
@@ -211,7 +216,7 @@
if(connection_add(newconn) < 0) { /* no space, forget it */
connection_free(newconn);
- return -1;
+ return 0; /* no need to tear down the parent */
}
log(LOG_DEBUG,"connection_handle_listener_read(): socket %d entered state %d.",newconn->s, new_state);
Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- main.c 24 Aug 2002 04:59:21 -0000 1.18
+++ main.c 3 Sep 2002 18:36:40 -0000 1.19
@@ -36,8 +36,7 @@
int connection_add(connection_t *conn) {
- if(nfds >= MAXCONNECTIONS-2) { /* 2, for some breathing room. should count the fenceposts. */
- /* FIXME should use the 'max connections' option */
+ if(nfds >= options.MaxConn-1) {
log(LOG_INFO,"connection_add(): failing because nfds is too high.");
return -1;
}
@@ -55,7 +54,6 @@
log(LOG_INFO,"connection_add(): new conn type %d, socket %d, nfds %d.",conn->type, conn->s, nfds);
return 0;
-
}
void connection_set_poll_socket(connection_t *conn) {
@@ -73,7 +71,6 @@
current_index = conn->poll_index;
if(current_index == nfds-1) { /* this is the end */
-// connection_free(conn);
nfds--;
return 0;
}