epoll_wait() never return even though not specifying a timeout of -1

Solution Verified - Updated -

Issue

  • The actual implementation of epoll_wait() system call does not conform to the manual page.
  • According to the manual, epoll_wait() is expected to wait for a maximum time of "timeout" milliseconds. Since the "timeout" is type of (int), one can specify a value of between 1 and INT_MAX for it (both -1 and 0 have special meanings).
  • But if one actually specify a timeout of between EP_MAX_MSTIMEO and INT_MAX, epoll_wait() never return (where EP_MAX_MSTIMEO is 2,147,482) because of the following implementation:

    [fs/eventpoll.c]
    1495 static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
    1496                    int maxevents, long timeout)
      :
    1508         jtimeout = (timeout<  0 || timeout>= EP_MAX_MSTIMEO) ?
    1509                 MAX_SCHEDULE_TIMEOUT : (timeout * HZ + 999) / 1000;
      :
    1539                         jtimeout = schedule_timeout(jtimeout);
    

Environment

  • Red Hat Enterprise Linux 5.6
  • 2.6.18-238.el5PAE

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content