aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/internal.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-08-28 20:51:54 +0000
committerChristian Grothoff <christian@grothoff.org>2016-08-28 20:51:54 +0000
commitaf90b3cd5169fbc49d376f4b96df1f231a577fdc (patch)
treea29ce09b6676ba7c7175178a99780397b3d4d090 /src/microhttpd/internal.h
parent404538a7cf03d11bbb433e381744a6055bfb72ea (diff)
downloadlibmicrohttpd-af90b3cd5169fbc49d376f4b96df1f231a577fdc.tar.gz
libmicrohttpd-af90b3cd5169fbc49d376f4b96df1f231a577fdc.zip
-setup IO buffers for upgraded connections from memory pool - if possible
Diffstat (limited to 'src/microhttpd/internal.h')
-rw-r--r--src/microhttpd/internal.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index 01d72950..9f0faba7 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -888,6 +888,17 @@ struct MHD_Connection
888 888
889 889
890/** 890/**
891 * Buffer we use for upgrade response handling in the unlikely
892 * case where the memory pool was so small it had no buffer
893 * capacity left. Note that we don't expect to _ever_ use this
894 * buffer, so it's mostly wasted memory (except that it allows
895 * us to handle a tricky error condition nicely). So no need to
896 * make this one big. Applications that want to perform well
897 * should just pick an adequate size for the memory pools.
898 */
899#define RESERVE_EBUF_SIZE 8
900
901/**
891 * Handle given to the application to manage special 902 * Handle given to the application to manage special
892 * actions relating to MHD responses that "upgrade" 903 * actions relating to MHD responses that "upgrade"
893 * the HTTP protocol (i.e. to WebSockets). 904 * the HTTP protocol (i.e. to WebSockets).
@@ -913,6 +924,40 @@ struct MHD_UpgradeResponseHandle
913 struct MHD_UpgradeResponseHandle *prev; 924 struct MHD_UpgradeResponseHandle *prev;
914 925
915 /** 926 /**
927 * The buffer for receiving data from TLS to
928 * be passed to the application. Contains @e in_buffer_size
929 * bytes. Do not free!
930 */
931 char *in_buffer;
932
933 /**
934 * The buffer for receiving data from the application to
935 * be passed to TLS. Contains @e out_buffer_size
936 * bytes. Do not free!
937 */
938 char *out_buffer;
939
940 /**
941 * Size of the @e in_buffer
942 */
943 size_t in_buffer_size;
944
945 /**
946 * Size of the @e out_buffer
947 */
948 size_t out_buffer_size;
949
950 /**
951 * Number of bytes actually in use in the @e in_buffer
952 */
953 size_t in_buffer_off;
954
955 /**
956 * Number of bytes actually in use in the @e out_buffer
957 */
958 size_t out_buffer_off;
959
960 /**
916 * The socket we gave to the application (r/w). 961 * The socket we gave to the application (r/w).
917 */ 962 */
918 MHD_socket app_socket; 963 MHD_socket app_socket;
@@ -932,6 +977,12 @@ struct MHD_UpgradeResponseHandle
932 * IO-state of the @e connection's socket. 977 * IO-state of the @e connection's socket.
933 */ 978 */
934 enum MHD_EpollState celi_client; 979 enum MHD_EpollState celi_client;
980
981 /**
982 * Emergency IO buffer we use in case the memory pool has literally
983 * nothing left.
984 */
985 char e_buf[RESERVE_EBUF_SIZE];
935#endif 986#endif
936 987
937}; 988};