[Date Prev][Date Next] [Chronological] [Thread] [Top]

non-null tvp on select() (ITS#2603)

Full_Name: Jeff Bouis
Version: 2.1.21
OS: Solaris 9
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (

Openldap 2.1.21, daemon.c, line 1325 is

    tvp = at ? &tv : NULL;

Apparently this changed in version 2.1.20 (per ITS#2374), because prior to that,
the equivalent code was

#if defined( HAVE_YIELDING_SELECT ) || defined( NO_THREADS )
    tvp = NULL
    tvp = at ? &tv : NULL;

In the earlier code, OS's that allow select() to yield (such as Solaris) always
set tvp to NULL, regardless of if any threads were active.  But in the new code,
if there are no active threads and everything is idle, then tvp points to a
struct timeval which has its values set to 0 by default.

So, in the old code (NULL tvp), select() would simply block and wait for
something to happen.  But in the new code (tvp with 0 time), select() runs, sees
nothing has changed, so goes back into the "while ( !slapd_shutdown )" loop and
starts over.  Just polling and polling and polling....

In less than 30 seconds of running, slapd with full logging output over
40,000(!) log entries of
    daemon: select timeout - yielding
    daemon: select: listen=6 active_threads=1 tvp=idle

Note this behavior is also mentioned in the followup message of ITS#2580.