]> git.sur5r.net Git - openldap/commitdiff
Mark areas needed poll(2) support with HAVE_POLL.
authorKurt Zeilenga <kurt@openldap.org>
Fri, 9 Jul 2004 17:50:22 +0000 (17:50 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Fri, 9 Jul 2004 17:50:22 +0000 (17:50 +0000)
libraries/libldap/init.c
libraries/libldap/ldap-int.h
libraries/libldap/os-ip.c
libraries/libldap/os-local.c
libraries/libldap/request.c

index f20223294a11b7a50b1bb4e045cb70be9fc74b20..03e55c85cfe7da828821dbd1ec72ae10488e3cd2 100644 (file)
@@ -534,8 +534,10 @@ void ldap_int_initialize( struct ldapoptions *gopts, int *dbglvl )
        || defined(HAVE_TLS) || defined(HAVE_CYRUS_SASL)
        ldap_int_hostname = ldap_pvt_get_fqdn( ldap_int_hostname );
 #endif
-       if ( ldap_int_tblsize == 0 )
-               ldap_int_ip_init();
+
+#ifndef HAVE_POLL
+       if ( ldap_int_tblsize == 0 ) ldap_int_ip_init();
+#endif
 
        ldap_int_initialize_global_options(gopts, NULL);
 
index 7d0c6fdb191d14c775f16ee92cf023441e068908..73b0aa999d6a965c20ba17c2d0276a4a2888e991 100644 (file)
@@ -448,7 +448,11 @@ LDAP_F (int) ldap_int_open_connection( LDAP *ld,
 /*
  * in os-ip.c
  */
+#ifndef HAVE_POLL
 LDAP_V (int) ldap_int_tblsize;
+LDAP_F (void) ldap_int_ip_init( void );
+#endif
+
 LDAP_F (int) ldap_int_timeval_dup( struct timeval **dest,
        const struct timeval *tm );
 LDAP_F (int) ldap_connect_to_host( LDAP *ld, Sockbuf *sb,
@@ -461,7 +465,6 @@ LDAP_F (char *) ldap_host_connected_to( Sockbuf *sb,
        const char *host );
 #endif
 
-LDAP_F (void) ldap_int_ip_init( void );
 LDAP_F (int) ldap_int_select( LDAP *ld, struct timeval *timeout );
 LDAP_F (void *) ldap_new_select_info( void );
 LDAP_F (void) ldap_free_select_info( void *sip );
index 1b3b515810f9df221672fb3856bd40b59220d969..7399fe5bd2e5b3e6b7fa615641fd854c07d7f5d4 100644 (file)
@@ -39,8 +39,6 @@
 
 #include "ldap-int.h"
 
-int ldap_int_tblsize = 0;
-
 #if defined( HAVE_GETADDRINFO ) && defined( HAVE_INET_NTOP )
 #  ifdef LDAP_PF_INET6
 int ldap_int_inet4or6 = AF_UNSPEC;
@@ -212,10 +210,12 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s,
 {
        int rc;
        struct timeval  tv, *opt_tv=NULL;
+#ifndef HAVE_POLL
        fd_set          wfds, *z=NULL;
 #ifdef HAVE_WINSOCK
        fd_set          efds;
 #endif
+#endif
 
 #ifdef LDAP_CONNECTIONLESS
        /* We could do a connect() but that would interfere with
@@ -258,6 +258,9 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s,
        if ( async ) return ( -2 );
 #endif
 
+#ifdef HAVE_POLL
+       assert(0);
+#else
        FD_ZERO(&wfds);
        FD_SET(s, &wfds );
 
@@ -305,6 +308,8 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s,
                        return ( -1 );
                return ( 0 );
        }
+#endif
+
        osip_debug(ld, "ldap_connect_timeout: timed out\n",0,0,0);
        ldap_pvt_set_errno( ETIMEDOUT );
        return ( -1 );
@@ -607,14 +612,18 @@ ldap_host_connected_to( Sockbuf *sb, const char *host )
 #endif
 
 
-/* for UNIX */
+#ifdef HAVE_POLL
+/* for UNIX poll(2) */
+       /* ??? */
+#else
+/* for UNIX select(2) */
 struct selectinfo {
        fd_set  si_readfds;
        fd_set  si_writefds;
        fd_set  si_use_readfds;
        fd_set  si_use_writefds;
 };
-
+#endif
 
 void
 ldap_mark_select_write( LDAP *ld, Sockbuf *sb )
@@ -708,10 +717,14 @@ ldap_free_select_info( void *sip )
 }
 
 
+#ifndef HAVE_POLL
+int ldap_int_tblsize = 0;
+
 void
 ldap_int_ip_init( void )
 {
        int tblsize;
+
 #if defined( HAVE_SYSCONF )
        tblsize = sysconf( _SC_OPEN_MAX );
 #elif defined( HAVE_GETDTABLESIZE )
@@ -721,11 +734,12 @@ ldap_int_ip_init( void )
 #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;
 }
+#endif
 
 
 int
@@ -739,14 +753,20 @@ ldap_int_select( LDAP *ld, struct timeval *timeout )
        Debug( LDAP_DEBUG_TRACE, "ldap_int_select\n", 0, 0, 0 );
 #endif
 
-       if ( ldap_int_tblsize == 0 )
-               ldap_int_ip_init();
+#ifndef HAVE_POLL
+       if ( ldap_int_tblsize == 0 ) ldap_int_ip_init();
+#endif
 
        sip = (struct selectinfo *)ld->ld_selectinfo;
        sip->si_use_readfds = sip->si_readfds;
        sip->si_use_writefds = sip->si_writefds;
        
+#ifdef HAVE_POLL
+       assert(0);
+       return -1;
+#else
        return( select( ldap_int_tblsize,
-                       &sip->si_use_readfds, &sip->si_use_writefds,
-                       NULL, timeout ));
+               &sip->si_use_readfds, &sip->si_use_writefds,
+               NULL, timeout ));
+#endif
 }
