]> git.sur5r.net Git - openldap/commitdiff
Changes to support FreeBSD LinuxThreads port. Namely don't rely
authorKurt Zeilenga <kurt@openldap.org>
Thu, 8 Apr 1999 03:57:25 +0000 (03:57 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Thu, 8 Apr 1999 03:57:25 +0000 (03:57 +0000)
on errno not getting changed by Debug().  Likely a problem elsewhere.
Tests run okay, excepting concurrency has "no such object" problems.

build/openldap.m4
servers/slapd/connection.c
servers/slapd/daemon.c
servers/slapd/result.c

index ce9f5f46117aa82b018e62c8254c36098f31b5fb..b7067667f52e00dfcc3185a901a86fd4a51dd695 100644 (file)
@@ -478,7 +478,7 @@ AC_DEFUN([OL_PTHREAD_TRY_LINK], [# Pthread try link: $1 ($2)
                # try $1
                AC_CACHE_CHECK([for pthread link with $1], [$2], [
                        # save the flags
-                       save_LIBS="$LIBS"
+                       ol_LIBS="$LIBS"
                        LIBS="$1 $LIBS"
 
                        AC_TRY_LINK([
@@ -502,7 +502,7 @@ AC_DEFUN([OL_PTHREAD_TRY_LINK], [# Pthread try link: $1 ($2)
 ], [$2=yes], [$2=no])
 
                # restore the LIBS
-               LIBS="$save_LIBS"
+               LIBS="$ol_LIBS"
                ])
 
                if test $$2 = yes ; then
index 0ca6909871b144e27f23b1a5e0fa7b2a2bfe9b3d..2e7a7604d3ccfb29535b71047a5fb16e3d44fafa 100644 (file)
@@ -592,8 +592,8 @@ int connection_read(int s)
 
        if( rc < 0 ) {
                Debug( LDAP_DEBUG_TRACE,
-                       "connection_read(%d): input error id=%ld, closing.\n",
-                       s, c->c_connid, 0 );
+                       "connection_read(%d): input error=%d id=%ld, closing.\n",
+                       s, rc, c->c_connid );
 
                connection_closing( c );
                connection_close( c );
@@ -624,21 +624,23 @@ connection_input(
        if ( (tag = ber_get_next( &conn->c_sb, &len, conn->c_currentber ))
            != LDAP_TAG_MESSAGE )
        {
+               int err = errno;
+
                Debug( LDAP_DEBUG_TRACE,
                        "ber_get_next on fd %d failed errno %d (%s)\n",
-                       lber_pvt_sb_get_desc(&conn->c_sb), errno,
-                       errno > -1 && errno < sys_nerr ?  sys_errlist[errno] : "unknown" );
+                       lber_pvt_sb_get_desc(&conn->c_sb), err,
+                       err > -1 && err < sys_nerr ?  sys_errlist[err] : "unknown" );
                Debug( LDAP_DEBUG_TRACE,
                        "\t*** got %ld of %lu so far\n",
                        (long)(conn->c_currentber->ber_rwptr - conn->c_currentber->ber_buf),
                        conn->c_currentber->ber_len, 0 );
 
-               if ( errno != EWOULDBLOCK && errno != EAGAIN ) {
+               if ( err != EWOULDBLOCK && err != EAGAIN ) {
                        /* log, close and send error */
                        ber_free( conn->c_currentber, 1 );
                        conn->c_currentber = NULL;
 
-                       return -1;
+                       return -2;
                }
                return 1;
        }
index 01d909b16c8f724b35e929a6ca264564a330bc25..f1c44505c5d98f9d4fe5b28bff0bf4dfb9b1f598 100644 (file)
@@ -178,9 +178,10 @@ set_socket( struct sockaddr_in *addr )
                int     tmp;
 
                if ( (tcps = socket( AF_INET, SOCK_STREAM, 0 )) == -1 ) {
+                       int err = errno;
                        Debug( LDAP_DEBUG_ANY,
-                               "daemon: socket() failed errno %d (%s)\n", errno,
-                       errno > -1 && errno < sys_nerr ? sys_errlist[errno] :
+                               "daemon: socket() failed errno %d (%s)\n", err,
+                       err > -1 && err < sys_nerr ? sys_errlist[err] :
                        "unknown", 0 );
                        exit( 1 );
                }
@@ -198,20 +199,20 @@ set_socket( struct sockaddr_in *addr )
                if ( setsockopt( tcps, SOL_SOCKET, SO_REUSEADDR,
                        (char *) &tmp, sizeof(tmp) ) == -1 )
                {
+                       int err = errno;
                        Debug( LDAP_DEBUG_ANY,
                               "slapd(%d): setsockopt() failed errno %d (%s)\n",
-                       tcps, errno,
-                               errno > -1 && errno < sys_nerr
-                                       ? sys_errlist[errno] : "unknown" );
-
-                       errno = 0;
+                       tcps, err,
+                               err > -1 && err < sys_nerr
+                                       ? sys_errlist[err] : "unknown" );
                }
 
                if ( bind( tcps, (struct sockaddr *) addr, sizeof(*addr) ) == -1 ) {
+                       int err = errno;
                        Debug( LDAP_DEBUG_ANY, "daemon: bind(%d) failed errno %d (%s)\n",
-                       tcps, errno,
-                               errno > -1 && errno < sys_nerr
-                                       ? sys_errlist[errno] : "unknown" );
+                       tcps, err,
+                               err > -1 && err < sys_nerr
+                                       ? sys_errlist[err] : "unknown" );
                        exit( 1 );
                }
        }
@@ -236,11 +237,12 @@ slapd_daemon_task(
 
        if( !inetd ) {
                if ( listen( tcps, 5 ) == -1 ) {
+                       int err = errno;
                        Debug( LDAP_DEBUG_ANY,
                                "daemon: listen(%d, 5) failed errno %d (%s)\n",
-                           tcps, errno,
-                               errno > -1 && errno < sys_nerr
-                                       ? sys_errlist[errno] : "unknown" );
+                           tcps, err,
+                               err > -1 && err < sys_nerr
+                                       ? sys_errlist[err] : "unknown" );
                        exit( 1 );
                }
 
@@ -321,18 +323,19 @@ slapd_daemon_task(
                ldap_pvt_thread_mutex_unlock( &active_threads_mutex );
 
                switch(ns = select( nfds, &readfds, &writefds, 0, tvp )) {
-               case -1:        /* failure - try again */
-                       if( errno != EINTR ) {
-                               Debug( LDAP_DEBUG_CONNS,
-                                       "daemon: select failed (%d): %s\n",
-                                       errno,
-                                       errno >= 0 && errno < sys_nerr
-                                               ? sys_errlist[errno] : "unknown",
-                                       0 );
-
-                               slapd_shutdown = -1;
+               case -1: {      /* failure - try again */
+                               int err = errno;
+                               if( err != EINTR ) {
+                                       Debug( LDAP_DEBUG_CONNS,
+                                               "daemon: select failed (%d): %s\n",
+                                               err,
+                                               err >= 0 && err < sys_nerr
+                                                       ? sys_errlist[err] : "unknown",
+                                               0 );
+
+                                       slapd_shutdown = -1;
+                               }
                        }
-                       errno = 0;
                        continue;
 
                case 0:         /* timeout - let threads run */
@@ -355,10 +358,11 @@ slapd_daemon_task(
                        if ( (s = accept( tcps,
                                (struct sockaddr *) &from, &len )) == -1 )
                        {
+                               int err = errno;
                                Debug( LDAP_DEBUG_ANY,
-                                   "daemon: accept(%d) failed errno %d (%s)\n", errno,
-                                   tcps, errno >= 0 && errno < sys_nerr ?
-                                   sys_errlist[errno] : "unknown");
+                                   "daemon: accept(%d) failed errno %d (%s)\n", err,
+                                   tcps, err >= 0 && err < sys_nerr ?
+                                   sys_errlist[err] : "unknown");
                                continue;
                        }
 
@@ -551,13 +555,13 @@ slapd_daemon_task(
 
        if( slapd_shutdown > 0 ) {
                Debug( LDAP_DEBUG_TRACE,
-                       "daemon: shutdown requested and initiated.\n",
-                       0, 0, 0 );
+                       "daemon: shutdown requested (%d) and initiated.\n",
+                       (int) slapd_shutdown, 0, 0 );
 
        } else if ( slapd_shutdown < 0 ) {
                Debug( LDAP_DEBUG_TRACE,
-                       "daemon: abnormal condition, shutdown initiated.\n",
-                       0, 0, 0 );
+                       "daemon: abnormal condition (%d), shutdown initiated.\n",
+                       (int) slapd_shutdown, 0, 0 );
        } else {
                Debug( LDAP_DEBUG_TRACE,
                        "daemon: no active streams, shutdown initiated.\n",
@@ -605,7 +609,7 @@ int slapd_daemon( int inetd, int tcps )
 void
 slap_set_shutdown( int sig )
 {
-       slapd_shutdown = 1;
+       slapd_shutdown = sig;
        ldap_pvt_thread_kill( listener_tid, LDAP_SIGUSR1 );
 
        /* reinstall self */
index 17f454ac83ee47a92238716e8221486b1e02551f..9a12891f717827a33be01260c93ebe09515274da 100644 (file)
@@ -97,6 +97,7 @@ send_ldap_result2(
        bytes = ber->ber_ptr - ber->ber_buf;
 
        while ( ber_flush( &conn->c_sb, ber, 1 ) != 0 ) {
+               int err = errno;
                /*
                 * we got an error.  if it's ewouldblock, we need to
                 * wait on the socket being writable.  otherwise, figure
@@ -104,10 +105,10 @@ send_ldap_result2(
                 */
 
                Debug( LDAP_DEBUG_CONNS, "ber_flush failed errno %d msg (%s)\n",
-                   errno, errno > -1 && errno < sys_nerr ? sys_errlist[errno]
+                   err, err > -1 && err < sys_nerr ? sys_errlist[err]
                    : "unknown", 0 );
 
-               if ( errno != EWOULDBLOCK && errno != EAGAIN ) {
+               if ( err != EWOULDBLOCK && err != EAGAIN ) {
                        connection_closing( conn );
 
                        ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
@@ -325,6 +326,7 @@ send_search_entry(
 
        /* write the pdu */
        while ( ber_flush( &conn->c_sb, ber, 1 ) != 0 ) {
+               int err = errno;
                /*
                 * we got an error.  if it's ewouldblock, we need to
                 * wait on the socket being writable.  otherwise, figure
@@ -332,10 +334,10 @@ send_search_entry(
                 */
 
                Debug( LDAP_DEBUG_CONNS, "ber_flush failed errno %d msg (%s)\n",
-                   errno, errno > -1 && errno < sys_nerr ? sys_errlist[errno]
+                   err, err > -1 && err < sys_nerr ? sys_errlist[err]
                    : "unknown", 0 );
 
-               if ( errno != EWOULDBLOCK && errno != EAGAIN ) {
+               if ( err != EWOULDBLOCK && err != EAGAIN ) {
                        connection_closing( conn );
 
                        ldap_pvt_thread_mutex_unlock( &conn->c_mutex );