/*
* 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,
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 );
#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;
{
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
if ( async ) return ( -2 );
#endif
+#ifdef HAVE_POLL
+ assert(0);
+#else
FD_ZERO(&wfds);
FD_SET(s, &wfds );
return ( -1 );
return ( 0 );
}
+#endif
+
osip_debug(ld, "ldap_connect_timeout: timed out\n",0,0,0);
ldap_pvt_set_errno( ETIMEDOUT );
return ( -1 );
#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 )
}
+#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 )
#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
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
}
#include "ldap-int.h"
#include "ldap_defaults.h"
-/* int ldap_int_tblsize = 0; */
-
#ifdef LDAP_DEBUG
#define oslocal_debug(ld,fmt,arg1,arg2,arg3) \
{
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;
}
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.
}
}
#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 );