diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2022-10-20 19:21:52 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2022-10-22 09:48:06 +0300 |
commit | 699b6cd5636ef7ce2e41b42301fc1b56f9a02f8e (patch) | |
tree | a7203aba95af3df388f553c8bf6e15cbcd565b76 | |
parent | 571ec180781a55a63007d97bad9755265b282ebf (diff) | |
download | libmicrohttpd-699b6cd5636ef7ce2e41b42301fc1b56f9a02f8e.tar.gz libmicrohttpd-699b6cd5636ef7ce2e41b42301fc1b56f9a02f8e.zip |
Added new state for MHD_ConnectionEventLoopInfo
-rw-r--r-- | src/microhttpd/connection.c | 2 | ||||
-rw-r--r-- | src/microhttpd/daemon.c | 24 | ||||
-rw-r--r-- | src/microhttpd/internal.h | 7 |
3 files changed, 22 insertions, 11 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index 2056fe3d..3cc4fe00 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c | |||
@@ -5278,7 +5278,7 @@ MHD_connection_epoll_update_ (struct MHD_Connection *connection) | |||
5278 | (0 == (connection->epoll_state & MHD_EPOLL_STATE_SUSPENDED)) && | 5278 | (0 == (connection->epoll_state & MHD_EPOLL_STATE_SUSPENDED)) && |
5279 | ( ( (MHD_EVENT_LOOP_INFO_WRITE == connection->event_loop_info) && | 5279 | ( ( (MHD_EVENT_LOOP_INFO_WRITE == connection->event_loop_info) && |
5280 | (0 == (connection->epoll_state & MHD_EPOLL_STATE_WRITE_READY))) || | 5280 | (0 == (connection->epoll_state & MHD_EPOLL_STATE_WRITE_READY))) || |
5281 | ( (MHD_EVENT_LOOP_INFO_READ == connection->event_loop_info) && | 5281 | ( (0 != (MHD_EVENT_LOOP_INFO_READ & connection->event_loop_info)) && |
5282 | (0 == (connection->epoll_state & MHD_EPOLL_STATE_READ_READY)) ) ) ) | 5282 | (0 == (connection->epoll_state & MHD_EPOLL_STATE_READ_READY)) ) ) ) |
5283 | { | 5283 | { |
5284 | /* add to epoll set */ | 5284 | /* add to epoll set */ |
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 59a7d7e1..fd40b341 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -985,6 +985,7 @@ internal_get_fdset2 (struct MHD_Daemon *daemon, | |||
985 | switch (pos->event_loop_info) | 985 | switch (pos->event_loop_info) |
986 | { | 986 | { |
987 | case MHD_EVENT_LOOP_INFO_READ: | 987 | case MHD_EVENT_LOOP_INFO_READ: |
988 | case MHD_EVENT_LOOP_INFO_PROCESS_READ: | ||
988 | if (! MHD_add_to_fd_set_ (pos->socket_fd, | 989 | if (! MHD_add_to_fd_set_ (pos->socket_fd, |
989 | read_fd_set, | 990 | read_fd_set, |
990 | max_fd, | 991 | max_fd, |
@@ -1181,7 +1182,7 @@ call_handlers (struct MHD_Connection *con, | |||
1181 | if (con->tls_read_ready) | 1182 | if (con->tls_read_ready) |
1182 | read_ready = true; | 1183 | read_ready = true; |
1183 | #endif /* HTTPS_SUPPORT */ | 1184 | #endif /* HTTPS_SUPPORT */ |
1184 | if ( (MHD_EVENT_LOOP_INFO_READ == con->event_loop_info) && | 1185 | if ( (0 != (MHD_EVENT_LOOP_INFO_READ & con->event_loop_info)) && |
1185 | (read_ready || (force_close && con->sk_nonblck)) ) | 1186 | (read_ready || (force_close && con->sk_nonblck)) ) |
1186 | { | 1187 | { |
1187 | MHD_connection_handle_read (con, force_close); | 1188 | MHD_connection_handle_read (con, force_close); |
@@ -1255,11 +1256,11 @@ call_handlers (struct MHD_Connection *con, | |||
1255 | if ( (! con->daemon->data_already_pending) && | 1256 | if ( (! con->daemon->data_already_pending) && |
1256 | (0 == (con->daemon->options & MHD_USE_THREAD_PER_CONNECTION)) ) | 1257 | (0 == (con->daemon->options & MHD_USE_THREAD_PER_CONNECTION)) ) |
1257 | { | 1258 | { |
1258 | if (MHD_EVENT_LOOP_INFO_BLOCK == con->event_loop_info) | 1259 | if (0 != (MHD_EVENT_LOOP_INFO_BLOCK & con->event_loop_info)) |
1259 | con->daemon->data_already_pending = true; | 1260 | con->daemon->data_already_pending = true; |
1260 | #ifdef HTTPS_SUPPORT | 1261 | #ifdef HTTPS_SUPPORT |
1261 | else if ( (con->tls_read_ready) && | 1262 | else if ( (con->tls_read_ready) && |
1262 | (MHD_EVENT_LOOP_INFO_READ == con->event_loop_info) ) | 1263 | (0 != (MHD_EVENT_LOOP_INFO_READ & con->event_loop_info)) ) |
1263 | con->daemon->data_already_pending = true; | 1264 | con->daemon->data_already_pending = true; |
1264 | #endif /* HTTPS_SUPPORT */ | 1265 | #endif /* HTTPS_SUPPORT */ |
1265 | } | 1266 | } |
@@ -1985,13 +1986,13 @@ thread_main_handle_connection (void *data) | |||
1985 | was_suspended = false; | 1986 | was_suspended = false; |
1986 | } | 1987 | } |
1987 | 1988 | ||
1988 | use_zero_timeout = ( (MHD_EVENT_LOOP_INFO_BLOCK == con->event_loop_info) | 1989 | use_zero_timeout = |
1990 | (0 != (MHD_EVENT_LOOP_INFO_BLOCK & con->event_loop_info) | ||
1989 | #ifdef HTTPS_SUPPORT | 1991 | #ifdef HTTPS_SUPPORT |
1990 | || ( (con->tls_read_ready) && \ | 1992 | || ( (con->tls_read_ready) && |
1991 | (MHD_EVENT_LOOP_INFO_READ == | 1993 | (0 != (MHD_EVENT_LOOP_INFO_READ & con->event_loop_info)) ) |
1992 | con->event_loop_info) ) | ||
1993 | #endif /* HTTPS_SUPPORT */ | 1994 | #endif /* HTTPS_SUPPORT */ |
1994 | ); | 1995 | ); |
1995 | if (! use_poll) | 1996 | if (! use_poll) |
1996 | { | 1997 | { |
1997 | /* use select */ | 1998 | /* use select */ |
@@ -2027,6 +2028,7 @@ thread_main_handle_connection (void *data) | |||
2027 | switch (con->event_loop_info) | 2028 | switch (con->event_loop_info) |
2028 | { | 2029 | { |
2029 | case MHD_EVENT_LOOP_INFO_READ: | 2030 | case MHD_EVENT_LOOP_INFO_READ: |
2031 | case MHD_EVENT_LOOP_INFO_PROCESS_READ: | ||
2030 | if (! MHD_add_to_fd_set_ (con->socket_fd, | 2032 | if (! MHD_add_to_fd_set_ (con->socket_fd, |
2031 | &rs, | 2033 | &rs, |
2032 | &maxsock, | 2034 | &maxsock, |
@@ -2133,6 +2135,7 @@ thread_main_handle_connection (void *data) | |||
2133 | switch (con->event_loop_info) | 2135 | switch (con->event_loop_info) |
2134 | { | 2136 | { |
2135 | case MHD_EVENT_LOOP_INFO_READ: | 2137 | case MHD_EVENT_LOOP_INFO_READ: |
2138 | case MHD_EVENT_LOOP_INFO_PROCESS_READ: | ||
2136 | p[0].events |= POLLIN | MHD_POLL_EVENTS_ERR_DISC; | 2139 | p[0].events |= POLLIN | MHD_POLL_EVENTS_ERR_DISC; |
2137 | break; | 2140 | break; |
2138 | case MHD_EVENT_LOOP_INFO_WRITE: | 2141 | case MHD_EVENT_LOOP_INFO_WRITE: |
@@ -4750,6 +4753,7 @@ MHD_poll_all (struct MHD_Daemon *daemon, | |||
4750 | switch (pos->event_loop_info) | 4753 | switch (pos->event_loop_info) |
4751 | { | 4754 | { |
4752 | case MHD_EVENT_LOOP_INFO_READ: | 4755 | case MHD_EVENT_LOOP_INFO_READ: |
4756 | case MHD_EVENT_LOOP_INFO_PROCESS_READ: | ||
4753 | p[poll_server + i].events |= POLLIN | MHD_POLL_EVENTS_ERR_DISC; | 4757 | p[poll_server + i].events |= POLLIN | MHD_POLL_EVENTS_ERR_DISC; |
4754 | break; | 4758 | break; |
4755 | case MHD_EVENT_LOOP_INFO_WRITE: | 4759 | case MHD_EVENT_LOOP_INFO_WRITE: |
@@ -5362,7 +5366,7 @@ MHD_epoll (struct MHD_Daemon *daemon, | |||
5362 | if (0 != (events[i].events & EPOLLIN)) | 5366 | if (0 != (events[i].events & EPOLLIN)) |
5363 | { | 5367 | { |
5364 | pos->epoll_state |= MHD_EPOLL_STATE_READ_READY; | 5368 | pos->epoll_state |= MHD_EPOLL_STATE_READ_READY; |
5365 | if ( ( (MHD_EVENT_LOOP_INFO_READ == pos->event_loop_info) || | 5369 | if ( ( (0 != (MHD_EVENT_LOOP_INFO_READ & pos->event_loop_info)) || |
5366 | (pos->read_buffer_size > pos->read_buffer_offset) ) && | 5370 | (pos->read_buffer_size > pos->read_buffer_offset) ) && |
5367 | (0 == (pos->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL) ) ) | 5371 | (0 == (pos->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL) ) ) |
5368 | { | 5372 | { |
@@ -5452,7 +5456,7 @@ MHD_epoll (struct MHD_Daemon *daemon, | |||
5452 | (pos->epoll_state & (MHD_EPOLL_STATE_SUSPENDED | 5456 | (pos->epoll_state & (MHD_EPOLL_STATE_SUSPENDED |
5453 | | MHD_EPOLL_STATE_IN_EREADY_EDLL))) | 5457 | | MHD_EPOLL_STATE_IN_EREADY_EDLL))) |
5454 | { | 5458 | { |
5455 | if ( ((MHD_EVENT_LOOP_INFO_READ == pos->event_loop_info) && | 5459 | if ( ((0 != (MHD_EVENT_LOOP_INFO_READ & pos->event_loop_info)) && |
5456 | (0 == (pos->epoll_state & MHD_EPOLL_STATE_READ_READY)) ) || | 5460 | (0 == (pos->epoll_state & MHD_EPOLL_STATE_READ_READY)) ) || |
5457 | ((MHD_EVENT_LOOP_INFO_WRITE == pos->event_loop_info) && | 5461 | ((MHD_EVENT_LOOP_INFO_WRITE == pos->event_loop_info) && |
5458 | (0 == (pos->epoll_state & MHD_EPOLL_STATE_WRITE_READY)) ) || | 5462 | (0 == (pos->epoll_state & MHD_EPOLL_STATE_WRITE_READY)) ) || |
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h index 6a94faea..89a68772 100644 --- a/src/microhttpd/internal.h +++ b/src/microhttpd/internal.h | |||
@@ -227,6 +227,13 @@ enum MHD_ConnectionEventLoopInfo | |||
227 | MHD_EVENT_LOOP_INFO_BLOCK = 1 << 2, | 227 | MHD_EVENT_LOOP_INFO_BLOCK = 1 << 2, |
228 | 228 | ||
229 | /** | 229 | /** |
230 | * Some data is ready to be processed, but more data could | ||
231 | * be read. | ||
232 | */ | ||
233 | MHD_EVENT_LOOP_INFO_PROCESS_READ = | ||
234 | MHD_EVENT_LOOP_INFO_READ | MHD_EVENT_LOOP_INFO_BLOCK, | ||
235 | |||
236 | /** | ||
230 | * We are finished and are awaiting cleanup. | 237 | * We are finished and are awaiting cleanup. |
231 | */ | 238 | */ |
232 | MHD_EVENT_LOOP_INFO_CLEANUP = 1 << 3 | 239 | MHD_EVENT_LOOP_INFO_CLEANUP = 1 << 3 |