[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] event_add fails with ENOENT when on epoll
- To: libevent-users@xxxxxxxxxxxxx
- Subject: [Libevent-users] event_add fails with ENOENT when on epoll
- From: Denis Bilenko <denis.bilenko@xxxxxxxxx>
- Date: Tue, 20 Apr 2010 10:24:51 +0700
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Mon, 19 Apr 2010 23:24:58 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:received:message-id :subject:from:to:content-type; bh=bJodPHkGpU13XWxMTjRwyjzgkuIST14yqmIAtpECBKw=; b=nWvXcIP/Q/Xtq+X1oAwUrSWj4Bq6nRL5W0IdekTzXiejrW9CSEF32WVVq61cux/b7s oCwynFEyDw3TQhWbCrwk7yxzkSvaCHSZkLoLBiUueSwcjPDnMlritzydU0tZycDXHb0y OIWRl991GD3oueR8eJdlEI3Smi0IV8wyypLkc=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=P9pprC5WOT3B3XqUDmNDxNBGHC0C6p9Gk2qEp++VJL9o25Bi8gHWmTZMP1fHqlm2xq PAjW37w2Jgaq3CzUz0CJ51L4/M/nztXDpksJUTDx+NP8845EP5M3a7FsIsJvX7Ctppqy vs1PXw5x9AI8UOiLWEcS28ZNBDSpNRGwPIdxg=
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
Hi,
I've run into an issue where event_add() fails with ENOENT.
This happens when a socket reuses a descriptor that was recently
closed and was used before with another event.
The details are below. The question I have is - what are the ways to
work around this?
Thanks,
Denis.
http://www.gevent.org - Python network library based on libevent.
---
Here's how to reproduce the bug:
#include "event.h"
#include <stdio.h>
#include <sys/socket.h>
int main()
{
struct event server_event, client_event;
int server_socket, client_socket;
printf("%s\n", event_get_version());
event_init();
server_socket = socket(AF_INET, SOCK_STREAM, 0);
printf("server_socket=%d\n", server_socket);
event_set(&server_event, server_socket, EV_READ, NULL, NULL);
if (event_add(&server_event, NULL))
perror("event_add(server_event)");
close(server_socket);
client_socket = socket(AF_INET, SOCK_STREAM, 0);
printf("client_socket=%d\n", client_socket);
event_set(&client_event, client_socket, EV_READ, NULL, NULL);
if (event_add(&client_event, NULL))
perror("event_add(client_event)");
}
And here's the output:
libevent-test-errno2$ ./test_errno2 # libevent-1.4.13 with epoll backend - fails
1.4.13-stable
server_socket=6
client_socket=6
event_add(client_event): No such file or directory
relevant strace:
epoll_create(32000) = 3
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 6
epoll_ctl(3, EPOLL_CTL_ADD, 6, {EPOLLIN, {u32=6, u64=6}}) = 0
close(6) = 0
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 6
epoll_ctl(3, EPOLL_CTL_MOD, 6, {EPOLLIN, {u32=6, u64=6}}) = -1 ENOENT
(No such file or directory)
libevent-test-errno2$ EVENT_NOEPOLL=1 ./test_errno2 # libevent-1.4.11
with poll backend - OK
1.4.11-stable
server_socket=5
client_socket=5
libevent-test-errno2$ ./test_errno2_2 # libevent-2.0.4-alpha with
epoll backend - OK
2.0.4-alpha
server_socket=8
client_socket=8
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.