]> git.sur5r.net Git - openldap/blob - servers/slurpd/re.c
fix previous commit
[openldap] / servers / slurpd / re.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 /*
7  * Copyright (c) 1996 Regents of the University of Michigan.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms are permitted
11  * provided that this notice is preserved and that due credit is given
12  * to the University of Michigan at Ann Arbor. The name of the University
13  * may not be used to endorse or promote products derived from this
14  * software without specific prior written permission. This software
15  * is provided ``as is'' without express or implied warranty.
16  */
17
18 /* 
19  * re.c - routines which deal with Re (Replication entry) structures.
20  * An Re struct is an in-core representation of one replication to
21  * be performed, along with member functions which are called by other
22  * routines.  The Re struct is defined in slurp.h.
23  */
24
25
26 #include "portable.h"
27
28 #include <stdio.h>
29
30 #include <ac/stdlib.h>
31 #include <ac/errno.h>
32 #include <ac/socket.h>
33 #include <ac/string.h>
34 #include <ac/ctype.h>
35
36 #include "slurp.h"
37 #include "globals.h"
38
39 #include "../slapd/slap.h"
40
41 /* Forward references */
42 static Rh       *get_repl_hosts LDAP_P(( char *, int *, char ** ));
43 static int      gettype LDAP_P(( char * ));
44 static int      getchangetype LDAP_P(( char * ));
45 static int      Re_parse LDAP_P(( Re *re, char *replbuf ));
46 static void     Re_dump LDAP_P(( Re *re, FILE *fp ));
47 static void     warn_unknown_replica LDAP_P(( char *, int port ));
48
49 /* Globals, scoped within this file */
50 static int      nur = 0;        /* Number of unknown replicas */
51 static Rh       *ur = NULL;     /* array of unknown replica names */
52
53
54 /*
55  * Return the next Re in a linked list.
56  */
57 static Re *
58 Re_getnext(
59     Re  *re
60 )
61 {
62     return(( re == NULL ) ? NULL :  re->re_next );
63 }
64
65
66
67
68 /*
69  * Free an Re
70  * ??? Something should apparently return nonzero here, but I dont know what.
71  */
72 static int
73 Re_free(
74     Re  *re
75 )
76 {
77     Rh  *rh;
78     Mi  *mi;
79     int i;
80
81     if ( re == NULL ) {
82         return 0;
83     }
84     if ( re->re_refcnt > 0 ) {
85 #ifdef NEW_LOGGING
86         LDAP_LOG ( SLURPD, WARNING, "Re_free: "
87                 "Warning: freeing re (dn: %s) with nonzero refcnt\n", re->re_dn, 0, 0 );
88 #else
89         Debug( LDAP_DEBUG_ANY,
90                 "Warning: freeing re (dn: %s) with nonzero refcnt\n",
91                 re->re_dn, 0, 0 );
92 #endif
93     }
94
95     ldap_pvt_thread_mutex_destroy( &re->re_mutex );
96
97     if (( rh = re->re_replicas ) != NULL ) {
98         for ( i = 0; rh[ i ].rh_hostname != NULL; i++ ) {
99             free( rh[ i ].rh_hostname );
100         }
101         free( rh );
102     }
103     ch_free( re->re_dn );
104     if (( mi = re->re_mods ) != NULL ) {
105         for ( i = 0; mi[ i ].mi_type != NULL; i++ ) {
106             free( mi[ i ].mi_type );
107             ch_free( mi[ i ].mi_val );
108         }
109         free( mi );
110     }
111     free( re );
112     return 0;
113 }
114
115
116
117
118 /*
119  * Read a buffer of data from a replication log file and fill in
120  * an (already allocated) Re.
121  */
122
123 #define BEGIN           0
124 #define GOT_DN          1
125 #define GOT_TIME        2
126 #define GOT_CHANGETYPE  4
127 #define GOT_ALL         ( GOT_DN | GOT_TIME | GOT_CHANGETYPE )
128
129 static int
130 Re_parse(
131     Re          *re,
132     char        *replbuf
133 )
134 {
135     int                 state;
136     int                 nml;
137     char                *buf, *rp, *p;
138     size_t              buflen;
139     char                *type, *value;
140     ber_len_t   len;
141     int                 nreplicas;
142
143     if ( re == NULL ) {
144 #ifdef NEW_LOGGING
145         LDAP_LOG ( SLURPD, ERR, "Re_parse: Error: re is NULL\n", 0, 0, 0 );
146 #else
147         Debug( LDAP_DEBUG_ANY, "Re_parse: error: re is NULL\n", 0, 0, 0 );
148 #endif
149         return -1;
150     }
151     if ( replbuf == NULL ) {
152 #ifdef NEW_LOGGING
153         LDAP_LOG ( SLURPD, ERR, "Re_parse: Error: replbuf is NULL\n", 0, 0, 0 );
154 #else
155         Debug( LDAP_DEBUG_ANY, "Re_parse: error: replbuf is NULL\n", 0, 0, 0 );
156 #endif
157         return -1;
158     }
159
160     state = BEGIN;
161     nml = 0;    /* number of modification information entries */
162     rp = replbuf;
163
164     re->re_replicas = get_repl_hosts( replbuf, &nreplicas, &rp );
165     re->re_refcnt = sglob->num_replicas;
166
167     for (;;) {
168         if (( state == GOT_ALL ) || ( buf = ldif_getline( &rp )) == NULL ) {
169             break;
170         }
171         /*
172          * If we're processing a rejection log, then the first line
173          * of each replication record will begin with "ERROR" - just
174          * ignore it.
175          */
176         if ( strncmp( buf, ERROR_STR, strlen( ERROR_STR )) == 0 ) {
177             continue;
178         }
179         buflen = strlen( buf );
180         if ( ldif_parse_line( buf, &type, &value, &len ) < 0 ) {
181 #ifdef NEW_LOGGING
182                 LDAP_LOG ( SLURPD, ERR, 
183                         "Re_parse: Error: malformed replog file\n", 0, 0, 0 );
184 #else
185             Debug( LDAP_DEBUG_ANY,
186                     "Error: Re_parse: malformed replog file\n",
187                     0, 0, 0 );
188 #endif
189             return -1;
190         }
191         switch ( gettype( type )) {
192         case T_CHANGETYPE:
193             re->re_changetype = getchangetype( value );
194             state |= GOT_CHANGETYPE;
195             break;
196         case T_TIME:
197             if (( p = strchr( value, '.' )) != NULL ) {
198                 /* there was a sequence number */
199                 *p++ = '\0';
200             }
201             re->re_timestamp = atol( value );
202             if ( p != NULL && isdigit( (unsigned char) *p )) {
203                 re->re_seq = atoi( p );
204             }
205             state |= GOT_TIME;
206             break;
207         case T_DN:
208             re->re_dn = ch_malloc( len + 1 );
209                 AC_MEMCPY( re->re_dn, value, len );
210                 re->re_dn[ len ]='\0';
211             state |= GOT_DN;
212             break;
213         default:
214             if ( !( state == GOT_ALL )) {
215 #ifdef NEW_LOGGING
216                 LDAP_LOG ( SLURPD, ERR, 
217                         "Re_parse: Error: bad type <%s>\n", type, 0, 0 );
218 #else
219                 Debug( LDAP_DEBUG_ANY,
220                         "Error: Re_parse: bad type <%s>\n",
221                         type, 0, 0 );
222 #endif
223                 free( type );
224                 free( value );
225                 return -1;
226             }
227         }
228         free( type );
229         free( value );
230     }
231
232     if ( state != GOT_ALL ) {
233 #ifdef NEW_LOGGING
234         LDAP_LOG ( SLURPD, ERR, 
235                 "Re_parse: Error: malformed replog file\n", 0, 0, 0 );
236 #else
237         Debug( LDAP_DEBUG_ANY,
238                 "Error: Re_parse: malformed replog file\n",
239                 0, 0, 0 );
240 #endif
241         return -1;
242     }
243
244     for (;;) {
245         char *const dash = "-";
246
247         if (( buf = ldif_getline( &rp )) == NULL ) {
248             break;
249         }
250         buflen = strlen( buf );
251         if (( buflen == 1 ) && ( buf[ 0 ] == '-' )) {
252             type  = dash;
253             value = NULL;
254         } else {
255             if ( ldif_parse_line( buf, &type, &value, &len ) < 0 ) {
256 #ifdef NEW_LOGGING
257                 LDAP_LOG ( SLURPD, ERR, 
258                         "Re_parse: Error: malformed replog line \"%s\"\n", buf, 0, 0 );
259 #else
260                 Debug( LDAP_DEBUG_ANY,
261                         "Error: malformed replog line \"%s\"\n",
262                         buf, 0, 0 );
263 #endif
264                 return -1;
265             }
266         }
267         re->re_mods = ( Mi  *) ch_realloc( (char *) re->re_mods,
268             sizeof( Mi ) * ( nml + 2 ));
269         re->re_mods[ nml ].mi_type = strdup( type );
270         if ( value != NULL ) {
271             re->re_mods[ nml ].mi_val = ch_malloc( len + 1 );
272                 AC_MEMCPY( re->re_mods[ nml ].mi_val, value, len );
273                 re->re_mods[ nml ].mi_val[ len ] = '\0';
274             re->re_mods[ nml ].mi_len = len;
275         } else {
276             re->re_mods[ nml ].mi_val = NULL;
277             re->re_mods[ nml ].mi_len = 0;
278         }
279         re->re_mods[ nml + 1 ].mi_type = NULL;
280         re->re_mods[ nml + 1 ].mi_val = NULL;
281         nml++;
282
283         if ( type != dash )
284                 free( type );
285         if ( value != NULL )
286                 free( value );
287     }
288     return 0;
289 }
290
291
292
293 /*
294  * Extract the replication hosts from a repl buf.  Check to be sure that
295  * each replica host and port number are ones we know about (that is, they're
296  * in the slapd config file we read at startup).  Without that information
297  * from the config file, we won't have the appropriate credentials to
298  * make modifications.  If there are any unknown replica names, don't
299  * add them the the Re struct.  Instead, log a warning message.
300  */
301 static Rh *
302 get_repl_hosts(
303     char        *replbuf,
304     int         *r_nreplicas,
305     char        **r_rp
306 )
307 {
308     char                *type, *value, *line, *p;
309     Rh                  *rh = NULL;
310     int                 nreplicas;
311         ber_len_t       len;
312     int                 port;
313     int                 repl_ok;
314     int                 i;
315
316     if ( replbuf == NULL ) {
317         return( NULL );
318     }
319
320     nreplicas = 0;
321
322     /*
323      * Get the host names of the replicas
324      */
325     *r_nreplicas = 0;
326     *r_rp = replbuf;
327     for (;;) {
328         /* If this is a reject log, we need to skip over the ERROR: line */
329         if ( !strncmp( *r_rp, ERROR_STR, strlen( ERROR_STR ))) {
330             line = ldif_getline( r_rp );
331             if ( line == NULL ) {
332                 break;
333             }
334         }
335         if ( strncasecmp( *r_rp, "replica:", 7 )) {
336             break;
337         }
338         line = ldif_getline( r_rp );
339         if ( line == NULL ) {
340             break;
341         }
342         if ( ldif_parse_line( line, &type, &value, &len ) < 0 ) {
343             return( NULL );
344         }
345         port = 0;
346         if (( p = strchr( value, ':' )) != NULL ) {
347             *p = '\0';
348             p++;
349             if ( *p != '\0' ) {
350                 port = atoi( p );
351             }
352         }
353
354         /* Verify that we've heard of this replica before */
355         repl_ok = 0;
356         for ( i = 0; i < sglob->num_replicas; i++ ) {
357             if ( strcmp( sglob->replicas[ i ]->ri_hostname, value )) {
358                 continue;
359             }
360             if ( sglob->replicas[ i ]->ri_port == port ) {
361                 repl_ok = 1;
362                 break;
363             }
364         }
365         free( type );
366         if ( !repl_ok ) {
367             warn_unknown_replica( value, port );
368             free( value );
369             continue;
370         }
371
372         rh = (Rh *) ch_realloc((char *) rh, ( nreplicas + 2 ) * sizeof( Rh ));
373         if ( rh == NULL ) {
374 #ifdef NEW_LOGGING
375                 LDAP_LOG ( SLURPD, ERR, 
376                         "get_repl_hosts: Out of memory\n", 0, 0, 0 );
377 #else
378             Debug( LDAP_DEBUG_ANY, "Out of memory in get_repl_hosts\n",
379                     0, 0, 0 );
380 #endif
381             return NULL;
382         }
383         rh[ nreplicas ].rh_hostname = strdup( value );
384         rh[ nreplicas ].rh_port = port;
385         nreplicas++;
386
387         free( value );
388     }
389
390     if ( nreplicas == 0 ) {
391         return( NULL );
392     }
393
394     rh[ nreplicas ].rh_hostname = NULL;
395     *r_nreplicas = nreplicas;
396
397     return( rh );
398 }
399
400
401
402
403
404 /*
405  * Convert "type" to an int.
406  */
407 static int
408 gettype(
409     char        *type
410 )
411 {
412     if ( !strcmp( type, T_CHANGETYPESTR )) {
413         return( T_CHANGETYPE );
414     }
415     if ( !strcmp( type, T_TIMESTR )) {
416         return( T_TIME );
417     }
418     if ( !strcmp( type, T_DNSTR )) {
419         return( T_DN );
420     }
421     return( T_ERR );
422 }
423
424
425
426 /*
427  * Convert "changetype" to an int.
428  */
429 static int
430 getchangetype(
431     char        *changetype
432 )
433 {
434     if ( !strcmp( changetype, T_ADDCTSTR )) {
435         return( T_ADDCT );
436     }
437     if ( !strcmp( changetype, T_MODIFYCTSTR )) {
438         return( T_MODIFYCT );
439     }
440     if ( !strcmp( changetype, T_DELETECTSTR )) {
441         return( T_DELETECT );
442     }
443     if ( !strcmp( changetype, T_MODRDNCTSTR )) {
444         return( T_MODRDNCT );
445     }
446     return( T_ERR );
447 }
448
449
450
451
452 /*
453  * Find the first line which is not a "replica:" line in buf.
454  * Returns a pointer to the line.  Returns NULL if there are
455  * only "replica:" lines in buf.
456  */
457 static char *
458 skip_replica_lines(
459     char        *buf
460 )
461 {
462     char *p = buf;
463     for (;;) {
464         if ( strncasecmp( p, "replica:", 8 )) {
465             return( p );
466         }
467         while (( *p != '\0' )  && ( *p != '\n' )) {
468             p++;
469         }
470         if ( *p == '\0' ) {
471             return ( NULL );
472         } else {
473             p++;
474         }
475     }
476 }
477
478
479
480
481 /*
482  * For debugging purposes: dump the contents of a replication entry.
483  * to the given stream.
484  */
485 static void
486 Re_dump(
487     Re          *re,
488     FILE        *fp
489 )
490 {
491     int i;
492     Mi *mi;
493
494     if ( re == NULL ) {
495 #ifdef NEW_LOGGING
496         LDAP_LOG ( SLURPD, ERR, "Re_dump: re is NULL\n", 0, 0, 0 );
497 #else
498         Debug( LDAP_DEBUG_TRACE, "Re_dump: re is NULL\n", 0, 0, 0 );
499 #endif
500         return;
501     }
502     fprintf( fp, "Re_dump: ******\n" );
503     fprintf( fp, "re_refcnt: %d\n", re->re_refcnt );
504     fprintf( fp, "re_timestamp: %ld\n", (long) re->re_timestamp );
505     fprintf( fp, "re_seq: %d\n", re->re_seq );
506     for ( i = 0; re->re_replicas && re->re_replicas[ i ].rh_hostname != NULL;
507                 i++ ) {
508         fprintf( fp, "re_replicas[%d]: %s:%d\n", 
509                 i, re->re_replicas[ i ].rh_hostname,
510                 re->re_replicas[ i ].rh_port );
511     }
512     fprintf( fp, "re_dn: %s\n", re->re_dn );
513     switch ( re->re_changetype ) {
514     case T_ADDCT:
515         fprintf( fp, "re_changetype: add\n" );
516         break;
517     case T_MODIFYCT:
518         fprintf( fp, "re_changetype: modify\n" );
519         break;
520     case T_DELETECT:
521         fprintf( fp, "re_changetype: delete\n" );
522         break;
523     case T_MODRDNCT:
524         fprintf( fp, "re_changetype: modrdn\n" );
525         break;
526     default:
527         fprintf( fp, "re_changetype: (unknown, type = %d\n",
528                 re->re_changetype );
529     }
530     if ( re->re_mods == NULL ) {
531         fprintf( fp, "re_mods: (none)\n" );
532     } else {
533         mi = re->re_mods;
534         fprintf( fp, "re_mods:\n" );
535         for ( i = 0; mi[ i ].mi_type != NULL; i++ ) {
536             fprintf( fp, "  %s, \"%s\", (%d bytes)\n",
537                     mi[ i ].mi_type,
538                     mi[ i ].mi_val == NULL ?  "(null)" : mi[ i ].mi_val,
539                     mi[ i ].mi_len );
540         }
541     }
542     return;
543 }
544
545
546 /* 
547  * Given an Ri, an Re, and a file pointer, write a replication record to
548  * the file pointer.  If ri is NULL, then include all replicas in the
549  * output.  If ri is non-NULL, then only include a single "replica:" line
550  * (used when writing rejection records).  Returns 0 on success, -1
551  * on failure.  Note that Re_write will not write anything out if the
552  * refcnt is zero.
553  */
554 static int
555 Re_write(
556     Ri          *ri,
557     Re          *re,
558     FILE        *fp )
559 {
560     int         i;
561     char        *s;
562     int         rc = 0;
563
564     if ( re == NULL || fp == NULL ) {
565 #ifdef NEW_LOGGING
566         LDAP_LOG ( SLURPD, ERR, 
567                 "Re_write: Internal error: NULL argument\n", 0, 0, 0 );
568 #else
569         Debug( LDAP_DEBUG_ANY, "Internal error: Re_write: NULL argument\n",
570                 0, 0, 0 );
571 #endif
572         return -1;
573     }
574
575     if ( re->re_refcnt < 1 ) {
576         return 0;               /* this is not an error */
577     }
578
579     if ( ri != NULL ) {         /* write a single "replica:" line */
580         if ( fprintf( fp, "replica: %s:%d\n", ri->ri_hostname,
581                 ri->ri_port ) < 0 ) {
582             rc = -1;
583             goto bad;
584         }
585     } else {                    /* write multiple "replica:" lines */
586         for ( i = 0; re->re_replicas[ i ].rh_hostname != NULL; i++ ) {
587             if ( fprintf( fp, "replica: %s:%d\n",
588                     re->re_replicas[ i ].rh_hostname,
589                     re->re_replicas[ i ].rh_port ) < 0 ) {
590                 rc = -1;
591                 goto bad;
592             }
593         }
594     }
595     if ( fprintf( fp, "time: %ld.%d\n", (long) re->re_timestamp, re->re_seq ) < 0 ) {
596         rc = -1;
597         goto bad;
598     }
599     if ( fprintf( fp, "dn: %s\n", re->re_dn ) < 0 ) {
600         rc = -1;
601         goto bad;
602     }
603     if ( fprintf( fp, "changetype: " ) < 0 ) {
604         rc = -1;
605         goto bad;
606     }
607     switch ( re->re_changetype ) {
608     case T_ADDCT:
609         s = T_ADDCTSTR;
610         break;
611     case T_MODIFYCT:
612         s = T_MODIFYCTSTR;
613         break;
614     case T_DELETECT:
615         s = T_DELETECTSTR;
616         break;
617     case T_MODRDNCT:
618         s = T_MODRDNCTSTR;
619         break;
620     default:
621         s = "IllegalModifyType!!!";
622     }
623     if ( fprintf( fp, "%s\n", s ) < 0 ) {
624         rc = -1;
625         goto bad;
626     }
627     for ( i = 0; (( re->re_mods != NULL ) &&
628             ( re->re_mods[ i ].mi_type != NULL )); i++ ) {
629         if ( !strcmp( re->re_mods[ i ].mi_type, T_MODSEPSTR )) {
630             if ( fprintf( fp, "%s\n", T_MODSEPSTR ) < 0 ) {
631                 rc = -1;
632                 goto bad;
633             }
634         } else {
635             char *obuf;
636             obuf = ldif_put( LDIF_PUT_VALUE,
637                         re->re_mods[ i ].mi_type,
638                     re->re_mods[ i ].mi_val ? re->re_mods[ i ].mi_val : "",
639                     re->re_mods[ i ].mi_len );
640             if ( fputs( obuf, fp ) < 0 ) {
641                 rc = -1;
642                 free( obuf );
643                 goto bad;
644             } else {
645                 ber_memfree( obuf );
646             }
647         }
648     }
649     if ( fprintf( fp, "\n" ) < 0 ) {
650         rc = -1;
651         goto bad;
652     }
653     if ( fflush( fp ) != 0 ) {
654         rc = -1;
655         goto bad;
656     }
657 bad:
658     if ( rc != 0 ) {
659 #ifdef NEW_LOGGING
660         LDAP_LOG ( SLURPD, ERR, 
661                 "Re_write: Error while writing: %s\n", sys_errlist[ errno ], 0, 0 );
662 #else
663         Debug( LDAP_DEBUG_ANY, "Error while writing: %s\n",
664                 sys_errlist[ errno ], 0, 0 );
665 #endif
666     }
667     return rc;
668 }
669
670
671
672
673 /*
674  * Decrement the refcnt.  Locking handled internally.
675  */
676 static int
677 Re_decrefcnt(
678     Re  *re
679 )
680 {
681     re->re_lock( re );
682     re->re_refcnt--;
683     re->re_unlock( re );
684     return 0;
685 }
686
687
688
689 /*
690  * Get the refcnt.  Locking handled internally.
691  */
692 static int
693 Re_getrefcnt(
694     Re  *re
695 )
696 {
697     int ret;
698
699     re->re_lock( re );
700     ret = re->re_refcnt;
701     re->re_unlock( re );
702     return ret;
703 }
704     
705     
706
707
708
709 /*
710  * Lock this replication entry
711  */
712 static int
713 Re_lock(
714     Re  *re
715 )
716 {
717     return( ldap_pvt_thread_mutex_lock( &re->re_mutex ));
718 }
719
720
721
722
723 /*
724  * Unlock this replication entry
725  */
726 static int
727 Re_unlock(
728     Re  *re
729 )
730 {
731     return( ldap_pvt_thread_mutex_unlock( &re->re_mutex ));
732 }
733
734
735
736
737 /* 
738  * Instantiate and initialize an Re.
739  */
740 int
741 Re_init(
742     Re **re
743 )
744 {
745     /* Instantiate */
746     (*re) = (Re *) malloc( sizeof( Re ));
747     if ( *re == NULL ) {
748         return -1;
749     }
750
751     /* Fill in the member function pointers */
752     (*re)->re_free = Re_free;
753     (*re)->re_getnext = Re_getnext;
754     (*re)->re_parse = Re_parse;
755     (*re)->re_write = Re_write;
756     (*re)->re_dump = Re_dump;
757     (*re)->re_lock = Re_lock;
758     (*re)->re_unlock = Re_unlock;
759     (*re)->re_decrefcnt = Re_decrefcnt;
760     (*re)->re_getrefcnt = Re_getrefcnt;
761
762     /* Initialize private data */
763    (*re)->re_refcnt = sglob->num_replicas;
764    (*re)->re_timestamp = (time_t) 0L;
765    (*re)->re_replicas = NULL;
766    (*re)->re_dn = NULL;
767    (*re)->re_changetype = 0;
768    (*re)->re_seq = 0;
769    (*re)->re_mods = NULL;
770    (*re)->re_next = NULL;
771
772    ldap_pvt_thread_mutex_init( &((*re)->re_mutex) );
773    return 0;
774 }
775
776
777
778
779 /*
780  * Given a host and port, generate a warning message iff we haven't already
781  * generated a message for this host:port combination.
782  */
783 static void
784 warn_unknown_replica( 
785     char        *host,
786     int         port
787 )
788 {
789     int found = 0;
790     int i;
791
792     for ( i = 0; i < nur; i++ ) {
793         if ( strcmp( ur[ i ].rh_hostname, host )) {
794             continue;
795         }
796         if ( ur[ i ].rh_port == port ) {
797             found = 1;
798             break;
799         }
800     }
801     if ( !found ) {
802 #ifdef NEW_LOGGING
803         LDAP_LOG ( SLURPD, WARNING, "warn_unknown_replica: "
804                 "Warning: unknown replica %s:%d found in replication log\n",
805                 host, port, 0 );
806 #else
807         Debug( LDAP_DEBUG_ANY,
808                 "Warning: unknown replica %s:%d found in replication log\n",
809                 host, port, 0 );
810 #endif
811         nur++;
812         ur = (Rh *) ch_realloc( (char *) ur, ( nur * sizeof( Rh )));
813         ur[ nur - 1 ].rh_hostname = strdup( host );
814         ur[ nur - 1 ].rh_port = port;
815     }
816 }