Comments (4)
Hello.
bufferevent_write as asynchronous write, it only adds to the evbuffer, and later when write is possible it will be written.
Also the time may depends on the some ratelimiting and stacking various bufferevents (though unlikely you have this).
What is the delay? Maybe EV_WRITE is not enabled for this bufferevent? (but then it will not be written at all). Can you provide a 100 line reproducer?
from libevent.
Hi, thanks for the reply. The issue has suddenly ceased to exist and I'm still not sure exactly what caused it. When the problem occurred before, the delay could reach 10ms+.
Also, I found that the behavior of the max_read buffer differs between version 2.1.12 and 2.2.1.alpha: in 2.1.12 I set the length beyond 16K via bufferevent_set_max_single_read, but it still occurs in the callbacks for processing the data that no message of the fulfilled size is read at once ( I realize that this can happen for real), however in 2.2.1.alpha this problem does not occur.
from libevent.
Hello.
Some code is:
static int sess_response(t_sess* sess)
{
if (sess->bev != NULL && bufferevent_write(sess->bev, sess->msg_out_buf, sess->msg_out_len) < 0)
{
LOG_REPORT_ERROR("bufferevent_write failed");
}
return 0;
}
static void conn_readcb(struct bufferevent* bev, void* user_data)
{
t_sess* sess = (t_sess*)user_data;
while (sess_nonblock_parse_request(sess))
{
// process one request, ant then call sess_response send response to client.
sess_handle_one_request(sess);
}
}
static void
listener_cb(struct evconnlistener* listener, evutil_socket_t fd, struct sockaddr* sa, int socklen, void* user_data)
{
t_uint32 network_event_base_index = os_interlock_inc_fetch(&next_network_event_base_index);
struct event_base* network_event_base = NULL;
struct bufferevent* bev;
t_sess* sess = sess_create(NULL, FALSE);
network_event_base_index = network_event_base_index % network_event_base_num;
network_event_base = network_event_base_array[network_event_base_index];
bev = bufferevent_socket_new(network_event_base, fd, BEV_OPT_CLOSE_ON_FREE);
if (!bev)
{
event_base_loopbreak(network_event_base);
return;
}
sess->bev = bev;
bufferevent_set_max_single_read(bev, 16 * 1024);
bufferevent_set_max_single_write(bev, 16 * 1024);
bufferevent_setcb(bev, conn_readcb, NULL, conn_eventcb, sess);
bufferevent_enable(bev, EV_WRITE | EV_READ);
}
listener = evconnlistener_new_bind(listen_event_base,
listener_cb,
(void*)listen_event_base,
LEV_OPT_REUSEABLE | LEV_OPT_CLOSE_ON_FREE,
-1,
(struct sockaddr*)&sin,
sizeof(sin));
Benchmark result:
use libevent 2.2.1.alpha. This above code cost 3m2s complete my job, bug If we direct use send
function write data to session, it cost 2m44s .
from libevent.
Through my test and analysis I feel this is caused to calling epoll _ wait too many times.
from libevent.
Related Issues (20)
- WSOptions enum value bug
- Potential NULL pointer dereference HOT 1
- Potential Null dereference in test-dumpevents.c HOT 1
- Potential Null pointer dereference in bufferevent_openssl.c HOT 1
- Potential Null pointer dereference in regress_ws.c HOT 1
- Potential Null pointer dereference in time-test.c HOT 1
- Failure making HTTP request to unix socket HOT 2
- Coverage report is broken
- Undefined symbols for architecture after building libevent HOT 2
- libevent for iOS HOT 8
- MacOS CI is broken HOT 7
- event_process_active_single_queue: Use of memory after it is freed
- Unexpected input(s) 'vcpkgArguments', 'vcpkgTriplet' HOT 2
- feature request: http/3 client HOT 2
- windows socks5 combo mbedtls client: [warn] BUG: Unexpected mbedtls error code -29184: SSL - An invalid SSL record was received HOT 1
- Class member functions to be param callback of event_new HOT 1
- deadlock on event_del_nolock_() HOT 2
- Segmentation fault after bufferevent_write HOT 4
- bufferevent_write deadlock
- buffereven_write blocking problem HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libevent.