Commit 40e5c744 authored by Sergey Lyubka's avatar Sergey Lyubka

Calling long-running URI handlers on each poll iteration

parent e648681f
...@@ -318,7 +318,8 @@ enum connection_flags { ...@@ -318,7 +318,8 @@ enum connection_flags {
CONN_HEADERS_SENT = 8, // User callback has sent HTTP headers CONN_HEADERS_SENT = 8, // User callback has sent HTTP headers
CONN_BUFFER = 16, // CGI only. Holds data send until CGI prints CONN_BUFFER = 16, // CGI only. Holds data send until CGI prints
// all HTTP headers // all HTTP headers
CONN_CONNECTED = 32 // HTTP client has connected CONN_CONNECTED = 32, // HTTP client has connected
CONN_LONG_RUNNING = 64 // Long-running URI handlers
}; };
struct connection { struct connection {
...@@ -1917,6 +1918,8 @@ static void call_uri_handler(struct connection *conn) { ...@@ -1917,6 +1918,8 @@ static void call_uri_handler(struct connection *conn) {
write_terminating_chunk(conn); write_terminating_chunk(conn);
} }
close_local_endpoint(conn); close_local_endpoint(conn);
} else {
conn->flags |= CONN_LONG_RUNNING;
} }
} }
...@@ -1940,11 +1943,6 @@ static void write_to_client(struct connection *conn) { ...@@ -1940,11 +1943,6 @@ static void write_to_client(struct connection *conn) {
conn->num_bytes_sent += n; conn->num_bytes_sent += n;
} }
if (conn->endpoint_type == EP_USER && !conn->mg_conn.is_websocket) {
conn->mg_conn.wsbits = conn->flags & CONN_CLOSE ? 1 : 0;
call_uri_handler(conn);
}
if (io->len == 0 && conn->flags & CONN_SPOOL_DONE) { if (io->len == 0 && conn->flags & CONN_SPOOL_DONE) {
conn->flags |= CONN_CLOSE; conn->flags |= CONN_CLOSE;
} }
...@@ -3741,6 +3739,11 @@ unsigned int mg_poll_server(struct mg_server *server, int milliseconds) { ...@@ -3741,6 +3739,11 @@ unsigned int mg_poll_server(struct mg_server *server, int milliseconds) {
conn->last_activity_time = current_time; conn->last_activity_time = current_time;
write_to_client(conn); write_to_client(conn);
} }
if (conn->flags & CONN_LONG_RUNNING) {
conn->mg_conn.wsbits = conn->flags & CONN_CLOSE ? 1 : 0;
call_uri_handler(conn);
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment