X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslurpd%2Fst.c;h=5b31dfb8d5a00f0c1ddda806050ac67c875a3786;hb=d84ffb62a6c7528ef711547194307af629e0d082;hp=e2a00299b6ea444204a39ce7557b840f4ab5b6e4;hpb=6939c531700652491f4be4688c6a1f35a1ab8a18;p=openldap
diff --git a/servers/slurpd/st.c b/servers/slurpd/st.c
index e2a00299b6..5b31dfb8d5 100644
--- a/servers/slurpd/st.c
+++ b/servers/slurpd/st.c
@@ -1,10 +1,18 @@
/* $OpenLDAP$ */
-/*
- * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software .
+ *
+ * Copyright 1998-2005 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * .
*/
-/*
- * Copyright (c) 1996 Regents of the University of Michigan.
+/* Portions Copyright (c) 1996 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
@@ -14,6 +22,10 @@
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
*/
+/* ACKNOWLEDGEMENTS:
+ * This work was originally developed by the University of Michigan
+ * (as part of U-MICH LDAP).
+ */
/*
@@ -31,6 +43,7 @@
#include "slurp.h"
#include "globals.h"
+#include "lutil.h"
/*
* Add information about replica host specified by Ri to list
@@ -97,15 +110,9 @@ St_write (
if (( rc = acquire_lock( sglob->slurpd_status_file, &(st->st_fp),
&(st->st_lfp))) < 0 ) {
if ( !st->st_err_logged ) {
-#ifdef NEW_LOGGING
- LDAP_LOG ( SLURPD, ERR, "St_write: "
- "Error: cannot open status file \"%s\":%s\n",
- sglob->slurpd_status_file, sys_errlist[ errno ], 0 );
-#else
Debug( LDAP_DEBUG_ANY,
"Error: cannot open status file \"%s\": %s\n",
sglob->slurpd_status_file, sys_errlist[ errno ], 0 );
-#endif
st->st_err_logged = 1;
ldap_pvt_thread_mutex_unlock( &(st->st_mutex ));
return -1;
@@ -183,26 +190,15 @@ St_read(
* File doesn't exist, so create it and return.
*/
if (( fp = fopen( sglob->slurpd_status_file, "w" )) == NULL ) {
-#ifdef NEW_LOGGING
- LDAP_LOG ( SLURPD, ERR, "St_write: "
- "Error: cannot create status file \"%s\"\n",
- sglob->slurpd_status_file, 0, 0 );
-#else
Debug( LDAP_DEBUG_ANY, "Error: cannot create status file \"%s\"\n",
sglob->slurpd_status_file, 0, 0 );
-#endif
ldap_pvt_thread_mutex_unlock( &(st->st_mutex ));
return -1;
}
(void) fclose( fp );
ldap_pvt_thread_mutex_unlock( &(st->st_mutex ));
-#ifdef NEW_LOGGING
- LDAP_LOG ( SLURPD, DETAIL1, "St_write: "
- "No status file found, defaulting values\n", 0, 0, 0 );
-#else
Debug( LDAP_DEBUG_ARGS, "No status file found, defaulting values\n",
0, 0, 0 );
-#endif
return 0;
}
if (( rc = acquire_lock( sglob->slurpd_status_file, &fp, &lfp)) < 0 ) {
@@ -235,11 +231,16 @@ St_read(
found = 0;
for ( i = 0; i < sglob->st->st_nreplicas; i++ ) {
+ int p;
if ( !strcmp( hostname, sglob->st->st_data[ i ]->hostname ) &&
- atoi( port ) == sglob->st->st_data[ i ]->port ) {
+ lutil_atoi( &p, port ) == 0 && p == sglob->st->st_data[ i ]->port )
+ {
found = 1;
- sglob->st->st_data[ i ]->last = atol( timestamp );
- sglob->st->st_data[ i ]->seq = atoi( seq );
+ if ( lutil_atol( &sglob->st->st_data[ i ]->last, timestamp ) != 0
+ || lutil_atoi( &sglob->st->st_data[ i ]->seq, seq ) != 0 )
+ {
+ found = 0;
+ }
break;
}
}
@@ -247,23 +248,12 @@ St_read(
char tbuf[ 255 ];
sprintf( tbuf, "%s:%s (timestamp %s.%s)", hostname, port,
timestamp, seq );
-#ifdef NEW_LOGGING
- LDAP_LOG ( SLURPD, DETAIL1, "St_write: "
- "Retrieved state information for %s\n", tbuf, 0, 0 );
-#else
Debug( LDAP_DEBUG_ARGS,
"Retrieved state information for %s\n", tbuf, 0, 0 );
-#endif
} else {
-#ifdef NEW_LOGGING
- LDAP_LOG ( SLURPD, WARNING, "St_write: "
- "Warning: saved state for %s:%s, not a known replica\n",
- hostname, port, 0 );
-#else
Debug( LDAP_DEBUG_ANY,
"Warning: saved state for %s:%s, not a known replica\n",
hostname, port, 0 );
-#endif
}
}
(void) relinquish_lock( sglob->slurpd_status_file, fp, lfp);