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

[Libevent-users] How to activate read callback when not all data was read



Hi,

In my daemon which uses libevent, i use bufferevent to read client commands
from a socket, set everything up to eventually generate the reply, and return to
the event loop.

Now a client may send several commands in one go. If I only read the first
command and drain the corresponding bytes from the bufferevent's input
buffer, the read callback will not be called until *more* data arrives,
so if a client sends two commands in one go, I need to somehow queue
the second (and further) commands before returning to the main loop,
otherwise the commands never gets processed.

Is there some other way, to get the second command processed,
something like "return to the main loop, but mark this callback as
still pending, and call it again"

In other words, bufferevent forces me to do edge-triggered event
handling. Is there a way to let me do level-triggered event handling
instead.

Or is there something like a idle task, that get called when there is
nothing else to do? Working with timeouts would introduce arbitrary gaps
in command handling, event if there are no other clients that want
work, so I won't go that route. Or does setting a timeout of { 0, 0 }
work?

-- 

Mit freundlichen Grüßen / with kind regards

Nils Rennebarth, Software Developer

--
Funkwerk IP-Appliances GmbH
Mönchhaldenstraße 28
D-70191 Stuttgart

Tel: +49 711 900300 - 0
Fax: +49 711 900300 - 90

E-Mail: Nils.Rennebarth@xxxxxxxxxxxxxxx

Location: GmbH Nuernberg, Local Court Nuernberg, HRB 25481
Managing Directors: Torsten Urban
--------------------------------
The information contained in this e-mail has been carefully researched,
but the possibility of it being inapplicable in individual cases cannot
be ruled out. We therefore regret that we cannot accept responsibility
or liability of any kind whatsoever for the correctness of the
information given. Please notify us if you discover that information is
inapplicable.

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