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

[Libevent-users] bufferevent and threads



Hello,

I made a daemon that receives data from a socket, data is read from
callback (readcb) :
> bufferevent_setcb(bev, readcb, NULL, eventcb, conndata);


 then it is given to a thread (because the treatment can be long). Then
this is the thread that writes the result of the treatment on the socket.
> evbuffer_add(outputbuf, res, len);

By doing like this, I have very long response time (several seconds),
but if I add a timeout

> timeoutevent_assign(&timeout, base, -1, EV_PERSIST, timeout_cb,
(void*)&pid);
> evutil_timerclear(&tv);
> tv.tv_sec = 0;
> tv.tv_usec = 10000L;    // 10 ms
> event_add(&timeout, &tv);

I have the answer immediately (10ms)

I tried using functions like:
bufferevent_flush(bev, EV_WRITE, BEV_FLUSH) or
bufferevent_setwatermark(bev, EV_WRITE, 0, 0);

I'm using libevent 2.0.8

Christophe

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