Hi, I found and solved my problem. I just added 'evthread_use_pthreads();' before 'event_base_dispatch(base);' and 'BEV_OPT_THREADSAFE' > bev = bufferevent_socket_new(base, newsock, BEV_OPT_CLOSE_ON_FREE|BEV_OPT_THREADSAFE);
Bye. Le 04/11/2010 14:46, Christophe ZBIERSKI a écrit : > 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 majord...@freehaven.net with > unsubscribe libevent-users in the body. > > *********************************************************************** To unsubscribe, send an e-mail to majord...@freehaven.net with unsubscribe libevent-users in the body.