[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] Handling concurent evhttp connections with evhttp_send_reply_chunk.



On Mon, Nov 16, 2009 at 9:12 AM, Krzysztof Adamski <k@xxxxxxxx> wrote:
> i would like to build simple HTTPD server using libevent2. It is going
> to send some quite big files but i would like it to handle couple
> concurrent connections. The files can be sent in chunks so I'm using
> evhttp_send_reply_chunk for this. The problem is, how can I send big
> files while still being able to handle new connections?

The way that chunked connections work at the moment is that you need
some other event to drive new data being sent to the client.   The
problem with a single-threaded server is not blocking on the file
reads.   In libevent-1.4, there is no way to set watermarks or similar
feedback mechanisms.   However, as we have switched to bufferevents in
libevent-2.0; this should be possible.

Alternatively, you could read files in a separate process or thread
and then send data out as it becomes available.

> when client disconnect in the middle of the transfer, however. I can't
> get fd of the connection form evhttp_request so it's impossible to set
> event callback for EV_WRITE instead of EV_TIMEOUT.

The problem with how chunked connections work at the moment is that
you do not get any feedback when they client has closed the
connection.  I will need to take another look at that and write a test
case for the scenario.

Let me know if you have further questions.

Thanks,
Niels.
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.