Re: [Libevent-users] Q: Exception callbacks and events that should run immediately

2012-12-05 Thread Sashan Govender
Hi!


> 1) I don't see any notion of event notification on FD exception - e.g.
> socket close.
> There are some words for buffer events, but nothing for regular file
> descriptor based callbacks. So what is a good way to get a callback
> when specific
> FD is closed/disconnected?
>

If the fd is a socket and the peer closes then you'll get a read callback.
When you read from the fd 'read' will return 0 indicating that the peer
closed.



>
> 2) Sometimes I need to post an event that will be executed in the same
> event loop iteration
> (possibly after other events are processed)- e.g.  I want to break a
> long call stack and restart
> from the event loop or want to give other events a chance to run. What
> is the good way of doing this -
> should I just post a timer event with a zero timeout value or do
> something else?
>
>
>
Not sure.


Re: Re : [Libevent-users] libevent client tries to reconnect to a lost server

2013-01-14 Thread Sashan Govender
On Tue, Jan 15, 2013 at 9:52 AM,  wrote:

> It serms that this is not the way it should be done. The whole buffer
> event should be removed and created again, until the server starts to
> respond. Unfortunately this method causes a segmentation fault. I had no
> idea of how such a simple problem can be solved with libevent. I couldn't
> be able to find an example.
>

I wouldn't say that  I've used libevent in two programs and managed to
reconnect to the server if a disconnection happens after the initial
connect. I did this by setting up a timer event that was on while the
client was disconnected and off while the client was connected or a
connection was in progress. This works fine.


[Libevent-users] evbuffer_find versus evbuffer_search

2013-04-10 Thread Sashan Govender
Hi

I'm porting some code from libevent 1.4 to 2.0 and in the 1.4 version some
of the code is using evbuffer_find find a pointer to the start of a
sequence then calculating a pointer difference from it:

u_char* end = evbuffer_find(input, pattern, 2);
...
 ptrdiff_t len = end - input->buffer;

But in 2.0 the evbuffer struct is now opaque and I can't access members of
it (i.e. the dereference here input->buffer will not compile). How should I
change this so that it works with 2.0.

Thanks


[Libevent-users] questions about bufferevent callbacks in multithreaded code

2013-05-01 Thread Sashan Govender
Hi

I need to clarify my understanding of how bufferevent objects work with
mulithreaded code. If a bufferevent triggers a callback (read or write)
does it hold a lock until that callback completes? Do the locks use a
recursive mutex?

Thanks