cURL
Haxx ad
libcurl

Shopping cart software, Online file storage, Online photo storage, Hosted shopping cart, Contact management software, Email marketing software, Project management software, Issue tracking software, Online notepad, Web publishing software

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-library Archives

Re: select() returned with errno = 9 (EBADF), msg = Bad file descriptor

From: Jamie Lokier <jamie_at_shareable.org>
Date: Fri, 13 Nov 2009 02:33:21 +0000

Daniel Stenberg wrote:
> On Wed, 11 Nov 2009, Stefan Krause wrote:
>
> > 15045:277 curlSelect(): errno = 9, msg = Bad file descriptor
> > curlSelect(): errno = 9, msg = Bad file descriptor [repeated
> > 300 times]
>
> >OS was QNX 6.3.2. libCurl version=7.19.3.
> >The select error occured during an endurance test.
> >The timestamps left are of format seconds:milliseconds.
> >
> >select() returned -1 and the errno was 9 / EBADF / "Bad file descriptor"
>
> >What might be the reason for that error ?
>
> Well, call me crazy but I would guess that one possible reason is that
> select() considered one or more of the file descriptors in use to be bad.

Often this happens because some other part of the application closes a
file descriptor that it shouldn't.

It can happen if the other part of the application closes it's own
descriptor _twice_ when finished with it, perhaps due to not tearing
down data structures. The first time is correct. By the second time,
the descriptor has been reused by something else, the the second close
affects the other user, resulting in EBADF errors.

For debugging, you (a) trace all system calls to a file, using
something like the strace tool, and (b) modify the call to select() so
that it iterates over each file descriptor in all the fd sets before
the select() call, and inside the loop calls fcntl(fd, F_GETFL) to
check if the descriptor is valid. Then you can look at the system
call trace to find the last place where close() was called on that
descriptor. If there isn't one, it's definitely a bug in setting up
select parameters. If there is one, it might point to buggy code
calling close().

-- Jamie
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-11-13

These mail archives are generated by hypermail.

donate! Page updated November 16, 2009.
web site info

File upload with ASP.NET