]> git.sur5r.net Git - openldap/commitdiff
Add missing arguments to Debug() calls... and adapt nt_debug for general
authorKurt Zeilenga <kurt@openldap.org>
Mon, 21 Jun 1999 22:36:13 +0000 (22:36 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Mon, 21 Jun 1999 22:36:13 +0000 (22:36 +0000)
use.

servers/slapd/daemon.c
servers/slapd/nt_debug.c

index 3c8bfe43864f6f36bc5febb1560bd13a52a7fc76..f8a45f357b72c9a56b2bf9108b92dee8c67bc9bd 100644 (file)
@@ -329,6 +329,7 @@ slapd_daemon_task(
        while ( !slapd_shutdown ) {
                ber_socket_t i;
                int ns;
+               int at;
                ber_socket_t nfds;
 #define SLAPD_EBADF_LIMIT 10
                int ebadf = 0;
@@ -391,21 +392,31 @@ slapd_daemon_task(
                ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
 
                ldap_pvt_thread_mutex_lock( &active_threads_mutex );
+               at = active_threads;
+               ldap_pvt_thread_mutex_unlock( &active_threads_mutex );
+
 #if defined( HAVE_YIELDING_SELECT ) || defined( NO_THREADS )
                tvp = NULL;
 #else
-               tvp = active_threads ? &zero : NULL;
+               tvp = at ? &zero : NULL;
 #endif
 
                Debug( LDAP_DEBUG_CONNS,
                        "daemon: select: tcps=%d active_threads=%d tvp=%s\n",
-                   tcps, active_threads,
+                   tcps, at,
                        tvp == NULL ? "NULL" : "zero" );
           
 
-               ldap_pvt_thread_mutex_unlock( &active_threads_mutex );
 
-               switch(ns = select( nfds, &readfds, &writefds, 0, tvp )) {
+               switch(ns = select( nfds, &readfds,
+#ifdef HAVE_WINSOCK
+                       /* don't pass empty fd_set */
+                       ( writefds.fd_count > 0 ? &writefds : NULL ),
+#else
+                       &writefds,
+#endif
+                       NULL, tvp ))
+               {
                case -1: {      /* failure - try again */
 #ifdef HAVE_WINSOCK
                                int err = WSAGetLastError();
@@ -561,10 +572,12 @@ slapd_daemon_task(
                Debug( LDAP_DEBUG_CONNS, "daemon: activity on:", 0, 0, 0 );
 #ifdef HAVE_WINSOCK
                for ( i = 0; i < readfds.fd_count; i++ ) {
-                       Debug( LDAP_DEBUG_CONNS, " %d%s", readfds.fd_array[i], "r" );
+                       Debug( LDAP_DEBUG_CONNS, " %d%s",
+                               readfds.fd_array[i], "r", 0 );
                }
                for ( i = 0; i < writefds.fd_count; i++ ) {
-                       Debug( LDAP_DEBUG_CONNS, " %d%s", writefds.fd_array[i], "w" );
+                       Debug( LDAP_DEBUG_CONNS, " %d%s",
+                               writefds.fd_array[i], "w", 0 );
                }
 #else
                for ( i = 0; i < nfds; i++ ) {
@@ -784,7 +797,8 @@ void hit_socket()
 
        if ( connect( s, (struct sockaddr *)&bind_addr, sizeof( struct sockaddr_in )) == SOCKET_ERROR ) {
                Debug( LDAP_DEBUG_ANY,
-                       "hit_socket: error on connect: %d\n", WSAGetLastError(), 0 );
+                       "hit_socket: error on connect: %d\n",
+                       WSAGetLastError(), 0, 0 );
                /* we can probably expect some error to occur here, mostly WSAEWOULDBLOCK */
        }
 
@@ -815,7 +829,7 @@ slap_set_shutdown( int sig )
                ldap_pvt_thread_kill( listener_tid, LDAP_SIGUSR1 );
        }
 #else
-       Debug( LDAP_DEBUG_TRACE, "Shutdown %d ordered", sig, 0 );
+       Debug( LDAP_DEBUG_TRACE, "Shutdown %d ordered", sig, 0, 0 );
        /* trying to "hit" the socket seems to always get a */
        /* EWOULDBLOCK error, so just close the listen socket to */
        /* break out of the select since we're shutting down anyway */
index b4a650fc5500b25ecf1c5f4cc124b55948f96da5..fc9027cbf56c3668917dbe797a4abe4c0239ff2f 100644 (file)
 
 static FILE *log_file;
 
-void (Debug)( int level, const char *fmt, ... )
+int lutil_debug_file( FILE *file )
+{
+       log_file = log_file;
+
+       return 0;
+}
+
+void (lutil_debug)( int level, int debug, const char *fmt, ... )
 {
        char buffer[4096];
        va_list vl;
 
-       if ( !(level & ldap_debug ) )
+       if ( !(level & debug ) )
                return;
 
+#ifdef HAVE_WINSOCK
        if( log_file == NULL )
     {
                log_file = fopen( LDAP_RUNDIR LDAP_DIRSEP "slapd.log", "w" );
@@ -29,13 +37,18 @@ void (Debug)( int level, const char *fmt, ... )
                if ( log_file == NULL )
                        return;
        }
+#endif
 
        va_start( vl, fmt );
-       vsprintf( buffer, fmt, vl );
-       fprintf( log_file, "%s", buffer );
 
-    printf ("%s", buffer);
+       vsnprintf( buffer, sizeof(buffer), fmt, vl );
+       buffer[sizeof(buffer)-1] = '\0';
+
+       if( log_file != NULL ) {
+               fputs( buffer, log_file );
+               fflush( log_file );
+       }
 
-       fflush( log_file );
+    puts(buffer );
        va_end( vl );
 }