From: Hallvard Furuseth Date: Sun, 10 Jun 2007 20:39:53 +0000 (+0000) Subject: Import ber_socklen_t (ITS#4629) from HEAD X-Git-Tag: OPENLDAP_REL_ENG_2_3_36~18 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=414e52fa5e25eb4c807f201d1037e72f368bb90d;p=openldap Import ber_socklen_t (ITS#4629) from HEAD --- diff --git a/configure.in b/configure.in index 816294ceeb..ede3d8e67b 100644 --- a/configure.in +++ b/configure.in @@ -2378,14 +2378,43 @@ AC_CHECK_TYPE(size_t, unsigned) AC_CHECK_TYPES([long long]) AC_CHECK_TYPES([ptrdiff_t]) -AC_CHECK_TYPE([socklen_t],, - [AC_DEFINE_UNQUOTED([socklen_t], [int], - [Define to `int' if does not define.])], - [$ac_includes_default + +AC_CHECK_TYPE([socklen_t],,, [$ac_includes_default +#ifdef HAVE_SYS_SOCKET_H +#include +#endif]) + +dnl socklen_t-like type in accept(), default socklen_t or int: +dnl - The OS might define socklen_t without using it. POSIX moved from +dnl int to size_t to socklen_t, hoping to stay at a 32-bit type, and +dnl HP-UX now has selectors for what to use. +dnl - On Solaris 2.8 the prototype has void *len, but the default is OK. +AC_MSG_CHECKING([the type of arg 3 to accept()]) +AC_CACHE_VAL(ol_cv_type_ber_socklen_t, [ + set socklen_t int unsigned "unsigned long" long size_t + test "$ac_cv_type_socklen_t" = yes || shift + ol_cv_type_ber_socklen_t=$1 guessing="guessing " + for lentype in "$@" ; do for addrtype in "struct sockaddr" void ; do + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_includes_default #ifdef HAVE_SYS_SOCKET_H #include #endif - ]) +extern int accept(int s, $addrtype *ap, $lentype *lp); +], [ +accept(0, (struct sockaddr *) 0, ($lentype *) 0); +])], [ol_cv_type_ber_socklen_t=$lentype guessing= ; break 2]) + done ; done]) +AC_MSG_RESULT([$guessing$ol_cv_type_ber_socklen_t *]) +AC_DEFINE_UNQUOTED(ber_socklen_t, $ol_cv_type_ber_socklen_t, + [Define to the type of arg 3 for `accept'.]) + +dnl Modules should use ber_socklen_t, not socklen_t. Define socklen_t +dnl for the time being anyway, for backwards compatibility. +if test "$ac_cv_type_socklen_t" != yes; then + AC_DEFINE_UNQUOTED([socklen_t], [$ol_cv_type_ber_socklen_t], + [Define like ber_socklen_t if does not define.]) +fi + AC_TYPE_SIGNAL diff --git a/libraries/libldap/os-ip.c b/libraries/libldap/os-ip.c index cfd3b20190..51e57c619e 100644 --- a/libraries/libldap/os-ip.c +++ b/libraries/libldap/os-ip.c @@ -174,7 +174,7 @@ ldap_pvt_is_socket_ready(LDAP *ld, int s) #if defined( notyet ) /* && defined( SO_ERROR ) */ { int so_errno; - socklen_t dummy = sizeof(so_errno); + ber_socklen_t dummy = sizeof(so_errno); if ( getsockopt( s, SOL_SOCKET, SO_ERROR, &so_errno, &dummy ) == AC_SOCKET_ERROR ) { @@ -196,7 +196,7 @@ ldap_pvt_is_socket_ready(LDAP *ld, int s) struct sockaddr_in sin; #endif char ch; - socklen_t dummy = sizeof(sin); + ber_socklen_t dummy = sizeof(sin); if ( getpeername( s, (struct sockaddr *) &sin, &dummy ) == AC_SOCKET_ERROR ) { @@ -216,7 +216,7 @@ ldap_pvt_is_socket_ready(LDAP *ld, int s) static int ldap_pvt_connect(LDAP *ld, ber_socket_t s, - struct sockaddr *sin, socklen_t addrlen, + struct sockaddr *sin, ber_socklen_t addrlen, int async) { int rc, err; @@ -326,7 +326,7 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s, /* This means the connection failed */ if ( FD_ISSET(s, &efds) ) { int so_errno; - int dummy = sizeof(so_errno); + ber_socklen_t dummy = sizeof(so_errno); if ( getsockopt( s, SOL_SOCKET, SO_ERROR, (char *) &so_errno, &dummy ) == AC_SOCKET_ERROR || !so_errno ) { @@ -574,7 +574,7 @@ ldap_connect_to_host(LDAP *ld, Sockbuf *sb, char * ldap_host_connected_to( Sockbuf *sb, const char *host ) { - socklen_t len; + ber_socklen_t len; #ifdef LDAP_PF_INET6 struct sockaddr_storage sabuf; #else diff --git a/libraries/libldap/os-local.c b/libraries/libldap/os-local.c index 247ea8006a..49620af0f4 100644 --- a/libraries/libldap/os-local.c +++ b/libraries/libldap/os-local.c @@ -120,7 +120,7 @@ ldap_pvt_is_socket_ready(LDAP *ld, int s) #if defined( notyet ) /* && defined( SO_ERROR ) */ { int so_errno; - socklen_t dummy = sizeof(so_errno); + ber_socklen_t dummy = sizeof(so_errno); if ( getsockopt( s, SOL_SOCKET, SO_ERROR, &so_errno, &dummy ) == AC_SOCKET_ERROR ) { @@ -138,7 +138,7 @@ ldap_pvt_is_socket_ready(LDAP *ld, int s) /* error slippery */ struct sockaddr_un sa; char ch; - socklen_t dummy = sizeof(sa); + ber_socklen_t dummy = sizeof(sa); if ( getpeername( s, (struct sockaddr *) &sa, &dummy ) == AC_SOCKET_ERROR ) { diff --git a/libraries/liblutil/getpeereid.c b/libraries/liblutil/getpeereid.c index f7010897ac..e856bf7054 100644 --- a/libraries/liblutil/getpeereid.c +++ b/libraries/liblutil/getpeereid.c @@ -50,7 +50,7 @@ int getpeereid( int s, uid_t *euid, gid_t *egid ) #ifdef LDAP_PF_LOCAL #if defined( SO_PEERCRED ) struct ucred peercred; - socklen_t peercredlen = sizeof peercred; + ber_socklen_t peercredlen = sizeof peercred; if(( getsockopt( s, SOL_SOCKET, SO_PEERCRED, (void *)&peercred, &peercredlen ) == 0 ) @@ -63,7 +63,7 @@ int getpeereid( int s, uid_t *euid, gid_t *egid ) #elif defined( LOCAL_PEERCRED ) struct xucred peercred; - socklen_t peercredlen = sizeof peercred; + ber_socklen_t peercredlen = sizeof peercred; if(( getsockopt( s, LOCAL_PEERCRED, 1, (void *)&peercred, &peercredlen ) == 0 ) @@ -139,7 +139,7 @@ int getpeereid( int s, uid_t *euid, gid_t *egid ) } #elif defined(SOCKCREDSIZE) struct msghdr msg; - socklen_t crmsgsize; + ber_socklen_t crmsgsize; void *crmsg; struct cmsghdr *cmp; struct sockcred *sc; diff --git a/libraries/liblutil/sockpair.c b/libraries/liblutil/sockpair.c index c2e6220035..308a758224 100644 --- a/libraries/liblutil/sockpair.c +++ b/libraries/liblutil/sockpair.c @@ -35,7 +35,8 @@ int lutil_pair( ber_socket_t sds[2] ) return pipe( sds ); #else struct sockaddr_in si; - int rc, len = sizeof(si); + int rc; + ber_socklen_t len = sizeof(si); ber_socket_t sd; sd = socket( AF_INET, SOCK_DGRAM, 0 ); diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index a5c6d6cb69..09693e05c9 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -1582,7 +1582,7 @@ slap_listener( Sockaddr from; ber_socket_t s; - socklen_t len = sizeof(from); + ber_socklen_t len = sizeof(from); long id; slap_ssf_t ssf = 0; struct berval authid = BER_BVNULL;