[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] Bug in win32_dispatch?
- To: <libevent-users@xxxxxxxxxxxxx>
- Subject: [Libevent-users] Bug in win32_dispatch?
- From: "Alexey Simak" <alexeysimak@xxxxxxxxx>
- Date: Wed, 13 May 2015 17:32:51 +0300
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Wed, 13 May 2015 10:33:01 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:from:to:subject:date:mime-version:content-type :content-transfer-encoding:importance; bh=uI2OPcapLHV0l2C3kwiFAnyhFTTQJIVOThkGKPh+n4Q=; b=wfzICS3dC+ZLSd2uqgYhARm0xC9YiEvh3leNT2kcVMtvgQXipvHrPq3WcV1EsoGTjG fo/rq9Jg+8FxqLzpF0vAOV6n1+El1FDRgZamEGxPBmRrBc3hff20WYQv+I0e3Xl7vLhA fCUabfsOMrarIUdcJGcJTuNaovJnjYZKvpk2wZiQF5+vW/pxK1brFpZGgRpKrI48FVvi KO23i8Zf7qYf8bYXfePLzEFn0XTGF94dT/KJMysY/DGbczGNV2qUuLIVv9O9haO7sLfM DRgXA9Qut9tLnN25rd1aID5Vkay/E2KhI1LKtA/NhyAaYLFPW2yTVlo5UikiyFPhf7aX 7jQw==
- Importance: Normal
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
Hi,
We are using libevent in the next scenario:
1) Create nonblocking socket.
2) Call "connect()" on it.
3) Create an event for socket and wait in event_base_dispatch() for socket
events.
4) Check for EV_TIMEOUT, EV_READ or EV_WRITE passed to callback.
There is a problem on win32:
When we are connecting to a destination that is not listening on the socket,
we receive
EV_WRITE event, which is not correct from my point of view.
The problem is in win32_dispatch from win32select.c:
res = select(fd_count,
(struct fd_set*)win32op->readset_out,
(struct fd_set*)win32op->writeset_out,
(struct fd_set*)win32op->exset_out, tv);
EVBASE_ACQUIRE_LOCK(base, th_base_lock);
event_debug(("%s: select returned %d", __func__, res));
if (res <= 0) {
return res;
}
if (win32op->readset_out->fd_count) {
i = rand() % win32op->readset_out->fd_count;
for (j=0; j<win32op->readset_out->fd_count; ++j) {
if (++i >= win32op->readset_out->fd_count)
i = 0;
s = win32op->readset_out->fd_array[i];
evmap_io_active(base, s, EV_READ);
}
}
if (win32op->exset_out->fd_count) {
i = rand() % win32op->exset_out->fd_count;
for (j=0; j<win32op->exset_out->fd_count; ++j) {
if (++i >= win32op->exset_out->fd_count)
i = 0;
s = win32op->exset_out->fd_array[i];
evmap_io_active(base, s, EV_WRITE);
}
}
if (win32op->writeset_out->fd_count) {
SOCKET s;
i = rand() % win32op->writeset_out->fd_count;
for (j=0; j<win32op->writeset_out->fd_count; ++j) {
if (++i >= win32op->writeset_out->fd_count)
i = 0;
s = win32op->writeset_out->fd_array[i];
evmap_io_active(base, s, EV_WRITE);
}
}
return (0);
As you see, EV_WRITE is returned if there is some socket error.
Is this behaviour a bug or "as designed"?
Thanks,
Alexey Simak
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.