我想控制每个进程可能的 libevent-http 连接的限制。
我怎样才能做到这一点 ?
我在文档中没有找到任何信息,请帮助!
我认为如果我不限制连接数 - 系统可能会崩溃。项目负载非常高。
ev_base = event_init();
ev_http = evhttp_new(ev_base);
// limit http connections here... how can i do that?
struct evconnlistener *
evconnlistener_new(struct event_base *base,
evconnlistener_cb cb, void *ptr, unsigned flags, int backlog,
evutil_socket_t fd)
待办事项是您要修改的内容。他们在内部调用:
listen(fd, backlog)
然而,在他们的 http 库中,他们将积压工作修复为 128:
evhttp_bind_socket_with_handle(struct evhttp *http, const char *address, ev_uint16_t port)
{
[...]
if (listen(fd, 128) == -1) {
event_sock_warn(fd, "%s: listen", __func__);
evutil_closesocket(fd);
return (NULL);
}
[...]
}