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

Re: [Libevent-users] how to change event type



On Thu, Oct 29, 2015 at 02:08:26AM +0100, liu wen wrote:
> if I have set events conn_ev
> 
> event_set(entry->conn_ev, entry->connfd, EV_READ|EV_PERSIST, on_recv,
> event_arg);
> event_base_set(base, entry->conn_ev);
> event_add(entry->conn_ev, NULL)
> 
> after a number of triggers of this events, I want to make the event become:
> 
> event_set(entry->conn_ev, entry->connfd, EV_READ|EV_TIMEOUT, on_recv,
> event_arg);
> 
> that is I want conn_ev to change from EV_READ|EV_PERSIST to
> EV_READ|EV_TIMEOUT, what should I do?

Hi,

event_set() is not for this, it must be used to *prepare* event to be
added to event base (and internally it call event_assign() which can't
be called for already added events).

If you want to change event you need to call event_add()/event_del()

You can take a look at be_socket_disable()/be_socket_enable() in
bufferevent_sock.c for example.
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.