2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
17 #ifdef AFS_PTHREAD_ENV
18 # include <opr/lock.h>
20 # include <opr/lockstub.h>
24 #include <afs/afsutil.h>
25 #include <afs/cellconfig.h>
28 #define UBIK_INTERNALS
33 * This module is responsible for determining when the system has
34 * recovered to the point that it can handle new transactions. It
35 * replays logs, polls to determine the current dbase after a crash,
36 * and distributes the new database to the others.
38 * The sync site associates a version number with each database. It
39 * broadcasts the version associated with its current dbase in every
40 * one of its beacon messages. When the sync site send a dbase to a
41 * server, it also sends the db's version. A non-sync site server can
42 * tell if it has the right dbase version by simply comparing the
43 * version from the beacon message \p uvote_dbVersion with the version
44 * associated with the database \p ubik_dbase->version. The sync site
45 * itself simply has one counter to keep track of all of this (again
46 * \p ubik_dbase->version).
48 * sync site: routine called when the sync site loses its quorum; this
49 * procedure is called "up" from the beacon package. It resyncs the
50 * dbase and nudges the recovery daemon to try to propagate out the
51 * changes. It also resets the recovery daemon's state, since
52 * recovery must potentially find a new dbase to propagate out. This
53 * routine should not do anything with variables used by non-sync site
58 * if this flag is set, then ubik will use only the primary address
59 * (the address specified in the CellServDB) to contact other
60 * ubik servers. Ubik recovery will not try opening connections
61 * to the alternate interface addresses.
63 int ubikPrimaryAddrOnly;
66 urecovery_ResetState(void)
75 * routine called when a non-sync site server goes down; restarts recovery
76 * process to send missing server the new db when it comes back up for
77 * non-sync site servers.
79 * \note This routine should not do anything with variables used by non-sync site servers.
82 urecovery_LostServer(struct ubik_server *ts)
84 ubeacon_ReinitServer(ts);
89 * return true iff we have a current database (called by both sync
90 * sites and non-sync sites) How do we determine this? If we're the
91 * sync site, we wait until recovery has finished fetching and
92 * re-labelling its dbase (it may still be trying to propagate it out
93 * to everyone else; that's THEIR problem). If we're not the sync
94 * site, then we must have a dbase labelled with the right version,
95 * and we must have a currently-good sync site.
98 urecovery_AllBetter(struct ubik_dbase *adbase, int areadAny)
102 ViceLog(25, ("allbetter checking\n"));
107 if (ubik_dbase->version.epoch > 1)
108 rcode = 1; /* Happy with any good version of database */
111 /* Check if we're sync site and we've got the right data */
112 else if (ubeacon_AmSyncSite() && (urecovery_state & UBIK_RECHAVEDB)) {
116 /* next, check if we're aux site, and we've ever been sent the
117 * right data (note that if a dbase update fails, we won't think
118 * that the sync site is still the sync site, 'cause it won't talk
119 * to us until a timeout period has gone by. When we recover, we
120 * leave this clear until we get a new dbase */
121 else if (uvote_HaveSyncAndVersion(ubik_dbase->version)) {
125 ViceLog(25, ("allbetter: returning %d\n", rcode));
130 * \brief abort all transactions on this database
133 urecovery_AbortAll(struct ubik_dbase *adbase)
135 struct ubik_trans *tt;
136 int reads = 0, writes = 0;
138 for (tt = adbase->activeTrans; tt; tt = tt->next) {
139 if (tt->type == UBIK_WRITETRANS)
145 ViceLog(0, ("urecovery_AbortAll: just aborted %d read and %d write transactions\n",
151 * \brief this routine aborts the current remote transaction, if any, if the tid is wrong
154 urecovery_CheckTid(struct ubik_tid *atid, int abortalways)
156 if (ubik_currentTrans) {
157 /* there is remote write trans, see if we match, see if this
158 * is a new transaction */
159 if (atid->epoch != ubik_currentTrans->tid.epoch
160 || atid->counter > ubik_currentTrans->tid.counter || abortalways) {
161 /* don't match, abort it */
163 /* If the thread is not waiting for lock - ok to end it */
164 if (ubik_currentTrans->locktype != LOCKWAIT) {
168 ViceLog(0, ("urecovery_CheckTid: Aborting/ending bad remote "
169 "transaction. (tx %d.%d, atid %d.%d, abortalways %d, "
171 ubik_currentTrans->tid.epoch,
172 ubik_currentTrans->tid.counter,
173 atid->epoch, atid->counter,
174 abortalways, endit));
176 udisk_end(ubik_currentTrans);
178 ubik_currentTrans = (struct ubik_trans *)0;
187 * log format is defined here, and implicitly in disk.c
189 * 4 byte opcode, followed by parameters, each 4 bytes long. All integers
190 * are in logged in network standard byte order, in case we want to move logs
191 * from machine-to-machine someday.
193 * Begin transaction: opcode \n
194 * Commit transaction: opcode, version (8 bytes) \n
195 * Truncate file: opcode, file number, length \n
196 * Abort transaction: opcode \n
197 * Write data: opcode, file, position, length, <length> data bytes \n
199 * A very simple routine, it just replays the log. Note that this is a new-value only log, which
200 * implies that no uncommitted data is written to the dbase: one writes data to the log, including
201 * the commit record, then we allow data to be written through to the dbase. In our particular
202 * implementation, once a transaction is done, we write out the pages to the database, so that
203 * our buffer package doesn't have to know about stable and uncommitted data in the memory buffers:
204 * any changed data while there is an uncommitted write transaction can be zapped during an
205 * abort and the remaining dbase on the disk is exactly the right dbase, without having to read
209 ReplayLog(struct ubik_dbase *adbase)
212 afs_int32 code, tpos;
214 afs_int32 len, thisSize, tfile, filePos;
216 afs_int32 syncFile = -1;
217 afs_int32 data[1024];
219 /* read the lock twice, once to see whether we have a transaction to deal
220 * with that committed, (theoretically, we should support more than one
221 * trans in the log at once, but not yet), and once replaying the
225 /* for now, assume that all ops in log pertain to one transaction; see if there's a commit */
228 (*adbase->read) (adbase, LOGFILE, (char *)&opcode, tpos,
230 if (code != sizeof(afs_int32))
232 opcode = ntohl(opcode);
233 if (opcode == LOGNEW) {
234 /* handle begin trans */
235 tpos += sizeof(afs_int32);
236 } else if (opcode == LOGABORT)
238 else if (opcode == LOGEND) {
241 } else if (opcode == LOGTRUNCATE) {
244 (*adbase->read) (adbase, LOGFILE, (char *)buffer, tpos,
245 2 * sizeof(afs_int32));
246 if (code != 2 * sizeof(afs_int32))
247 break; /* premature eof or io error */
248 tpos += 2 * sizeof(afs_int32);
249 } else if (opcode == LOGDATA) {
252 (*adbase->read) (adbase, LOGFILE, (char *)buffer, tpos,
253 3 * sizeof(afs_int32));
254 if (code != 3 * sizeof(afs_int32))
256 /* otherwise, skip over the data bytes, too */
257 tpos += ntohl(buffer[2]) + 3 * sizeof(afs_int32);
259 ViceLog(0, ("corrupt log opcode (%d) at position %d\n", opcode,
261 break; /* corrupt log! */
265 /* actually do the replay; log should go all the way through the commit record, since
266 * we just read it above. */
272 (*adbase->read) (adbase, LOGFILE, (char *)&opcode, tpos,
274 if (code != sizeof(afs_int32))
276 opcode = ntohl(opcode);
277 if (opcode == LOGNEW) {
278 /* handle begin trans */
279 tpos += sizeof(afs_int32);
280 } else if (opcode == LOGABORT)
281 panic("log abort\n");
282 else if (opcode == LOGEND) {
283 struct ubik_version version;
286 (*adbase->read) (adbase, LOGFILE, (char *)buffer, tpos,
287 2 * sizeof(afs_int32));
288 if (code != 2 * sizeof(afs_int32))
290 version.epoch = ntohl(buffer[0]);
291 version.counter = ntohl(buffer[1]);
292 code = (*adbase->setlabel) (adbase, 0, &version);
295 ViceLog(0, ("Successfully replayed log for interrupted "
296 "transaction; db version is now %ld.%ld\n",
297 (long) version.epoch, (long) version.counter));
299 break; /* all done now */
300 } else if (opcode == LOGTRUNCATE) {
303 (*adbase->read) (adbase, LOGFILE, (char *)buffer, tpos,
304 2 * sizeof(afs_int32));
305 if (code != 2 * sizeof(afs_int32))
306 break; /* premature eof or io error */
307 tpos += 2 * sizeof(afs_int32);
309 (*adbase->truncate) (adbase, ntohl(buffer[0]),
313 } else if (opcode == LOGDATA) {
316 (*adbase->read) (adbase, LOGFILE, (char *)buffer, tpos,
317 3 * sizeof(afs_int32));
318 if (code != 3 * sizeof(afs_int32))
320 tpos += 3 * sizeof(afs_int32);
321 /* otherwise, skip over the data bytes, too */
322 len = ntohl(buffer[2]); /* total number of bytes to copy */
323 filePos = ntohl(buffer[1]);
324 tfile = ntohl(buffer[0]);
325 /* try to minimize file syncs */
326 if (syncFile != tfile) {
328 code = (*adbase->sync) (adbase, syncFile);
336 thisSize = (len > sizeof(data) ? sizeof(data) : len);
337 /* copy sizeof(data) buffer bytes at a time */
339 (*adbase->read) (adbase, LOGFILE, (char *)data, tpos,
341 if (code != thisSize)
344 (*adbase->write) (adbase, tfile, (char *)data, filePos,
346 if (code != thisSize)
353 ViceLog(0, ("corrupt log opcode (%d) at position %d\n",
355 break; /* corrupt log! */
360 code = (*adbase->sync) (adbase, syncFile);
364 ViceLog(0, ("Log read error on pass 2\n"));
369 /* now truncate the log, we're done with it */
370 code = (*adbase->truncate) (adbase, LOGFILE, 0);
375 * Called at initialization to figure out version of the dbase we really have.
377 * This routine is called after replaying the log; it reads the restored labels.
380 InitializeDB(struct ubik_dbase *adbase)
384 code = (*adbase->getlabel) (adbase, 0, &adbase->version);
386 /* try setting the label to a new value */
388 adbase->version.epoch = 1; /* value for newly-initialized db */
389 adbase->version.counter = 1;
390 code = (*adbase->setlabel) (adbase, 0, &adbase->version);
392 /* failed, try to set it back */
393 adbase->version.epoch = 0;
394 adbase->version.counter = 0;
395 (*adbase->setlabel) (adbase, 0, &adbase->version);
403 * \brief initialize the local ubik_dbase
405 * We replay the logs and then read the resulting file to figure out what version we've really got.
408 urecovery_Initialize(struct ubik_dbase *adbase)
413 code = ReplayLog(adbase);
416 code = InitializeDB(adbase);
423 * \brief Main interaction loop for the recovery manager
425 * The recovery light-weight process only runs when you're the
426 * synchronization site. It performs the following tasks, if and only
427 * if the prerequisite tasks have been performed successfully (it
428 * keeps track of which ones have been performed in its bit map,
429 * \p urecovery_state).
431 * First, it is responsible for probing that all servers are up. This
432 * is the only operation that must be performed even if this is not
433 * yet the sync site, since otherwise this site may not notice that
434 * enough other machines are running to even elect this guy to be the
437 * After that, the recovery process does nothing until the beacon and
438 * voting modules manage to get this site elected sync site.
440 * After becoming sync site, recovery first attempts to find the best
441 * database available in the network (it must do this in order to
442 * ensure finding the latest committed data). After finding the right
443 * database, it must fetch this dbase to the sync site.
445 * After fetching the dbase, it relabels it with a new version number,
446 * to ensure that everyone recognizes this dbase as the most recent
449 * One the dbase has been relabelled, this machine can start handling
450 * requests. However, the recovery module still has one more task:
451 * propagating the dbase out to everyone who is up in the network.
454 urecovery_Interact(void *dummy)
457 struct ubik_server *bestServer = NULL;
458 struct ubik_server *ts;
459 int dbok, doingRPC, now;
460 afs_int32 lastProbeTime;
461 /* if we're the sync site, the best db version we've found yet */
462 static struct ubik_version bestDBVersion;
463 struct ubik_version tversion;
465 int length, tlen, offset, file, nbytes;
466 struct rx_call *rxcall;
468 struct ubik_stat ubikstat;
469 struct in_addr inAddr;
475 opr_threadname_set("recovery");
477 /* otherwise, begin interaction */
481 /* Run through this loop every 4 seconds */
484 #ifdef AFS_PTHREAD_ENV
485 select(0, 0, 0, 0, &tv);
487 IOMGR_Select(0, 0, 0, 0, &tv);
490 ViceLog(5, ("recovery running in state %x\n", urecovery_state));
492 /* Every 30 seconds, check all the down servers and mark them
493 * as up if they respond. When a server comes up or found to
494 * not be current, then re-find the the best database and
497 if ((now = FT_ApproxTime()) > 30 + lastProbeTime) {
499 for (ts = ubik_servers, doingRPC = 0; ts; ts = ts->next) {
510 urecovery_state &= ~UBIK_RECFOUNDDB;
517 urecovery_state &= ~UBIK_RECFOUNDDB;
523 now = FT_ApproxTime();
527 /* Mark whether we are the sync site */
529 if (!ubeacon_AmSyncSite()) {
530 urecovery_state &= ~UBIK_RECSYNCSITE;
532 continue; /* nothing to do */
534 urecovery_state |= UBIK_RECSYNCSITE;
536 /* If a server has just come up or if we have not found the
537 * most current database, then go find the most current db.
539 if (!(urecovery_state & UBIK_RECFOUNDDB)) {
542 bestServer = (struct ubik_server *)0;
543 bestDBVersion.epoch = 0;
544 bestDBVersion.counter = 0;
545 for (ts = ubik_servers; ts; ts = ts->next) {
549 continue; /* don't bother with these guys */
555 code = DISK_GetVersion(ts->disk_rxcid, &ts->version);
559 /* perhaps this is the best version */
560 if (vcmp(ts->version, bestDBVersion) > 0) {
561 /* new best version */
562 bestDBVersion = ts->version;
570 if (okcalls + 1 >= ubik_quorum) {
571 /* If we've asked a majority of sites about their db version,
572 * then we can say with confidence that we've found the best db
573 * version. If we haven't contacted most sites (because
574 * GetVersion failed or because we already know the server is
575 * down), then we don't really know if we know about the best
576 * db version. So we can only proceed in here if 'okcalls'
577 * indicates we managed to contact a majority of sites. */
579 /* take into consideration our version. Remember if we,
580 * the sync site, have the best version. Also note that
581 * we may need to send the best version out.
583 if (vcmp(ubik_dbase->version, bestDBVersion) >= 0) {
584 bestDBVersion = ubik_dbase->version;
585 bestServer = (struct ubik_server *)0;
586 urecovery_state |= UBIK_RECHAVEDB;
588 /* Clear the flag only when we know we have to retrieve
589 * the db. Because urecovery_AllBetter() looks at it.
591 urecovery_state &= ~UBIK_RECHAVEDB;
593 urecovery_state |= UBIK_RECFOUNDDB;
594 urecovery_state &= ~UBIK_RECSENTDB;
597 if (!(urecovery_state & UBIK_RECFOUNDDB)) {
599 continue; /* not ready */
602 /* If we, the sync site, do not have the best db version, then
603 * go and get it from the server that does.
605 if ((urecovery_state & UBIK_RECHAVEDB) || !bestServer) {
606 urecovery_state |= UBIK_RECHAVEDB;
608 /* we don't have the best version; we should fetch it. */
609 urecovery_AbortAll(ubik_dbase);
611 /* Rx code to do the Bulk fetch */
615 rxcall = rx_NewCall(bestServer->disk_rxcid);
617 ViceLog(0, ("Ubik: Synchronize database: receive (via GetFile) "
618 "from server %s begin\n",
619 afs_inet_ntoa_r(bestServer->addr[0], hoststr)));
622 code = StartDISK_GetFile(rxcall, file);
624 ViceLog(0, ("StartDiskGetFile failed=%d\n", code));
627 nbytes = rx_Read(rxcall, (char *)&length, sizeof(afs_int32));
628 length = ntohl(length);
629 if (nbytes != sizeof(afs_int32)) {
630 ViceLog(0, ("Rx-read length error=%d\n", BULK_ERROR));
635 /* give invalid label during file transit */
638 code = (*ubik_dbase->setlabel) (ubik_dbase, file, &tversion);
641 ViceLog(0, ("setlabel io error=%d\n", code));
644 snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.TMP",
645 ubik_dbase->pathName, (file<0)?"SYS":"",
646 (file<0)?-file:file);
647 fd = open(pbuffer, O_CREAT | O_RDWR | O_TRUNC, 0600);
652 code = lseek(fd, HDRSIZE, 0);
653 if (code != HDRSIZE) {
660 tlen = (length > sizeof(tbuffer) ? sizeof(tbuffer) : length);
661 #ifndef AFS_PTHREAD_ENV
665 nbytes = rx_Read(rxcall, tbuffer, tlen);
666 if (nbytes != tlen) {
667 ViceLog(0, ("Rx-read bulk error=%d\n", BULK_ERROR));
672 nbytes = write(fd, tbuffer, tlen);
674 if (nbytes != tlen) {
685 code = EndDISK_GetFile(rxcall, &tversion);
687 code = rx_EndCall(rxcall, code);
689 /* we got a new file, set up its header */
690 urecovery_state |= UBIK_RECHAVEDB;
692 memcpy(&ubik_dbase->version, &tversion,
693 sizeof(struct ubik_version));
694 snprintf(tbuffer, sizeof(tbuffer), "%s.DB%s%d",
695 ubik_dbase->pathName, (file<0)?"SYS":"",
696 (file<0)?-file:file);
698 snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.OLD",
699 ubik_dbase->pathName, (file<0)?"SYS":"",
700 (file<0)?-file:file);
701 code = unlink(pbuffer);
703 code = rename(tbuffer, pbuffer);
704 snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.TMP",
705 ubik_dbase->pathName, (file<0)?"SYS":"",
706 (file<0)?-file:file);
709 code = rename(pbuffer, tbuffer);
711 (*ubik_dbase->open) (ubik_dbase, file);
712 /* after data is good, sync disk with correct label */
714 (*ubik_dbase->setlabel) (ubik_dbase, 0,
715 &ubik_dbase->version);
719 snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.OLD",
720 ubik_dbase->pathName, (file<0)?"SYS":"",
721 (file<0)?-file:file);
728 * We will effectively invalidate the old data forever now.
729 * Unclear if we *should* but we do.
732 ubik_dbase->version.epoch = 0;
733 ubik_dbase->version.counter = 0;
736 ("Ubik: Synchronize database: receive (via GetFile) "
737 "from server %s failed (error = %d)\n",
738 afs_inet_ntoa_r(bestServer->addr[0], hoststr), code));
741 ("Ubik: Synchronize database: receive (via GetFile) "
742 "from server %s complete, version: %d.%d\n",
743 afs_inet_ntoa_r(bestServer->addr[0], hoststr),
744 ubik_dbase->version.epoch, ubik_dbase->version.counter));
746 urecovery_state |= UBIK_RECHAVEDB;
748 udisk_Invalidate(ubik_dbase, 0); /* data has changed */
750 if (!(urecovery_state & UBIK_RECHAVEDB)) {
752 continue; /* not ready */
755 /* If the database was newly initialized, then when we establish quorum, write
756 * a new label. This allows urecovery_AllBetter() to allow access for reads.
757 * Setting it to 2 also allows another site to come along with a newer
758 * database and overwrite this one.
760 if (ubik_dbase->version.epoch == 1) {
761 urecovery_AbortAll(ubik_dbase);
763 ubik_dbase->version.epoch = 2;
764 ubik_dbase->version.counter = 1;
766 (*ubik_dbase->setlabel) (ubik_dbase, 0, &ubik_dbase->version);
768 udisk_Invalidate(ubik_dbase, 0); /* data may have changed */
771 /* Check the other sites and send the database to them if they
772 * do not have the current db.
774 if (!(urecovery_state & UBIK_RECSENTDB)) {
775 /* now propagate out new version to everyone else */
776 dbok = 1; /* start off assuming they all worked */
779 * Check if a write transaction is in progress. We can't send the
780 * db when a write is in progress here because the db would be
781 * obsolete as soon as it goes there. Also, ops after the begin
782 * trans would reach the recepient and wouldn't find a transaction
783 * pending there. Frankly, I don't think it's possible to get past
784 * the write-lock above if there is a write transaction in progress,
785 * but then, it won't hurt to check, will it?
787 if (ubik_dbase->dbFlags & DBWRITING) {
790 long cur_usec = 50000;
791 while ((ubik_dbase->dbFlags & DBWRITING) && (safety < 500)) {
793 /* sleep for a little while */
795 tv.tv_usec = cur_usec;
796 #ifdef AFS_PTHREAD_ENV
797 select(0, 0, 0, 0, &tv);
799 IOMGR_Select(0, 0, 0, 0, &tv);
807 for (ts = ubik_servers; ts; ts = ts->next) {
809 inAddr.s_addr = ts->addr[0];
814 /* It would be nice to have this message at loglevel
815 * 0 as well, but it will log once every 4s for each
816 * down server while in this recovery state. This
817 * should only be changed to loglevel 0 if it is
820 ViceLog(5, ("recovery cannot send version to %s\n",
821 afs_inet_ntoa_r(inAddr.s_addr, hoststr)));
827 if (vcmp(ts->version, ubik_dbase->version) != 0) {
828 ViceLog(0, ("Synchronize database: send (via SendFile) "
829 "to server %s begin\n",
830 afs_inet_ntoa_r(inAddr.s_addr, hoststr)));
832 /* Rx code to do the Bulk Store */
833 code = (*ubik_dbase->stat) (ubik_dbase, 0, &ubikstat);
835 length = ubikstat.size;
838 rxcall = rx_NewCall(ts->disk_rxcid);
841 StartDISK_SendFile(rxcall, file, length,
842 &ubik_dbase->version);
844 ViceLog(0, ("StartDiskSendFile failed=%d\n",
851 sizeof(tbuffer) ? sizeof(tbuffer) : length);
853 (*ubik_dbase->read) (ubik_dbase, file,
854 tbuffer, offset, tlen);
855 if (nbytes != tlen) {
857 ViceLog(0, ("Local disk read error=%d\n", code));
860 nbytes = rx_Write(rxcall, tbuffer, tlen);
861 if (nbytes != tlen) {
863 ViceLog(0, ("Rx-write bulk error=%d\n", code));
869 code = EndDISK_SendFile(rxcall);
871 code = rx_EndCall(rxcall, code);
875 /* we set a new file, process its header */
876 ts->version = ubik_dbase->version;
879 ("Ubik: Synchronize database: send (via SendFile) "
880 "to server %s complete, version: %d.%d\n",
881 afs_inet_ntoa_r(inAddr.s_addr, hoststr),
882 ts->version.epoch, ts->version.counter));
887 ("Ubik: Synchronize database: send (via SendFile) "
888 "to server %s failed (error = %d)\n",
889 afs_inet_ntoa_r(inAddr.s_addr, hoststr), code));
892 /* mark file up to date */
897 urecovery_state |= UBIK_RECSENTDB;
901 AFS_UNREACHED(return(NULL));
905 * \brief send a Probe to all the network address of this server
907 * \return 0 if success, else return 1
910 DoProbe(struct ubik_server *server)
912 struct rx_connection *conns[UBIK_MAX_INTERFACE_ADDR];
913 struct rx_connection *connSuccess = 0;
914 int i, nconns, success_i = -1;
920 for (i = 0; (i < UBIK_MAX_INTERFACE_ADDR) && (addr = server->addr[i]);
923 rx_NewConnection(addr, ubik_callPortal, DISK_SERVICE_ID,
924 addr_globals.ubikSecClass, addr_globals.ubikSecIndex);
926 /* user requirement to use only the primary interface */
927 if (ubikPrimaryAddrOnly) {
934 opr_Assert(nconns); /* at least one interface address for this server */
936 multi_Rx(conns, nconns) {
938 if (!multi_error) { /* first success */
945 if (success_i >= 0) {
947 addr = server->addr[success_i]; /* successful interface addr */
949 if (server->disk_rxcid) /* destroy existing conn */
950 rx_DestroyConnection(server->disk_rxcid);
951 if (server->vote_rxcid)
952 rx_DestroyConnection(server->vote_rxcid);
954 /* make new connections */
955 server->disk_rxcid = conns[success_i];
956 server->vote_rxcid = rx_NewConnection(addr, ubik_callPortal,
957 VOTE_SERVICE_ID, addr_globals.ubikSecClass,
958 addr_globals.ubikSecIndex);
960 connSuccess = conns[success_i];
961 strcpy(buffer, afs_inet_ntoa_r(server->addr[0], hoststr));
963 ViceLog(0, ("ubik:server %s is back up: will be contacted through %s\n",
964 buffer, afs_inet_ntoa_r(addr, hoststr)));
968 /* Destroy all connections except the one on which we succeeded */
969 for (i = 0; i < nconns; i++)
970 if (conns[i] != connSuccess)
971 rx_DestroyConnection(conns[i]);
974 ViceLog(5, ("ubik:server %s still down\n",
975 afs_inet_ntoa_r(server->addr[0], hoststr)));
978 return 0; /* success */
980 return 1; /* failure */