index 6cbc8a10c2d11cc3f592589f38d369699111b0a5..43d55f513deff91ec98df910d9e430dee743c67a 100644 (file)
@@ -51,8 +51,6 @@
 #include "ldap-int.h"
 #include "ldap_defaults.h"
 
-/* int ldap_int_tblsize = 0; */
-
 #ifdef LDAP_DEBUG
 
 #define oslocal_debug(ld,fmt,arg1,arg2,arg3) \
@@ -169,7 +167,6 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s, struct sockaddr_un *sa, int async)
 {
        int rc;
        struct timeval  tv, *opt_tv=NULL;
-       fd_set          wfds, *z=NULL;
 
        if ( (opt_tv = ld->ld_options.ldo_tm_net) != NULL ) {
                tv.tv_usec = opt_tv->tv_usec;
@@ -177,17 +174,15 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s, struct sockaddr_un *sa, int async)
        }
 
        oslocal_debug(ld, "ldap_connect_timeout: fd: %d tm: %ld async: %d\n",
-                       s, opt_tv ? tv.tv_sec : -1L, async);
+               s, opt_tv ? tv.tv_sec : -1L, async);
 
-       if ( ldap_pvt_ndelay_on(ld, s) == -1 )
-               return ( -1 );
+       if ( ldap_pvt_ndelay_on(ld, s) == -1 ) return -1;
 
        if ( connect(s, (struct sockaddr *) sa, sizeof(struct sockaddr_un))
                != AC_SOCKET_ERROR )
        {
-               if ( ldap_pvt_ndelay_off(ld, s) == -1 ) {
-                       return ( -1 );
-               }
+               if ( ldap_pvt_ndelay_off(ld, s) == -1 ) return -1;
+
 #ifdef DO_SENDMSG
        /* Send a dummy message with access rights. Remote side will
         * obtain our uid/gid by fstat'ing this descriptor.
@@ -211,38 +206,42 @@ sendcred:
                        }
                }
 #endif
-               return ( 0 );
+               return 0;
        }
 
-       if ( errno != EINPROGRESS && errno != EWOULDBLOCK ) {
-               return ( -1 );
-       }
+       if ( errno != EINPROGRESS && errno != EWOULDBLOCK ) return -1;
        
 #ifdef notyet
-       if ( async ) return ( -2 );
+       if ( async ) return -2;
 #endif
 
-       FD_ZERO(&wfds);
-       FD_SET(s, &wfds );
+#ifdef HAVE_POLL
+               assert(0);
+#else
+       {
+               fd_set          wfds, *z=NULL;
+               FD_ZERO(&wfds);
+               FD_SET(s, &wfds );
 
-       do { 
-               rc = select(ldap_int_tblsize, z, &wfds, z, opt_tv ? &tv : NULL);
-       } while( rc == AC_SOCKET_ERROR && errno == EINTR &&
-               LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_RESTART ));
+               do { 
+                       rc = select( ldap_int_tblsize, z, &wfds, z, opt_tv ? &tv : NULL );
+               } while( rc == AC_SOCKET_ERROR && errno == EINTR &&
+                       LDAP_BOOL_GET(&ld->ld_options, LDAP_BOOL_RESTART ));
 
-       if( rc == AC_SOCKET_ERROR ) return rc;
+               if( rc == AC_SOCKET_ERROR ) return rc;
 
-       if ( FD_ISSET(s, &wfds) ) {
-               if ( ldap_pvt_is_socket_ready(ld, s) == -1 )
-                       return ( -1 );
-               if ( ldap_pvt_ndelay_off(ld, s) == -1 )
-                       return ( -1 );
+               if ( FD_ISSET(s, &wfds) ) {
+                       if ( ldap_pvt_is_socket_ready(ld, s) == -1 ) return -1;
+                       if ( ldap_pvt_ndelay_off(ld, s) == -1 ) return -1;
 #ifdef DO_SENDMSG
-               goto sendcred;
+                       goto sendcred;
 #else
-               return ( 0 );
+                       return ( 0 );
 #endif
+               }
        }
+#endif
+
        oslocal_debug(ld, "ldap_connect_timeout: timed out\n",0,0,0);
        ldap_pvt_set_errno( ETIMEDOUT );
        return ( -1 );
index 237a6eefff542c4d79512c66ddc4732be9ab48b0..1187e28fae3c2c5ab68d9797ec35c5251044fa9b 100644 (file)
@@ -158,8 +158,7 @@ ldap_send_initial_request(
 int
 ldap_int_flush_request(
        LDAP *ld,
-       LDAPRequest *lr
-)
+       LDAPRequest *lr )
 {
        LDAPConn *lc = lr->lr_conn;