#12 [PATCH] fixed select() call in CEPoll::wait() for sys sockets when OS is not Linux

epoll (2)

I've been making some developments under OSX and iOS and was trying to use udt's epoll with both UDT and SYS sockets. After noticing that the epoll_wait wasn't firing events for SYS sockets I delved into the code and found out that when the OS was not Linux the code invokes select() by default for SYS sockets, which was my case.

Then I found out that the problem was that select() was being invoked with the first argument equal to 0, which should be (max_fd + 1), where max_fd is the maximum file descriptor of all descriptors being monitored. You can confirm this in the select man page.

So, I made a small fix to determine the max_fd and invoke select() with (max_fd + 1) as the first argument.

In the future I may try to add kqueue support for SYS sockets when on OSX / iOS.

Thanks for the awesome project!

1 Attachments


  • Mikhail T.

    Mikhail T. - 2014-02-11

    Shouldn't any errors encountered by select() be propagated to the caller too?

  • André Pacheco Neves

    Hi Mikhail,

    Since error handling isn't being done in neither native epoll() or select(), I didn't include it.

    My guess is that the reason for this was to not interrupt normal UDT CEPoll::wait() behavior unless the error was UDT related.

    You could add error handling, but to be consistent with the existing code you would have to do something like

    (...) // epoll() or select() call
    else // error
    throw CUDTException(X, Y); // new exceptions

    which would obviously interrupt the CEPoll::wait() call.

    One could however create a specific error handling which would print something to stderr based on errno value. That would be better than nothing I guess.



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks