From 354702b94e832d5c33941c1f51905cca6e17c6f0 Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Tue, 13 Jul 1999 06:21:14 +0000 Subject: [PATCH] ldap-int.h --- libraries/libldap/init.c | 2 ++ libraries/libldap/os-ip.c | 44 ++++++++++++++++++++++++--------------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/libraries/libldap/init.c b/libraries/libldap/init.c index ec2ca20929..4e45c7554a 100644 --- a/libraries/libldap/init.c +++ b/libraries/libldap/init.c @@ -290,6 +290,8 @@ void ldap_int_initialize( void ) } ldap_int_utils_init(); + if ( ldap_int_tblsize == 0 ) + ldap_int_ip_init(); gopts.ldo_version = LDAP_VERSION2; gopts.ldo_deref = LDAP_DEREF_NEVER; diff --git a/libraries/libldap/os-ip.c b/libraries/libldap/os-ip.c index b17e71a58f..75c3a7277c 100644 --- a/libraries/libldap/os-ip.c +++ b/libraries/libldap/os-ip.c @@ -33,6 +33,9 @@ #include "ldap-int.h" +int ldap_int_tblsize = 0; + + int ldap_connect_to_host( Sockbuf *sb, const char *host, unsigned long address, int port, int async ) @@ -301,34 +304,41 @@ ldap_free_select_info( void *sip ) } -int -do_ldap_select( LDAP *ld, struct timeval *timeout ) +void +ldap_int_ip_init( void ) { - struct selectinfo *sip; - static int tblsize; - - Debug( LDAP_DEBUG_TRACE, "do_ldap_select\n", 0, 0, 0 ); - - if ( tblsize == 0 ) { + int tblsize; #if defined( HAVE_SYSCONF ) - tblsize = sysconf( _SC_OPEN_MAX ); + tblsize = sysconf( _SC_OPEN_MAX ); #elif defined( HAVE_GETDTABLESIZE ) - tblsize = getdtablesize(); + tblsize = getdtablesize(); #else - tblsize = FD_SETSIZE; + tblsize = FD_SETSIZE; #endif /* !USE_SYSCONF */ #ifdef FD_SETSIZE - if( tblsize > FD_SETSIZE ) { - tblsize = FD_SETSIZE; - } + if( tblsize > FD_SETSIZE ) + tblsize = FD_SETSIZE; #endif /* FD_SETSIZE*/ - } + ldap_int_tblsize = tblsize; +} + + +int +do_ldap_select( LDAP *ld, struct timeval *timeout ) +{ + struct selectinfo *sip; + + Debug( LDAP_DEBUG_TRACE, "do_ldap_select\n", 0, 0, 0 ); + + if ( ldap_int_tblsize == 0 ) + ldap_int_ip_init(); sip = (struct selectinfo *)ld->ld_selectinfo; sip->si_use_readfds = sip->si_readfds; sip->si_use_writefds = sip->si_writefds; - return( select( tblsize, &sip->si_use_readfds, &sip->si_use_writefds, - NULL, timeout )); + return( select( ldap_int_tblsize, + &sip->si_use_readfds, &sip->si_use_writefds, + NULL, timeout )); } -- 2.39.5