Created
April 6, 2020 09:55
-
-
Save azat/797db20e950960e421e5bdc44d407eb1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// endless loop for EV_CLOSED with the patch applied from | |
// https://github.com/libevent/libevent/issues/984 | |
#include <event2/event.h> | |
#include <unistd.h> | |
#include <assert.h> | |
#include <sys/socket.h> | |
void readcb(int fd, short events, void *arg) | |
{ | |
printf("%s: fd=%i, events=%hi, EV_READ=%hi, EV_CLOSED=%hi\n", | |
__func__, fd, events, events&EV_READ, events&EV_CLOSED); | |
} | |
void closecb(int fd, short events, void *arg) | |
{ | |
printf("%s: fd=%i, events=%hi, EV_READ=%hi, EV_CLOSED=%hi\n", | |
__func__, fd, events, events&EV_READ, events&EV_CLOSED); | |
} | |
int main() | |
{ | |
int fd[2]; | |
struct event_base *base = event_base_new(); | |
struct event *ev1; | |
struct event *ev2; | |
assert(!socketpair(AF_UNIX, SOCK_STREAM, 0, fd)); | |
ev1 = event_new(base, fd[1], EV_READ, readcb, NULL); | |
assert(ev1); | |
ev2 = event_new(base, fd[1], EV_CLOSED|EV_ET, closecb, NULL); | |
assert(ev2); | |
//assert(!event_add(ev1, NULL)); | |
assert(!event_add(ev2, NULL)); | |
//event_active(ev2, EV_READ, 0); | |
assert(!close(fd[0])); | |
return event_base_dispatch(base); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment