aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/internal.h')
-rw-r--r--src/microhttpd/internal.h72
1 files changed, 58 insertions, 14 deletions
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index 9f0faba7..00843729 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -899,6 +899,45 @@ struct MHD_Connection
899#define RESERVE_EBUF_SIZE 8 899#define RESERVE_EBUF_SIZE 8
900 900
901/** 901/**
902 * Context we pass to epoll() for each of the two sockets
903 * of a `struct MHD_UpgradeResponseHandle`. We need to do
904 * this so we can distinguish the two sockets when epoll()
905 * gives us event notifications.
906 */
907struct UpgradeEpollHandle
908{
909 /**
910 * Reference to the overall response handle this struct is
911 * included within.
912 */
913 struct MHD_UpgradeResponseHandle *urh;
914
915 /**
916 * The socket this event is kind-of about. Note that this is NOT
917 * necessarily the socket we are polling on, as for when we read
918 * from TLS, we epoll() on the connection's socket
919 * (`urh->connection->socket_fd`), while this then the application's
920 * socket (where the application will read from). Nevertheless, for
921 * the application to read, we need to first read from TLS, hence
922 * the two are related.
923 *
924 * Similarly, for writing to TLS, this epoll() will be on the
925 * connection's `socket_fd`, and this will merely be the FD which
926 * the applicatio would write to. Hence this struct must always be
927 * interpreted based on which field in `struct
928 * MHD_UpgradeResponseHandle` it is (`app` or `mhd`).
929 */
930 MHD_socket socket;
931
932 /**
933 * IO-state of the @e socket (or the connection's `socket_fd`).
934 */
935 enum MHD_EpollState celi;
936
937};
938
939
940/**
902 * Handle given to the application to manage special 941 * Handle given to the application to manage special
903 * actions relating to MHD responses that "upgrade" 942 * actions relating to MHD responses that "upgrade"
904 * the HTTP protocol (i.e. to WebSockets). 943 * the HTTP protocol (i.e. to WebSockets).
@@ -960,23 +999,13 @@ struct MHD_UpgradeResponseHandle
960 /** 999 /**
961 * The socket we gave to the application (r/w). 1000 * The socket we gave to the application (r/w).
962 */ 1001 */
963 MHD_socket app_socket; 1002 struct UpgradeEpollHandle app;
964 1003
965 /** 1004 /**
966 * If @a app_sock was a socketpair, our end of it, otherwise 1005 * If @a app_sock was a socketpair, our end of it, otherwise
967 * #MHD_INVALID_SOCKET; (r/w). 1006 * #MHD_INVALID_SOCKET; (r/w).
968 */ 1007 */
969 MHD_socket mhd_socket; 1008 struct UpgradeEpollHandle mhd;
970
971 /**
972 * IO-state of the @e mhd_socket.
973 */
974 enum MHD_EpollState celi_mhd;
975
976 /**
977 * IO-state of the @e connection's socket.
978 */
979 enum MHD_EpollState celi_client;
980 1009
981 /** 1010 /**
982 * Emergency IO buffer we use in case the memory pool has literally 1011 * Emergency IO buffer we use in case the memory pool has literally
@@ -1257,10 +1286,25 @@ struct MHD_Daemon
1257 int epoll_fd; 1286 int epoll_fd;
1258 1287
1259 /** 1288 /**
1260 * MHD_YES if the listen socket is in the 'epoll' set, 1289 * #MHD_YES if the listen socket is in the 'epoll' set,
1261 * MHD_NO if not. 1290 * #MHD_NO if not.
1262 */ 1291 */
1263 int listen_socket_in_epoll; 1292 int listen_socket_in_epoll;
1293
1294#if HTTPS_SUPPORT
1295 /**
1296 * File descriptor associated with the #run_epoll_for_upgrade() loop.
1297 * Only available if #MHD_USE_HTTPS_EPOLL_UPGRADE is set.
1298 */
1299 int epoll_upgrade_fd;
1300
1301 /**
1302 * #MHD_YES if @e epoll_upgrade_fd is in the 'epoll' set,
1303 * #MHD_NO if not.
1304 */
1305 int upgrade_fd_in_epoll;
1306#endif
1307
1264#endif 1308#endif
1265 1309
1266 /** 1310 /**