Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Better timeout support while handling POSTs.

git-svn-id: svn://cherokee-project.com/cherokee/trunk@4179 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information...
commit f9f8902bec0fa7ec7121c0b3077d2ddfdf70be8f 1 parent bedf48f
@alobbs alobbs authored
View
12 cherokee/handler_cgi.c
@@ -95,7 +95,9 @@ read_from_cgi (cherokee_handler_cgi_base_t *cgi_base, cherokee_buffer_t *buffer)
switch (ret) {
case ret_eagain:
- cherokee_thread_deactive_to_polling (HANDLER_THREAD(cgi), HANDLER_CONN(cgi), cgi->pipeInput, 0, false);
+ cherokee_thread_deactive_to_polling (HANDLER_THREAD(cgi),
+ HANDLER_CONN(cgi), cgi->pipeInput,
+ FDPOLL_MODE_READ, false);
return ret_eagain;
case ret_ok:
@@ -438,15 +440,17 @@ cherokee_handler_cgi_read_post (cherokee_handler_cgi_t *cgi)
return ret_ok;
}
- ret = cherokee_post_send_to_fd (&conn->post, &conn->socket,
+ ret = cherokee_post_send_to_fd (&conn->post, conn, &conn->socket,
cgi->pipeOutput, NULL, &blocking);
switch (ret) {
case ret_ok:
break;
case ret_eagain:
if (blocking == socket_writing) {
- cherokee_thread_deactive_to_polling (HANDLER_THREAD(cgi), conn,
- cgi->pipeOutput, 1, false);
+ cherokee_thread_deactive_to_polling (HANDLER_THREAD(cgi),
+ conn, cgi->pipeOutput,
+ FDPOLL_MODE_WRITE, false);
+ return ret_deny;
}
return ret_eagain;
default:
View
20 cherokee/handler_fcgi.c
@@ -560,7 +560,8 @@ connect_to_server (cherokee_handler_fcgi_t *hdl)
static ret_t
-do_send (cherokee_handler_fcgi_t *hdl, cherokee_buffer_t *buffer)
+do_send (cherokee_handler_fcgi_t *hdl,
+ cherokee_buffer_t *buffer)
{
ret_t ret;
size_t written = 0;
@@ -582,10 +583,6 @@ do_send (cherokee_handler_fcgi_t *hdl, cherokee_buffer_t *buffer)
cherokee_buffer_move_to_begin (buffer, written);
TRACE (ENTRIES, "sent=%d, remaining=%d\n", written, buffer->len);
- if (! cherokee_buffer_is_empty (buffer)) {
- return ret_eagain;
- }
-
return ret_ok;
}
@@ -662,7 +659,11 @@ send_post (cherokee_handler_fcgi_t *hdl,
/* Next iteration
*/
if (! cherokee_buffer_is_empty (buf)) {
- return ret_eagain;
+ cherokee_thread_deactive_to_polling (HANDLER_THREAD(hdl),
+ HANDLER_CONN(hdl),
+ hdl->socket.socket,
+ FDPOLL_MODE_WRITE, false);
+ return ret_deny;
}
if (! cherokee_post_read_finished (&conn->post)) {
@@ -731,8 +732,13 @@ cherokee_handler_fcgi_init (cherokee_handler_fcgi_t *hdl)
/* Send the header
*/
ret = do_send (hdl, &hdl->write_buffer);
- if (ret != ret_ok)
+ if (ret != ret_ok) {
return ret;
+ }
+
+ if (! cherokee_buffer_is_empty (&hdl->write_buffer)) {
+ return ret_eagain;
+ }
break;
}
View
3  cherokee/handler_proxy.c
@@ -631,7 +631,7 @@ send_post (cherokee_handler_proxy_t *hdl)
cherokee_connection_t *conn = HANDLER_CONN(hdl);
cherokee_socket_status_t blocking = socket_closed;
- ret = cherokee_post_send_to_socket (&conn->post, &conn->socket,
+ ret = cherokee_post_send_to_socket (&conn->post, conn, &conn->socket,
&hdl->pconn->socket, NULL, &blocking);
switch (ret) {
case ret_ok:
@@ -642,6 +642,7 @@ send_post (cherokee_handler_proxy_t *hdl)
cherokee_thread_deactive_to_polling (HANDLER_THREAD(hdl), conn,
hdl->pconn->socket.socket,
FDPOLL_MODE_WRITE, false);
+ return ret_deny;
}
return ret_eagain;
View
9 cherokee/handler_scgi.c
@@ -145,8 +145,10 @@ read_from_scgi (cherokee_handler_cgi_base_t *cgi_base, cherokee_buffer_t *buffer
switch (ret) {
case ret_eagain:
- cherokee_thread_deactive_to_polling (HANDLER_THREAD(cgi_base), HANDLER_CONN(cgi_base),
- scgi->socket.socket, 0, false);
+ cherokee_thread_deactive_to_polling (HANDLER_THREAD(cgi_base),
+ HANDLER_CONN(cgi_base),
+ scgi->socket.socket,
+ FDPOLL_MODE_READ, false);
return ret_eagain;
case ret_ok:
@@ -395,7 +397,7 @@ cherokee_handler_scgi_read_post (cherokee_handler_scgi_t *hdl)
cherokee_connection_t *conn = HANDLER_CONN(hdl);
cherokee_socket_status_t blocking = socket_closed;
- ret = cherokee_post_send_to_socket (&conn->post, &conn->socket,
+ ret = cherokee_post_send_to_socket (&conn->post, conn, &conn->socket,
&hdl->socket, NULL, &blocking);
switch (ret) {
case ret_ok:
@@ -406,6 +408,7 @@ cherokee_handler_scgi_read_post (cherokee_handler_scgi_t *hdl)
cherokee_thread_deactive_to_polling (HANDLER_THREAD(hdl),
conn, hdl->socket.socket,
FDPOLL_MODE_WRITE, false);
+ return ret_deny;
}
return ret_eagain;
View
14 cherokee/handler_uwsgi.c
@@ -165,8 +165,10 @@ read_from_uwsgi (cherokee_handler_cgi_base_t *cgi_base,
switch (ret) {
case ret_eagain:
- cherokee_thread_deactive_to_polling (HANDLER_THREAD(cgi_base), HANDLER_CONN(cgi_base),
- uwsgi->socket.socket, 0, false);
+ cherokee_thread_deactive_to_polling (HANDLER_THREAD(cgi_base),
+ HANDLER_CONN(cgi_base),
+ uwsgi->socket.socket,
+ FDPOLL_MODE_READ, false);
return ret_eagain;
case ret_ok:
@@ -429,7 +431,7 @@ cherokee_handler_uwsgi_read_post (cherokee_handler_uwsgi_t *hdl)
/* Send it
*/
- ret = cherokee_post_send_to_socket (&conn->post, &conn->socket,
+ ret = cherokee_post_send_to_socket (&conn->post, conn, &conn->socket,
&hdl->socket, NULL, &blocking);
switch (ret) {
case ret_ok:
@@ -437,8 +439,10 @@ cherokee_handler_uwsgi_read_post (cherokee_handler_uwsgi_t *hdl)
case ret_eagain:
if (blocking == socket_writing) {
- cherokee_thread_deactive_to_polling (HANDLER_THREAD(hdl), conn,
- hdl->socket.socket, 1, false);
+ cherokee_thread_deactive_to_polling (HANDLER_THREAD(hdl),
+ conn, hdl->socket.socket,
+ FDPOLL_MODE_WRITE, false);
+ return ret_deny;
}
return ret_eagain;
View
28 cherokee/post.c
@@ -532,6 +532,7 @@ do_send_socket (cherokee_socket_t *sock,
ret_t
cherokee_post_send_to_socket (cherokee_post_t *post,
+ cherokee_connection_t *conn,
cherokee_socket_t *sock_in,
cherokee_socket_t *sock_out,
cherokee_buffer_t *tmp,
@@ -544,6 +545,8 @@ cherokee_post_send_to_socket (cherokee_post_t *post,
case cherokee_post_send_phase_read:
TRACE (ENTRIES, "Post send, phase: %s\n", "read");
+ /* Read from the client
+ */
ret = cherokee_post_read (post, sock_in, buffer);
switch (ret) {
case ret_ok:
@@ -555,6 +558,12 @@ cherokee_post_send_to_socket (cherokee_post_t *post,
return ret;
}
+ /* Did something, increase timeout
+ */
+ cherokee_connection_update_timeout (conn);
+
+ /* Write it
+ */
TRACE (ENTRIES, "Post buffer.len %d\n", buffer->len);
post->send.phase = cherokee_post_send_phase_write;
@@ -575,6 +584,10 @@ cherokee_post_send_to_socket (cherokee_post_t *post,
RET_UNKNOWN(ret);
return ret_error;
}
+
+ /* Did something, increase timeout
+ */
+ cherokee_connection_update_timeout (conn);
}
if (! cherokee_buffer_is_empty (buffer)) {
@@ -601,6 +614,7 @@ cherokee_post_send_to_socket (cherokee_post_t *post,
ret_t
cherokee_post_send_to_fd (cherokee_post_t *post,
+ cherokee_connection_t *conn,
cherokee_socket_t *sock_in,
int fd_out,
cherokee_buffer_t *tmp,
@@ -615,6 +629,8 @@ cherokee_post_send_to_fd (cherokee_post_t *post,
case cherokee_post_send_phase_read:
TRACE (ENTRIES, "Post send, phase: %s\n", "read");
+ /* Read from the client
+ */
ret = cherokee_post_read (post, sock_in, buffer);
switch (ret) {
case ret_ok:
@@ -626,6 +642,12 @@ cherokee_post_send_to_fd (cherokee_post_t *post,
return ret;
}
+ /* Did something, increase timeout
+ */
+ cherokee_connection_update_timeout (conn);
+
+ /* Write it
+ */
TRACE (ENTRIES, "Post buffer.len %d\n", buffer->len);
post->send.phase = cherokee_post_send_phase_write;
@@ -648,8 +670,14 @@ cherokee_post_send_to_fd (cherokee_post_t *post,
}
cherokee_buffer_move_to_begin (buffer, r);
+
+ /* Did something, increase timeout
+ */
+ cherokee_connection_update_timeout (conn);
}
+ /* Next iteration
+ */
if (! cherokee_buffer_is_empty (buffer)) {
return ret_eagain;
}
View
2  cherokee/post.h
@@ -92,12 +92,14 @@ ret_t cherokee_post_read (cherokee_post_t *post,
ret_t cherokee_post_send_reset (cherokee_post_t *post);
ret_t cherokee_post_send_to_socket (cherokee_post_t *post,
+ cherokee_connection_t *conn,
cherokee_socket_t *sock_in,
cherokee_socket_t *sock_out,
cherokee_buffer_t *buffer,
cherokee_socket_status_t *blocking);
ret_t cherokee_post_send_to_fd (cherokee_post_t *post,
+ cherokee_connection_t *conn,
cherokee_socket_t *sock_in,
int fd_out,
cherokee_buffer_t *tmp,
View
4 cherokee/thread.c
@@ -1085,8 +1085,12 @@ process_active_connections (cherokee_thread_t *thd)
case ret_ok:
break;
case ret_eagain:
+ /* Blocking on socket read */
conn_set_mode (thd, conn, socket_reading);
continue;
+ case ret_deny:
+ /* Blocking on back-end write */
+ continue;
case ret_eof:
case ret_error:
conn->error_code = http_internal_error;
Please sign in to comment.
Something went wrong with that request. Please try again.