Ticket #472 (closed defect: fixed)

Opened 9 years ago

Last modified 9 years ago

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:

Description

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.

(1) http://www.gnu.org/software/libc/manual/html_node/Waiting-for-I_002fO.html#Waiting-for-I_002fO

Change History

comment:1 Changed 9 years ago by bennylp

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

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 9 years ago by bennylp

r1785:

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

comment:3 Changed 9 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 9 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.