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

Re: [Libevent-users] evbuffer_add_file() file descriptor exhaustion experiment



On Sun, Nov 02, 2014 at 10:40:08PM +0300, Azat Khuzhin wrote:
> On Fri, Oct 31, 2014 at 02:52:43PM +0100, Marcin Szewczyk wrote:
> > I am struggling with exhaustion of file descriptors when using
> > evbuffer_add_file(). My application responds to every line of input with
> > contents of a file. I don't know how to efficiently control open
> > descriptors number so when input rate is high I hit the open file

> And what you want to do when you are out of fds?
> (Actually you already know this - open(2) will return -1 and errno will
> be installed to EMFILE)

Actually the final goal is to keep a pool of free fds for new
connections and suspend evbuffer_add_file() responses.

> *But* I guess you could use evbuffer_file_segment*() API, it have all
> you need - cleanup callback, so you could track when some of fds closed,
> and since you are already could track when some of fds opened (you call
> open(2)), you will have 'open file descriptors count' implementation.
> 
> Is this what you want?

Yes. Now I feel embarrassed. Somehow I was so focused on libevent 2.0
that I missed callbacks for segments in 2.1.

> P.S. evbuffer_add_file() do use evbuffer_file_segment*() API, but
> without any cleanup callback and with EVBUF_FS_CLOSE_ON_FREE flag.

Thank you very much for pulling me out from brain dead-lock.

-- 
Marcin Szewczyk                       http://wodny.org
mailto:Marcin.Szewczyk@xxxxxxxxxx  <- remove b / usuÅ b
xmpp:wodny@xxxxxxxxx                  xmpp:wodny@xxxxxxxxxx
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.