RTEMS | Socket close fails with kqueue/kevent usage. (#5201)
Fabrizio Pirovano (@pirovano.fabrizio)
gitlab at rtems.org
Mon Feb 3 14:36:37 UTC 2025
Fabrizio Pirovano created an issue: https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5201
## Summary
Using rtems-6 and freebsd-12 (30.01.2025), we are facing the following issue: close socket fail with error "Device or resource busy" because the reference count is not zero.
## Steps to reproduce
The following code highlights the error.
static void test(void)
{
int kq, sock;
struct kevent evset;
kq = kqueue();
if (kq < 0)
printf("kqueue() failed: %s\n", strerror(errno));
else
{
sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (sock >= 0)
{
EV_SET(&evset, sock, EVFILT_READ, EV_ADD, 0, 0, NULL);
if (kevent(kq, &evset, 1, NULL, 0, NULL) < 0)
printf("kevent() EV_ADD failed: %s\n", strerror(errno));
EV_SET(&evset, sock, EVFILT_READ, EV_DELETE, 0, 0, NULL);
if (kevent(kq, &evset, 1, NULL, 0, NULL) < 0)
printf("kevent() EV_DELETE failed: %s\n", strerror(errno));
if (close(sock) < 0)
printf("close() socket failed: %s\n", strerror(errno));
}
}
}
The same behavior can be observed in testsuite/selectpollkqueue01 if we add the close sockets and their checks after the sockets have been used with kevent().
The attached patch modifies testsuite/selectpollkqueue01/test_main.c[selectpollkqueue01.patch]. We haven't add intentionally the assert() after close socket to highlight the errors.
(/uploads/9729838c50ad8254a4f6fbfaafce0976/selectpollkqueue01.patch)
### Pre-set options
--
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5201
You're receiving this email because of your account on gitlab.rtems.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20250203/347193e9/attachment.htm>
More information about the bugs
mailing list