Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixes a bug in the POST support.

git-svn-id: svn://cherokee-project.com/cherokee/trunk@4436 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information...
commit 616bb65ba2b75d475edc14662452016457213c68 1 parent ddd3fa3
@alobbs alobbs authored
View
8 cherokee/handler_cgi.c
@@ -458,7 +458,15 @@ cherokee_handler_cgi_read_post (cherokee_handler_cgi_t *cgi)
FDPOLL_MODE_WRITE, false);
return ret_deny;
}
+
+ /* ret_eagain - Block on read
+ * ret_deny - Block on back-end write
+ */
+ if (cherokee_post_has_buffered_info (&conn->post, NULL)) {
+ return ret_deny;
+ }
return ret_eagain;
+
default:
return ret;
}
View
18 cherokee/handler_fcgi.c
@@ -592,6 +592,7 @@ send_post (cherokee_handler_fcgi_t *hdl,
cherokee_buffer_t *buf)
{
ret_t ret;
+ int tmp;
cherokee_connection_t *conn = HANDLER_CONN(hdl);
static FCGI_Header empty_header = {0,0,0,0,0,0,0,0};
@@ -637,9 +638,22 @@ send_post (cherokee_handler_fcgi_t *hdl,
TRACE (ENTRIES",post", "Post write, buf.len=%d (header len %d)\n", buf->len, sizeof(FCGI_Header));
if (! cherokee_buffer_is_empty (buf)) {
+ tmp = buf->len;
+
ret = do_send (hdl, buf);
switch (ret) {
case ret_ok:
+ /* Did something, increase timeout
+ */
+ if (buf->len < tmp) {
+ cherokee_connection_update_timeout (conn);
+ }
+
+ /* Block on back-end write
+ */
+ if (buf->len > 0) {
+ return ret_deny;
+ }
break;
case ret_eagain:
return ret_eagain;
@@ -652,10 +666,6 @@ send_post (cherokee_handler_fcgi_t *hdl,
}
}
- /* Did something, increase timeout
- */
- cherokee_connection_update_timeout (conn);
-
/* Next iteration
*/
if (! cherokee_buffer_is_empty (buf)) {
View
8 cherokee/handler_scgi.c
@@ -402,7 +402,6 @@ cherokee_handler_scgi_read_post (cherokee_handler_scgi_t *hdl)
*/
ret = cherokee_post_send_to_socket (&conn->post, &conn->socket,
&hdl->socket, NULL, &blocking, &did_IO);
-
if (did_IO) {
cherokee_connection_update_timeout (conn);
}
@@ -420,6 +419,13 @@ cherokee_handler_scgi_read_post (cherokee_handler_scgi_t *hdl)
FDPOLL_MODE_WRITE, false);
return ret_deny;
}
+
+ /* ret_eagain - Block on read
+ * ret_deny - Block on back-end write
+ */
+ if (cherokee_post_has_buffered_info (&conn->post, NULL)) {
+ return ret_deny;
+ }
return ret_eagain;
default:
View
7 cherokee/handler_uwsgi.c
@@ -450,6 +450,13 @@ cherokee_handler_uwsgi_read_post (cherokee_handler_uwsgi_t *hdl)
FDPOLL_MODE_WRITE, false);
return ret_deny;
}
+
+ /* ret_eagain - Block on read
+ * ret_deny - Block on back-end write
+ */
+ if (cherokee_post_has_buffered_info (&conn->post, NULL)) {
+ return ret_deny;
+ }
return ret_eagain;
default:
View
7 cherokee/post.c
@@ -529,6 +529,13 @@ do_send_socket (cherokee_socket_t *sock,
return ret_ok;
}
+int
+cherokee_post_has_buffered_info (cherokee_post_t *post,
+ cherokee_buffer_t *tmp)
+{
+ cherokee_buffer_t *buffer = tmp ? tmp : &post->send.buffer;
+ return (! cherokee_buffer_is_empty (buffer));
+}
ret_t
cherokee_post_send_to_socket (cherokee_post_t *post,
View
9 cherokee/post.h
@@ -77,9 +77,12 @@ ret_t cherokee_post_init (cherokee_post_t *post);
ret_t cherokee_post_clean (cherokee_post_t *post);
ret_t cherokee_post_mrproper (cherokee_post_t *post);
-ret_t cherokee_post_read_header (cherokee_post_t *post, void *conn);
-ret_t cherokee_post_has_info (cherokee_post_t *post);
-int cherokee_post_read_finished (cherokee_post_t *post);
+ret_t cherokee_post_read_header (cherokee_post_t *post, void *conn);
+ret_t cherokee_post_has_info (cherokee_post_t *post);
+int cherokee_post_read_finished (cherokee_post_t *post);
+int cherokee_post_has_buffered_info (cherokee_post_t *post,
+ cherokee_buffer_t *tmp);
+
/* Read
*/
View
4 cherokee/thread.c
@@ -671,7 +671,8 @@ process_active_connections (cherokee_thread_t *thd)
}
else if ((conn->phase != phase_shutdown) &&
(conn->phase != phase_lingering) &&
- (conn->phase != phase_reading_header || conn->incoming_header.len <= 0))
+ (conn->phase != phase_reading_header || conn->incoming_header.len <= 0) &&
+ (conn->phase != phase_reading_post || conn->post.send.buffer.len <= 0))
{
re = cherokee_fdpoll_check (thd->fdpoll,
SOCKET_FD(&conn->socket),
@@ -1078,7 +1079,6 @@ process_active_connections (cherokee_thread_t *thd)
conn->phase = phase_reading_post;
case phase_reading_post:
-
/* Read/Send the POST info
*/
ret = cherokee_connection_read_post (conn);

0 comments on commit 616bb65

Please sign in to comment.
Something went wrong with that request. Please try again.