Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

eventfd: socket does not allow changing to non-blocking



Hi!

NetBSD recently got an eventfd interface which is supposedly
compatible to Linux's.

net/zeromq uses eventfds and has lots of assertions in its test code,
and I looked at one of them. It basically makes a new eventfd and then
tries to set it to non-blocking mode using fcntl. This fails with
'operation not supported'.

I see that eventfd() is documented as having a flag for non-blocking
mode when creating the eventfd, but since zeromq is doing this using
fnctl(), I guess this is supposed to work that way as well.

Is this a bug in NetBSD's eventfd implementation or is zeromq wrong
here?
 Thomas
#include <sys/eventfd.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>

int main() {
    int cflags = 0x400000;
    int s_ = eventfd (0, cflags);

    int flags = fcntl (s_, F_GETFL, 0);
    printf("eventfd flags are %d, O_NONBLOCK is %d\n", flags, O_NONBLOCK);
    if (flags == -1)
        flags = 0;
    int rc = fcntl (s_, F_SETFL, flags | O_NONBLOCK);
    printf("fcntl returned %d: %s\n", rc, strerror(errno));
}
eventfd flags are 2, O_NONBLOCK is 4
fcntl returned -1: Operation not supported



Home | Main Index | Thread Index | Old Index