Changes to support FreeBSD LinuxThreads port. Namely don't rely

on errno not getting changed by Debug().  Likely a problem elsewhere.
Tests run okay, excepting concurrency has "no such object" problems.
This commit is contained in:
Kurt Zeilenga 1999-04-08 03:57:25 +00:00
parent 21f49f3b27
commit 6743aebf3d
4 changed files with 51 additions and 43 deletions

View 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

View 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;
}

View 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 );
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;
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 */

View 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 );