[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] backport:
Update of /home/or/cvsroot/tor/src/or
In directory moria:/home/arma/work/onion/tor-010x/tor/src/or
Modified Files:
Tag: tor-0_1_0-patches
connection.c directory.c or.h
Log Message:
backport:
- When we're a server, a client asks for an old-style directory,
and our write bucket is empty, don't give it to him. This way
small servers can continue to serve the directory *sometimes*,
without getting overloaded.
Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection.c,v
retrieving revision 1.373.2.2
retrieving revision 1.373.2.3
diff -u -p -d -r1.373.2.2 -r1.373.2.3
--- connection.c 7 Aug 2005 19:40:17 -0000 1.373.2.2
+++ connection.c 18 Feb 2006 00:57:49 -0000 1.373.2.3
@@ -876,6 +876,13 @@ static int connection_bucket_read_limit(
return at_most;
}
+/** Return 1 if the global write bucket has no bytes in it,
+ * or return 0 if it does. */
+int global_write_bucket_empty(void)
+{
+ return global_write_bucket <= 0;
+}
+
/** We just read num_read onto conn. Decrement buckets appropriately. */
static void connection_read_bucket_decrement(connection_t *conn, int num_read) {
global_read_bucket -= num_read; //tor_assert(global_read_bucket >= 0);
Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.230.2.3
retrieving revision 1.230.2.4
diff -u -p -d -r1.230.2.3 -r1.230.2.4
--- directory.c 11 Feb 2006 22:20:21 -0000 1.230.2.3
+++ directory.c 18 Feb 2006 00:57:49 -0000 1.230.2.4
@@ -968,6 +968,14 @@ directory_handle_command_get(connection_
return 0;
}
+ if (global_write_bucket_empty()) {
+ log_fn(LOG_INFO,
+ "Client asked for the mirrored directory, but we've been "
+ "writing too many bytes lately. Sending 503 Dir busy.");
+ write_http_status_line(conn, 503, "Directory busy, try again later");
+ return 0;
+ }
+
log_fn(LOG_DEBUG,"Dumping %sdirectory to client.",
deflated?"deflated ":"");
format_rfc1123_time(date, time(NULL));
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.610.2.6
retrieving revision 1.610.2.7
diff -u -p -d -r1.610.2.6 -r1.610.2.7
--- or.h 2 Jan 2006 13:32:46 -0000 1.610.2.6
+++ or.h 18 Feb 2006 00:57:49 -0000 1.610.2.7
@@ -1289,6 +1289,7 @@ void connection_expire_held_open(void);
int connection_connect(connection_t *conn, char *address, uint32_t addr, uint16_t port);
int retry_all_listeners(int force);
+int global_write_bucket_empty(void);
void connection_bucket_init(void);
void connection_bucket_refill(struct timeval *now);