summaryrefslogtreecommitdiff
path: root/src/or/directory.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2006-12-23 08:48:16 +0000
committerRoger Dingledine <arma@torproject.org>2006-12-23 08:48:16 +0000
commit488b4726a76c62313518e380576aec530ea44b48 (patch)
tree4cbd5a574e2b260f73f6f4ddc656367bfd99c2af /src/or/directory.c
parent94d7d8d88fce35a4db28c287d258d1890a7c73f8 (diff)
downloadtor-488b4726a76c62313518e380576aec530ea44b48.tar.gz
tor-488b4726a76c62313518e380576aec530ea44b48.zip
reinstate the most important dead chickens for limiting
impact of directory writes now that we're write limiting. a few more dead chickens remain. svn:r9170
Diffstat (limited to 'src/or/directory.c')
-rw-r--r--src/or/directory.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index 34fbf5b7ff..a38aada299 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1510,7 +1510,7 @@ directory_handle_command_get(dir_connection_t *conn, char *headers,
}
dlen = deflated ? d->dir_z_len : d->dir_len;
- if (global_write_bucket_empty()) {
+ if (global_write_bucket_low(dlen, 1)) {
log_info(LD_DIRSERV,
"Client asked for the mirrored directory, but we've been "
"writing too many bytes lately. Sending 503 Dir busy.");
@@ -1544,16 +1544,24 @@ directory_handle_command_get(dir_connection_t *conn, char *headers,
!strcmp(url,"/tor/running-routers.z")) { /* running-routers fetch */
int deflated = !strcmp(url,"/tor/running-routers.z");
dlen = dirserv_get_runningrouters(&cp, deflated);
- note_request(url, dlen);
- tor_free(url);
if (!dlen) { /* we failed to create/cache cp */
write_http_status_line(conn, 503, "Directory unavailable");
/* try to get a new one now */
if (!already_fetching_directory(DIR_PURPOSE_FETCH_RUNNING_LIST))
directory_get_from_dirserver(DIR_PURPOSE_FETCH_RUNNING_LIST, NULL, 1);
+ tor_free(url);
return 0;
}
-
+ if (global_write_bucket_low(dlen, 1)) {
+ log_info(LD_DIRSERV,
+ "Client asked for running-routers, but we've been "
+ "writing too many bytes lately. Sending 503 Dir busy.");
+ write_http_status_line(conn, 503, "Directory busy, try again later");
+ tor_free(url);
+ return 0;
+ }
+ note_request(url, dlen);
+ tor_free(url);
write_http_response_header(conn, dlen,
deflated?"application/octet-stream":"text/plain",
deflated?"deflate":"identity",
@@ -1562,6 +1570,10 @@ directory_handle_command_get(dir_connection_t *conn, char *headers,
return 0;
}
+ /* FFFF for status/ and server/ requests, we don't have a good
+ * guess of the length we're going to be writing out, so it's hard
+ * to call global_write_bucket_low(). How to proceed? */
+
if (!strcmpstart(url,"/tor/status/")) {
/* v2 network status fetch. */
size_t url_len = strlen(url);