fd/socket free() memory leak and EV_WRITE post event
schmorp at schmorp.de
Sat Feb 26 15:16:08 CET 2011
On Sat, Feb 26, 2011 at 01:01:40PM +0100, Rémi Pecqueur <remi.pecqueur at gmail.com> wrote:
> 1) *fd/socket free()/memory leak*:
> I am running libev on win32 on a server side to discuss with a mobile
> application. I try to reuse as much as possible the 64 file descriptors
With new-enough libc, compiler, and OS the limit is either 512 or 2048.
> close either the socket or the fd works, the other crash... I test the
> program on another computer and it results the same issue. Then, if I am
> closing only the fd (without the socketclose) and free the other ressources,
> I have a memory leak at each close...
Hard to say without even knowing where your program crashes. It could be a
bug in your handling of resources (on win32 you have to juggle both fds and
There is also a bug in the current libev release that causes handles not to
be correctly removed from the fd set. That shouldn't cause crashes, but who
For the latter, you could try the CVS version of libev, which has this
> 2) *ev_write event generation:*
> I found the libev io watcher/loop very interesting implementation and I was
> expecting to use this smart approach not only to watch read events but to
> watch internal write events as well. The documentation explains how to
> interface the EV_WRITE event to a WriteCallback, but I do not know how to
> generate a write event to call my WriteCallback from the ev_loop. Should I
> use the "ev_once()" or "ev_feed_fd_event()" APIs or anything else?
It's not clear to me what you actually want to do. If you rarely want to
watch for some event, then ev_once is probably easiest, but it' more
efficient to have a write watcher and start and stop that one.
If you want to queue an even for an existing watcher (and you have the
pointer), then ev_feed_event is the right function to call. If you have the
fd and want to simulate an event, then ev_feed_fd_event is the right function.
And if you just want to invoke the callback function for an existing
event, you can simply use ev_invoke, which will instantly call the
callback as libev would do it.
The choice of a Deliantra, the free code+content MORPG
-----==- _GNU_ http://www.deliantra.net
----==-- _ generation
---==---(_)__ __ ____ __ Marc Lehmann
--==---/ / _ \/ // /\ \/ / schmorp at schmorp.de
More information about the libev