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

Re: "epollCreate: unsupported operation" on buildd hosts



On Wed, Mar  9, 2011 at 15:23:09 +0530, Joachim Breitner wrote:

> Hi,
> 
> Am Mittwoch, den 09.03.2011, 10:22 +0100 schrieb Julien Cristau:
> > epoll_create1 was added in 2.6.27, afaict.  If that's what haskell is
> > using, then it's not unexpected to have it fail on 2.6.26.
> 
> good shot, thanks!
> 
> From ./libraries/base/System/Event/EPoll.hsc: (this line does not start with ">")
> 
> epollCreate :: IO EPollFd
> epollCreate = do
>   fd <- throwErrnoIfMinus1 "epollCreate" $
> #if defined(HAVE_EPOLL_CREATE1)
>         c_epoll_create1 (#const EPOLL_CLOEXEC)
> #else
>         c_epoll_create 256 -- argument is ignored
>   setCloseOnExec fd
> #endif
>   let !epollFd' = EPollFd fd
>   return epollFd'
> 
> #if defined(HAVE_EPOLL_CREATE1)
> foreign import ccall unsafe "sys/epoll.h epoll_create1"
>     c_epoll_create1 :: CInt -> IO CInt
> #else
> foreign import ccall unsafe "sys/epoll.h epoll_create"
>     c_epoll_create :: CInt -> IO CInt
> #endif
> 
> 
> and in libraries/base/configure.ac:
> AC_CHECK_FUNCS([epoll_create1 epoll_ctl eventfd kevent kevent64 kqueue poll])
> 
> 
> So what is the conclusion? Do we need to disable the use of
> epoll_create1 completely? Or is it actually so that the libc should map
> uses of epoll_create1 to epoll_create? Or do we need to introduce
> run-time checks as to whether epoll_create1 is available?
> 
Something like this, I think...

#if defined(HAVE_EPOLL_CREATE1)
fd = epoll_create1(EPOLL_CLOEXEC);
if (fd < 0 && errno == ENOSYS)
#endif
{
  fd = epoll_create(256);
  if (fd < 0 || fcntl(fd, F_SETFD, fcntl(fd, F_GETFD, 0) | FD_CLOEXEC) < 0)
    return -1;
}
return fd;

Cheers,
Julien


Reply to: