diff options
Diffstat (limited to 'ot_http.c')
| -rw-r--r-- | ot_http.c | 25 |
1 files changed, 19 insertions, 6 deletions
| @@ -158,6 +158,13 @@ ssize_t http_sendiovecdata(const int64 sock, struct ot_workstruct *ws, size_t io | |||
| 158 | HTTPERROR_500; | 158 | HTTPERROR_500; |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | /* Descriptor numbers get recycled, so a result can only belong to this | ||
| 162 | connection if this connection is in fact waiting for one. */ | ||
| 163 | if (!(cookie->flag & (STRUCT_HTTP_FLAG_WAITINGFORTASK | STRUCT_HTTP_FLAG_CHUNKED_IN_TRANSFER))) { | ||
| 164 | iovec_free(&iovec_entries, &iovector); | ||
| 165 | return 0; | ||
| 166 | } | ||
| 167 | |||
| 161 | /* If this socket collected request in a buffer, free it now */ | 168 | /* If this socket collected request in a buffer, free it now */ |
| 162 | buf_reset(&cookie->request); | 169 | buf_reset(&cookie->request); |
| 163 | 170 | ||
| @@ -267,12 +274,16 @@ static ssize_t http_handle_stats(const int64 sock, struct ot_workstruct *ws, cha | |||
| 267 | {"url", TASK_FULLSCRAPE_TPB_URLENCODED}, {"txt", TASK_FULLSCRAPE_TPB_ASCII}, | 274 | {"url", TASK_FULLSCRAPE_TPB_URLENCODED}, {"txt", TASK_FULLSCRAPE_TPB_ASCII}, |
| 268 | {"txtp", TASK_FULLSCRAPE_TPB_ASCII_PLUS}, {NULL, -3}}; | 275 | {"txtp", TASK_FULLSCRAPE_TPB_ASCII_PLUS}, {NULL, -3}}; |
| 269 | 276 | ||
| 270 | int mode = TASK_STATS_PEERS, scanon = 1, format = 0; | ||
| 271 | |||
| 272 | #ifdef WANT_RESTRICT_STATS | ||
| 273 | struct http_data *cookie = io_getcookie(sock); | 277 | struct http_data *cookie = io_getcookie(sock); |
| 278 | int mode = TASK_STATS_PEERS, scanon = 1, format = 0; | ||
| 274 | 279 | ||
| 275 | if (!cookie || !accesslist_is_blessed(cookie->ip, OT_PERMISSION_MAY_STAT)) | 280 | /* A socket without one is a dead socket, which is what http_sendiovecdata |
| 281 | already answers 500 to. */ | ||
| 282 | if (!cookie) | ||
| 283 | HTTPERROR_500; | ||
| 284 | |||
| 285 | #ifdef WANT_RESTRICT_STATS | ||
| 286 | if (!accesslist_is_blessed(cookie->ip, OT_PERMISSION_MAY_STAT)) | ||
| 276 | HTTPERROR_403_IP; | 287 | HTTPERROR_403_IP; |
| 277 | #endif | 288 | #endif |
| 278 | 289 | ||
| @@ -306,8 +317,7 @@ static ssize_t http_handle_stats(const int64 sock, struct ot_workstruct *ws, cha | |||
| 306 | } | 317 | } |
| 307 | 318 | ||
| 308 | if (mode == TASK_STATS_TPB) { | 319 | if (mode == TASK_STATS_TPB) { |
| 309 | struct http_data *cookie = io_getcookie(sock); | 320 | tai6464 t; |
| 310 | tai6464 t; | ||
| 311 | #ifdef WANT_COMPRESSION_GZIP | 321 | #ifdef WANT_COMPRESSION_GZIP |
| 312 | ws->request[ws->request_size - 1] = 0; | 322 | ws->request[ws->request_size - 1] = 0; |
| 313 | #ifndef WANT_COMPRESSION_GZIP_ALWAYS | 323 | #ifndef WANT_COMPRESSION_GZIP_ALWAYS |
| @@ -334,6 +344,9 @@ static ssize_t http_handle_stats(const int64 sock, struct ot_workstruct *ws, cha | |||
| 334 | /* default format for now */ | 344 | /* default format for now */ |
| 335 | if ((mode & TASK_CLASS_MASK) == TASK_STATS) { | 345 | if ((mode & TASK_CLASS_MASK) == TASK_STATS) { |
| 336 | tai6464 t; | 346 | tai6464 t; |
| 347 | |||
| 348 | cookie->flag |= STRUCT_HTTP_FLAG_WAITINGFORTASK; | ||
| 349 | |||
| 337 | /* Complex stats also include expensive memory debugging tools */ | 350 | /* Complex stats also include expensive memory debugging tools */ |
| 338 | taia_uint(&t, 0); | 351 | taia_uint(&t, 0); |
| 339 | io_timeout(sock, t); | 352 | io_timeout(sock, t); |
