| 381 } |
381 } |
| 382 |
382 |
| 383 if(ret) { |
383 if(ret) { |
| 384 return client->error == 0; |
384 return client->error == 0; |
| 385 } |
385 } |
| |
386 log_ereport(LOG_INFORM, "client_process end: %p", event->finish); |
| |
387 |
| |
388 if(event != &client->event) { |
| |
389 // An extern event has called client_process, therefore the |
| |
390 // client_finished event callback is not automatically called. |
| |
391 // Manually shutdown the client: |
| |
392 log_ereport(LOG_INFORM, "client_process: manual shutdown"); |
| |
393 ev_remove_poll(client->ev, client->socketfd); |
| |
394 client_finished(client->ev, &client->event); |
| |
395 client->event.fn = NULL; |
| |
396 client->event.finish = NULL; |
| |
397 } |
| 386 |
398 |
| 387 return 0; |
399 return 0; |
| 388 } |
400 } |
| 389 |
401 |
| 390 static int client_ws_write(HttpClient *client) { |
402 static int client_ws_write(HttpClient *client) { |
| 473 return r == 0 || client->error ? 0 : 1; |
485 return r == 0 || client->error ? 0 : 1; |
| 474 } |
486 } |
| 475 |
487 |
| 476 static int client_finished(EventHandler *ev, Event *event) { |
488 static int client_finished(EventHandler *ev, Event *event) { |
| 477 HttpClient *client = event->cookie; |
489 HttpClient *client = event->cookie; |
| |
490 log_ereport(LOG_INFORM, "client_finished: %p", client->response_finished); |
| 478 |
491 |
| 479 close(client->socketfd); |
492 close(client->socketfd); |
| 480 client->socketfd = -1; |
493 client->socketfd = -1; |
| 481 client->stage = -1; |
494 client->stage = -1; |
| 482 |
495 |
| 834 return 1; |
847 return 1; |
| 835 } |
848 } |
| 836 } |
849 } |
| 837 } |
850 } |
| 838 |
851 |
| |
852 if(r == 0) { |
| |
853 log_ereport(LOG_INFORM, "client_read_response_body eof"); |
| |
854 } |
| |
855 |
| 839 if(r < 0) { |
856 if(r < 0) { |
| |
857 if(client->stream->st.io_errno == EWOULDBLOCK) { |
| |
858 log_ereport(LOG_INFORM, "client_read_response_body would block"); |
| |
859 } |
| |
860 |
| 840 if(client->stream->st.io_errno != EWOULDBLOCK) { |
861 if(client->stream->st.io_errno != EWOULDBLOCK) { |
| 841 client->error = 1; |
862 client->error = 1; |
| 842 } |
863 } |
| 843 return 1; |
864 return 1; |
| 844 } |
865 } |
| 845 |
866 log_ereport(LOG_INFORM, "client_read_response_body finished"); |
| 846 return 0; |
867 return 0; |
| 847 } |
868 } |
| 848 |
869 |
| 849 /* --------------------------------- Tests --------------------------------- */ |
870 /* --------------------------------- Tests --------------------------------- */ |
| 850 |
871 |