mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-23 20:11:49 +00:00
Calling long-running URI handlers on each poll iteration
This commit is contained in:
1 parent
e648681f1d
commit
40e5c744da
1 file changed
+9
-6
+9
-6
@@ -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) {
|
|||||||
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) {
|
|||||||
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) {
|
|||||||
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user