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?

Manuel Abeledo
  • 327
  • 2
  • 4
  • 14
  • Apparently, I can add a bufferevent pair to an event base, but they don't have associated file descriptors and the loop ends prematurely. I can write/read as long as I've defined another event (with an actual file descriptor) attached to the loop. Seems like I'll have to use pipes. – Manuel Abeledo Jun 06 '11 at 06:52

1 Answers1

0

I know this is an older question but I happen to have found an answer in looking for other information so I figured I would post it here in case someone still needs it. The original answer was here http://archives.seul.org/libevent/users/Jul-2011/msg00009.html

In case it gets taken down however I will also summarize it.

Paired buffer events don't have any internal events so they don't stop the event loop from reaching a no events pending status and the loop exits. The workaround given was to add a timer event that didn't do anything. It would however keep the loop from ending. There was a possibility of fixing it so that the paired buffer events would prevent the loop from exiting but I don't know if it was ever done. The communication linked above has the same date as the original post, maybe it was even a response to the OP through another resource.

Edward Goodson
  • 302
  • 1
  • 11