Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#472 closed defect (fixed)

Problem with setting up FD_SETSIZE

Reported by: bennylp Owned by: bennylp
Priority: normal Milestone: release-0.9.0
Component: pjlib Version: trunk
Keywords: Cc:
Backport to 1.x milestone: Backported:


PJLIB assumes that FD_SETSIZE is always set-able in every OS, so <pj/config.h> always override this macro and set set it to PJ_IOQUEUE_MAX_HANDLES.

While this assumption is correct for Windows (or Visual C rather), this is wrong for GLIBC. On GLIBC, FD_SETSIZE specifies the maximum number of file descriptors in fd_set, and the value is constant (see (1)). If we set this in PJLIB, we will get warning about macro being redefined when including GLIBC headers.

So PJLIB should detect if FD_SETSIZE is indeed changeable, and only set it if it is.


Change History (4)

comment:1 Changed 16 years ago by bennylp

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in r1783:

  • Added PJ_FD_SETSIZE_SETABLE macro to indicate whether FD_SETSIZE is set-able. This macro should be set to false when GLIBC is used, but alas! LIBC headers have not yet included when <pj/config.h> is compiled, hence GLIBC_ is always false. As a workaround, we set PJ_FD_SETSIZE_SETABLE macro to false when GNUC is set instead.
  • Only override FD_SETSIZE when PJ_FD_SETSIZE_SETABLE is true.
  • In sock_select.c, check again that PJ_IOQUEUE_MAX_HANDLES value does not exceed FD_SETSIZE.

comment:2 Changed 16 years ago by bennylp


  • Fixed compilation errors on Symbian and others caused by removal of FD_SETSIZE from declaration.

comment:3 Changed 16 years ago by bennylp

In r1788:

  • Fixed problem when building on Mingw. Now PJ_FD_SETSIZE_SETABLE is only set when <winsock.h> is present.
  • Default PJ_IOQUEUE_MAX_HANDLES is now set to 64.
  • The "#if (PJ_IOQUEUE_MAX_HANDLES < FD_SET_SIZE)}}}" checking was moved from sock_select.c to ioqueue_select.c.

comment:4 Changed 16 years ago by bennylp

In r1802:

  • Compilation error when building on Win32, with PJ_IOQUEUE_MAX_HANDLES declared to large value, due to missing PJ_HAS_WINSOCK_H. This is because on Win32 PJ_HAS_WINSOCK_H is disabled and PJ_HAS_WINSOCK2_H is enabled instead. Thanks Truong Thanh Quang.
Note: See TracTickets for help on using tickets.