[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libmicrohttpd] Blocking read and performance
From: |
Tom Wambold |
Subject: |
Re: [libmicrohttpd] Blocking read and performance |
Date: |
Wed, 23 Oct 2013 19:35:16 -0400 |
Hi Adam:
On Wed, Oct 23, 2013 at 4:19 PM, Adam Almos Homolya
<address@hidden> wrote:
> I would like to stream large amount of data that is being read
> asynchronously so that I can't ensure that when libmicrohttpd is calling the
> reader callback any byte is available for read without blocking. The
> documentation says returning zero from the callback will result in a busy
> wait which is not an option. Can you give any advise how to work around this
> problem?
I solved this using MHD_USE_THREAD_PER_CONNECTION, and locks to block
threads. I wrapped this code up on GitHub at [1] (look at
microhttpd_pubsub.h). It's probably not ideal if you are going to have
lots of clients connecting to one server, but this worked for my
small-scale needs.
As an aside, I haven't actually published a link to this before, so if
you (or anyone else) ends up looking at it, I'd be happy to respond to
any questions/comments. It's been a little while since I looked at this
code though.
-Tom Wambold
[1]: https://github.com/tom5760/microhttpd_utils