May be I need to put it in a way specific to only MHD. Any help or pointers stating which areas could break or needs to be re-looked would be much appreciated.
For HTTP2, I'm trying https://github.com/maru/libmicrohttpd-http2
which has integration of nghttp2 with MHD. But it was some open areas as mentioned by the author. One of them is to support multiple streams with suspend/resume.
Since multiple streams needs to be processed over a single connection, we cannot suspend entire connection on a single request over a stream. I've done few changes to MHD over the changes done in above mentioned library to get this working. I shall list here the changes specific to MHD so that I could get some comments.
1. When a request is received over a stream, connection wont be suspended but some data structures would be updated regarding stream details.
2. So if multiple requests are received over the connection, only the data structures would be updated to reflect that stream is suspended, the connection/epoll state/epoll list/suspended list not updated or changed.
3. On resume, the application needs to pass the stream id as well along the connection, here it will update the stream data-structure to indicate that it needs to be resumed and trigger/activate the MHD ITC.
4. As part of MHD_connection_handle_idle API, it will also monitor the state of the streams i.e. if they were suspended and needs to be resumed.
5. When the condition is met in #4, it invokes the MHD access handler callback.
6. On the callback, when MHD_queue_response is invoked, it would update the epoll state for the connection (epoll state ready & write ready) & invoke MHD_connection_epoll_update_()
7. In MHD_connection_epoll_update_(), if the connection is http2 it will update the epoll_ctl to epoll_mod instead of epoll_add, which would eventually trigger sending response for this stream.