]> git.sur5r.net Git - openldap/blobdiff - servers/slurpd/fm.c
Listener commit broke test048, skip listener check on Hidden DBs
[openldap] / servers / slurpd / fm.c
index 3574539728b432a55a4849961badcfe35c64b956..23d08bfba0e62510f0c68213304b6d5034530c30 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2007 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -43,6 +43,7 @@
 
 #include "slurp.h"
 #include "globals.h"
+#include "lutil.h"
 
 
 /*
@@ -77,8 +78,8 @@ fm(
 #ifdef SIGHUP
     (void) SIGNAL( SIGHUP, slurp_set_shutdown );
 #endif
-#if defined(SIGBREAK) && defined(HAVE_NT_SERVICE_MANAGER)
-    (void) SIGNAL( SIGBREAK, do_nothing );
+#if defined(SIGBREAK)
+    (void) SIGNAL( SIGBREAK, slurp_set_shutdown );
 #endif
 
     if ( sglob->one_shot_mode ) {
@@ -106,26 +107,16 @@ fm(
     while ( !sglob->slurpd_shutdown ) {
        if ( file_nonempty( sglob->slapd_replogfile )) {
            /* New work found - copy to slurpd replog file */
-#ifdef NEW_LOGGING
-       LDAP_LOG ( SLURPD, ARGS, 
-                       "fm: new work in %s\n", sglob->slapd_replogfile, 0, 0 );
-#else
            Debug( LDAP_DEBUG_ARGS, "new work in %s\n",
                    sglob->slapd_replogfile, 0, 0 );
-#endif
            if (( rc = copy_replog( sglob->slapd_replogfile,
                    sglob->slurpd_replogfile )) == 0 )  {
                populate_queue( sglob->slurpd_replogfile );
            } else {
                if ( rc < 0 ) {
-#ifdef NEW_LOGGING
-               LDAP_LOG ( SLURPD, CRIT, 
-                               "fm: Fatal error while copying replication log\n" , 0, 0, 0);
-#else
                    Debug( LDAP_DEBUG_ANY,
                            "Fatal error while copying replication log\n",
                            0, 0, 0 );
-#endif
                    sglob->slurpd_shutdown = 1;
                }
            }
@@ -147,15 +138,9 @@ fm(
            FILE *fp, *lfp;
            if (( rc = acquire_lock( sglob->slurpd_replogfile, &fp,
                    &lfp )) < 0 ) {
-#ifdef NEW_LOGGING
-               LDAP_LOG ( SLURPD, ERR, 
-                       "fm: Error: cannot acquire lock on \"%s\" for trimming\n",
-                       sglob->slurpd_replogfile, 0, 0 );
-#else
                Debug( LDAP_DEBUG_ANY,
                        "Error: cannot acquire lock on \"%s\" for trimming\n",
                        sglob->slurpd_replogfile, 0, 0 );
-#endif
            } else {
                sglob->rq->rq_write( sglob->rq, fp );
                (void) relinquish_lock( sglob->slurpd_replogfile, fp, lfp );
@@ -168,11 +153,7 @@ fm(
        (sglob->replicas[ i ])->ri_wake( sglob->replicas[ i ]);
     }
     sglob->rq->rq_unlock( sglob->rq );                 /* unlock queue */
-#ifdef NEW_LOGGING
-       LDAP_LOG ( SLURPD, RESULTS, "fm: exiting\n", 0, 0, 0 );
-#else
     Debug( LDAP_DEBUG_ARGS, "fm: exiting\n", 0, 0, 0 );
-#endif
     return NULL;
 }
 
@@ -185,8 +166,15 @@ fm(
 RETSIGTYPE
 slurp_set_shutdown(int sig)
 {
+#if HAVE_NT_SERVICE_MANAGER && SIGBREAK
+    if (is_NT_Service && sig == SIGBREAK) {
+       /* empty */;
+    } else
+#endif
+    {
     sglob->slurpd_shutdown = 1;                                /* set flag */
     tcp_write( sglob->wake_sds[1], "0", 1);            /* wake up file mgr */
+    }
 
     (void) SIGNAL_REINSTALL( sig, slurp_set_shutdown );        /* reinstall handlers */
 }
@@ -219,15 +207,9 @@ populate_queue(
     char       *p;
 
     if ( acquire_lock( f, &fp, &lfp ) < 0 ) {
-#ifdef NEW_LOGGING
-       LDAP_LOG ( SLURPD, ERR, 
-               "populate_queue: error: can't lock file \"%s\": %s\n", 
-               f, sys_errlist[ errno ], 0 );
-#else
        Debug( LDAP_DEBUG_ANY,
                "error: can't lock file \"%s\": %s\n",
                f, sys_errlist[ errno ], 0 );
-#endif
        return;
     }
 
@@ -236,15 +218,9 @@ populate_queue(
      * the queue.
      */
     if ( fseek( fp, sglob->srpos, 0 ) < 0 ) {
-#ifdef NEW_LOGGING
-       LDAP_LOG ( SLURPD, ERR, 
-               "populate_queue: error: can't seek to offset %ld in file \"%s\"\n", 
-               sglob->srpos, f, 0 );
-#else
        Debug( LDAP_DEBUG_ANY,
                "error: can't seek to offset %ld in file \"%s\"\n",
                sglob->srpos, f, 0 );
-#endif
     } else {
     while (( p = get_record( fp )) != NULL ) {
        if ( sglob->rq->rq_add( sglob->rq, p ) < 0 ) {
@@ -253,15 +229,9 @@ populate_queue(
            if (( t = strchr( p, '\n' )) != NULL ) {
                *t = '\0';
            }
-#ifdef NEW_LOGGING
-               LDAP_LOG ( SLURPD, ERR, 
-                       "populate_queue: error: malformed replog entry "
-                       "(begins with \"%s\")\n", p, 0, 0 );
-#else
            Debug( LDAP_DEBUG_ANY,
                    "error: malformed replog entry (begins with \"%s\")\n",
                    p, 0, 0 );
-#endif
        }
        free( p );
        ldap_pvt_thread_yield();