1

I have this multithreaded app with a loop for each thread and two paired bufferevents per thread to send/receive data between those and the main thread.

This in theory. In practice, bufferevent_pair_new() returns fine, but two bufferevent structures without usable descriptors are created, so when I call bufferevent_getfd() with them, I get -1 for both.

Of course, when I try to attach them to a event loop without any other event added previously, thread returns and a "loop without events" error is raised.

I saw something similar in Tor (paired bufferevents to communicate between threads). Am I doing it right? Do I need something else?

4

1 回答 1

0

我知道这是一个较老的问题,但我碰巧在寻找其他信息时找到了答案,所以我想我会把它贴在这里以防有人仍然需要它。原来的答案在这里http://archives.seul.org/libevent/users/Jul-2011/msg00009.html

万一它被取下来,我也会总结一下。

配对缓冲区事件没有任何内部事件,因此它们不会阻止事件循环达到无事件挂起状态并且循环退出。给出的解决方法是添加一个不做任何事情的计时器事件。然而,它会阻止循环结束。有可能修复它,以便成对的缓冲区事件可以防止循环退出,但我不知道它是否已经完成。上面链接的通信与原始帖子的日期相同,甚至可能是通过另一个资源对 OP 的回应。

于 2013-04-26T16:03:35.743 回答