X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=servers%2Fslurpd%2Fre.c;h=e0b38c65e31b184d81d07d05a376e7902ff0ebd4;hb=df5d69df8f20895172730d092503a5c2b2871aeb;hp=1f351a27535718a8afbe993da3fa1192e64c5d10;hpb=4039648a2e147bb6a78498111207c199dda9cb5e;p=openldap diff --git a/servers/slurpd/re.c b/servers/slurpd/re.c index 1f351a2753..e0b38c65e3 100644 --- a/servers/slurpd/re.c +++ b/servers/slurpd/re.c @@ -1,6 +1,6 @@ /* $OpenLDAP$ */ /* - * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved. + * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file */ /* @@ -27,6 +27,7 @@ #include +#include #include #include #include @@ -81,9 +82,14 @@ Re_free( return 0; } if ( re->re_refcnt > 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG ( SLURPD, WARNING, "Re_free: " + "Warning: freeing re (dn: %s) with nonzero refcnt\n", re->re_dn, 0, 0 ); +#else Debug( LDAP_DEBUG_ANY, "Warning: freeing re (dn: %s) with nonzero refcnt\n", re->re_dn, 0, 0 ); +#endif } ldap_pvt_thread_mutex_destroy( &re->re_mutex ); @@ -135,11 +141,19 @@ Re_parse( int nreplicas; if ( re == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG ( SLURPD, ERR, "Re_parse: Error: re is NULL\n", 0, 0, 0 ); +#else Debug( LDAP_DEBUG_ANY, "Re_parse: error: re is NULL\n", 0, 0, 0 ); +#endif return -1; } if ( replbuf == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG ( SLURPD, ERR, "Re_parse: Error: replbuf is NULL\n", 0, 0, 0 ); +#else Debug( LDAP_DEBUG_ANY, "Re_parse: error: replbuf is NULL\n", 0, 0, 0 ); +#endif return -1; } @@ -164,9 +178,14 @@ Re_parse( } buflen = strlen( buf ); if ( ldif_parse_line( buf, &type, &value, &len ) < 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG ( SLURPD, ERR, + "Re_parse: Error: malformed replog file\n", 0, 0, 0 ); +#else Debug( LDAP_DEBUG_ANY, "Error: Re_parse: malformed replog file\n", 0, 0, 0 ); +#endif return -1; } switch ( gettype( type )) { @@ -193,24 +212,32 @@ Re_parse( break; default: if ( !( state == GOT_ALL )) { +#ifdef NEW_LOGGING + LDAP_LOG ( SLURPD, ERR, + "Re_parse: Error: bad type <%s>\n", type, 0, 0 ); +#else Debug( LDAP_DEBUG_ANY, "Error: Re_parse: bad type <%s>\n", type, 0, 0 ); +#endif free( type ); - if ( value != NULL ) - free( value ); + free( value ); return -1; } } free( type ); - if ( value != NULL ) - free( value ); + free( value ); } if ( state != GOT_ALL ) { +#ifdef NEW_LOGGING + LDAP_LOG ( SLURPD, ERR, + "Re_parse: Error: malformed replog file\n", 0, 0, 0 ); +#else Debug( LDAP_DEBUG_ANY, "Error: Re_parse: malformed replog file\n", 0, 0, 0 ); +#endif return -1; } @@ -226,9 +253,14 @@ Re_parse( value = NULL; } else { if ( ldif_parse_line( buf, &type, &value, &len ) < 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG ( SLURPD, ERR, + "Re_parse: Error: malformed replog line \"%s\"\n", buf, 0, 0 ); +#else Debug( LDAP_DEBUG_ANY, "Error: malformed replog line \"%s\"\n", buf, 0, 0 ); +#endif return -1; } } @@ -333,23 +365,26 @@ get_repl_hosts( free( type ); if ( !repl_ok ) { warn_unknown_replica( value, port ); - if ( value != NULL ) - free( value ); + free( value ); continue; } rh = (Rh *) ch_realloc((char *) rh, ( nreplicas + 2 ) * sizeof( Rh )); if ( rh == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG ( SLURPD, ERR, + "get_repl_hosts: Out of memory\n", 0, 0, 0 ); +#else Debug( LDAP_DEBUG_ANY, "Out of memory in get_repl_hosts\n", 0, 0, 0 ); +#endif return NULL; } rh[ nreplicas ].rh_hostname = strdup( value ); rh[ nreplicas ].rh_port = port; nreplicas++; - if ( value != NULL ) - free( value ); + free( value ); } if ( nreplicas == 0 ) { @@ -457,7 +492,11 @@ Re_dump( Mi *mi; if ( re == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG ( SLURPD, ERR, "Re_dump: re is NULL\n", 0, 0, 0 ); +#else Debug( LDAP_DEBUG_TRACE, "Re_dump: re is NULL\n", 0, 0, 0 ); +#endif return; } fprintf( fp, "Re_dump: ******\n" ); @@ -523,8 +562,13 @@ Re_write( int rc = 0; if ( re == NULL || fp == NULL ) { +#ifdef NEW_LOGGING + LDAP_LOG ( SLURPD, ERR, + "Re_write: Internal error: NULL argument\n", 0, 0, 0 ); +#else Debug( LDAP_DEBUG_ANY, "Internal error: Re_write: NULL argument\n", 0, 0, 0 ); +#endif return -1; } @@ -612,8 +656,13 @@ Re_write( } bad: if ( rc != 0 ) { +#ifdef NEW_LOGGING + LDAP_LOG ( SLURPD, ERR, + "Re_write: Error while writing: %s\n", sys_errlist[ errno ], 0, 0 ); +#else Debug( LDAP_DEBUG_ANY, "Error while writing: %s\n", sys_errlist[ errno ], 0, 0 ); +#endif } return rc; } @@ -750,9 +799,15 @@ warn_unknown_replica( } } if ( !found ) { +#ifdef NEW_LOGGING + LDAP_LOG ( SLURPD, WARNING, "warn_unknown_replica: " + "Warning: unknown replica %s:%d found in replication log\n", + host, port, 0 ); +#else Debug( LDAP_DEBUG_ANY, "Warning: unknown replica %s:%d found in replication log\n", host, port, 0 ); +#endif nur++; ur = (Rh *) ch_realloc( (char *) ur, ( nur * sizeof( Rh ))); ur[ nur - 1 ].rh_hostname = strdup( host );