libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] http2 suspend/resume


From: Kunal Ekawde
Subject: Re: [libmicrohttpd] http2 suspend/resume
Date: Mon, 7 Jan 2019 12:32:00 +0530

Hi All,

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.


Thanks,
Kunal

On Fri, Jan 4, 2019 at 11:39 PM Kunal Ekawde <address@hidden> wrote:
Hi Christian,

I could get multiple streams working with suspend/resume. Took the following approach:
  1. When request is received, saved the stream id at application.
  2. Suspend now would suspend only the stream logically, so the connection is not suspended – no updating epoll fds as earlier, I update the stream as suspended. MHD_suspend_stream() – new API
  3. When the application wants to sends response (current example – after timer exp), it invokes an new API MHD_resume_stream. In here, I update the stream to be resumed and trigger the MDH inter thread communication.
  4. MHD invokes the callback so that response can be queued.
  5. On queuing the rsp and starting its internal epoll, I check for all the streams for that connections were suspended and have to be resumed, if so , update the epoll internal state and do epoll_ctl so that fd can be triggered to send the response.

Please let me know if this sounds logical or there is basic issue with this approach.

Thanks,
Kunal

On Mon, Dec 31, 2018 at 2:18 PM Kunal Ekawde <address@hidden> wrote:
Hi,

I'm currently checking the http2 combo of nghttp2 + MHD provided by https://github.com/maru/libmicrohttpd-http2.

It doesn't support multiple streams with suspend/resume. To try to make it work, I was thinking if following understanding is correct(only if version is http/2):
To suspend, we need to suspend only the stream and resume also for a particular stream. Here, can we keep MHD connection still in non suspended state ? So something like create and add fd's to epoll for each stream and wake up when application triggers resume on the stream. Will the callbacks be affected and way response is queued ?
Any pointers will be appreciated.

Thanks,
~Kunal


--
~Kunal


--
~Kunal

reply via email to

[Prev in Thread] Current Thread [Next in Thread]