summaryrefslogtreecommitdiff
path: root/ot_http.c
diff options
context:
space:
mode:
Diffstat (limited to 'ot_http.c')
-rw-r--r--ot_http.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/ot_http.c b/ot_http.c
index 2216453..927d618 100644
--- a/ot_http.c
+++ b/ot_http.c
@@ -143,7 +143,7 @@ ssize_t http_issue_error(const int64_t sock, struct ot_workstruct *ws, int code)
143#ifdef _DEBUG_HTTPERROR 143#ifdef _DEBUG_HTTPERROR
144 fprintf(stderr, "DEBUG: invalid request was: %s\n", ws->debugbuf); 144 fprintf(stderr, "DEBUG: invalid request was: %s\n", ws->debugbuf);
145#endif 145#endif
146 stats_issue_event(EVENT_FAILED, FLAG_TCP, code); 146 stats_issue_event(ws, EVENT_FAILED, FLAG_TCP, code);
147 http_senddata(sock, ws); 147 http_senddata(sock, ws);
148 return ws->reply_size = -2; 148 return ws->reply_size = -2;
149} 149}
@@ -222,7 +222,7 @@ ssize_t http_sendiovecdata(const int64_t sock, struct ot_workstruct *ws, size_t
222 cookie->flag &= ~STRUCT_HTTP_FLAG_CHUNKED_IN_TRANSFER; 222 cookie->flag &= ~STRUCT_HTTP_FLAG_CHUNKED_IN_TRANSFER;
223 } 223 }
224 224
225 fdstate_set_expiry(sock, g_now_seconds + OT_CLIENT_TIMEOUT_SEND); 225 fdstate_set_expiry(sock, time_future_seconds(OT_CLIENT_TIMEOUT_SEND));
226 http_interest_add(sock, cookie, EVENT_OUT); 226 http_interest_add(sock, cookie, EVENT_OUT);
227 return 0; 227 return 0;
228} 228}
@@ -359,7 +359,7 @@ static ssize_t http_handle_fullscrape(const int64_t sock, struct ot_workstruct *
359 ot_scrape_log this_peer, *new_peer; 359 ot_scrape_log this_peer, *new_peer;
360 int exactmatch; 360 int exactmatch;
361 memcpy(this_peer.ip, cookie->ip, sizeof(ot_ip6)); 361 memcpy(this_peer.ip, cookie->ip, sizeof(ot_ip6));
362 this_peer.last_fullscrape = g_now_seconds; 362 this_peer.last_fullscrape = time_now_seconds();
363 pthread_mutex_lock(&g_modest_fullscrape_mutex); 363 pthread_mutex_lock(&g_modest_fullscrape_mutex);
364 new_peer = vector_find_or_insert(&g_modest_fullscrape_timeouts, &this_peer, sizeof(ot_scrape_log), sizeof(ot_ip6), &exactmatch); 364 new_peer = vector_find_or_insert(&g_modest_fullscrape_timeouts, &this_peer, sizeof(ot_scrape_log), sizeof(ot_ip6), &exactmatch);
365 if (!new_peer) { 365 if (!new_peer) {
@@ -402,7 +402,7 @@ static ssize_t http_handle_fullscrape(const int64_t sock, struct ot_workstruct *
402#endif 402#endif
403#endif 403#endif
404 404
405 stats_issue_event(EVENT_FULLSCRAPE_REQUEST, 0, (uintptr_t)cookie->ip); 405 stats_issue_event(ws, EVENT_FULLSCRAPE_REQUEST, 0, (uintptr_t)cookie->ip);
406 406
407#ifdef _DEBUG_HTTPERROR 407#ifdef _DEBUG_HTTPERROR
408 fprintf(stderr, "%s", ws->debugbuf); 408 fprintf(stderr, "%s", ws->debugbuf);
@@ -474,7 +474,7 @@ static ssize_t http_handle_scrape(const int64_t sock, struct ot_workstruct *ws,
474 /* Enough for http header + whole scrape string */ 474 /* Enough for http header + whole scrape string */
475 return_tcp_scrape_for_torrent((const ot_hash *)multiscrape_buf, numwant, &reply, ws->outbuf + G_OUTBUF_SIZE); 475 return_tcp_scrape_for_torrent((const ot_hash *)multiscrape_buf, numwant, &reply, ws->outbuf + G_OUTBUF_SIZE);
476 ws->reply_size = reply - ws->reply; 476 ws->reply_size = reply - ws->reply;
477 stats_issue_event(EVENT_SCRAPE, FLAG_TCP, ws->reply_size); 477 stats_issue_event(ws, EVENT_SCRAPE, FLAG_TCP, ws->reply_size);
478 return ws->reply_size; 478 return ws->reply_size;
479} 479}
480 480
@@ -682,7 +682,7 @@ static ssize_t http_handle_announce(const int64_t sock, struct ot_workstruct
682#endif 682#endif
683 683
684 /* XXX DEBUG 684 /* XXX DEBUG
685 stats_issue_event( EVENT_ACCEPT, FLAG_TCP, (uintptr_t)ws->reply ); 685 stats_issue_event(ws, EVENT_ACCEPT, FLAG_TCP, (uintptr_t)ws->reply );
686 */ 686 */
687 687
688 /* Scanned whole query string */ 688 /* Scanned whole query string */
@@ -694,7 +694,7 @@ static ssize_t http_handle_announce(const int64_t sock, struct ot_workstruct
694 else 694 else
695 ws->reply_size = add_peer_to_torrent_and_return_peers(FLAG_TCP, ws, numwant); 695 ws->reply_size = add_peer_to_torrent_and_return_peers(FLAG_TCP, ws, numwant);
696 696
697 stats_issue_event(EVENT_ANNOUNCE, FLAG_TCP, ws->reply_size); 697 stats_issue_event(ws, EVENT_ANNOUNCE, FLAG_TCP, ws->reply_size);
698 return ws->reply_size; 698 return ws->reply_size;
699} 699}
700 700
@@ -710,7 +710,7 @@ ssize_t http_handle_request(const int64_t sock, struct ot_workstruct *ws) {
710 log->size = ws->request_size; 710 log->size = ws->request_size;
711 log->data = malloc(ws->request_size); 711 log->data = malloc(ws->request_size);
712 log->next = 0; 712 log->next = 0;
713 log->time = g_now_seconds; 713 log->time = time_now_seconds();
714 memcpy(log->ip, cookie->ip, sizeof(ot_ip6)); 714 memcpy(log->ip, cookie->ip, sizeof(ot_ip6));
715 if (log->data) { 715 if (log->data) {
716 memcpy(log->data, ws->request, ws->request_size); 716 memcpy(log->data, ws->request, ws->request_size);