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 */
162 /* If the thread is not waiting for lock - ok to end it */
163 if (ubik_currentTrans->locktype != LOCKWAIT) {
164 udisk_end(ubik_currentTrans);
166 ubik_currentTrans = (struct ubik_trans *)0;
175 * log format is defined here, and implicitly in disk.c
177 * 4 byte opcode, followed by parameters, each 4 bytes long. All integers
178 * are in logged in network standard byte order, in case we want to move logs
179 * from machine-to-machine someday.
181 * Begin transaction: opcode \n
182 * Commit transaction: opcode, version (8 bytes) \n
183 * Truncate file: opcode, file number, length \n
184 * Abort transaction: opcode \n
185 * Write data: opcode, file, position, length, <length> data bytes \n
187 * A very simple routine, it just replays the log. Note that this is a new-value only log, which
188 * implies that no uncommitted data is written to the dbase: one writes data to the log, including
189 * the commit record, then we allow data to be written through to the dbase. In our particular
190 * implementation, once a transaction is done, we write out the pages to the database, so that
191 * our buffer package doesn't have to know about stable and uncommitted data in the memory buffers:
192 * any changed data while there is an uncommitted write transaction can be zapped during an
193 * abort and the remaining dbase on the disk is exactly the right dbase, without having to read
197 ReplayLog(struct ubik_dbase *adbase)
200 afs_int32 code, tpos;
202 afs_int32 len, thisSize, tfile, filePos;
204 afs_int32 syncFile = -1;
205 afs_int32 data[1024];
207 /* read the lock twice, once to see whether we have a transaction to deal
208 * with that committed, (theoretically, we should support more than one
209 * trans in the log at once, but not yet), and once replaying the
213 /* for now, assume that all ops in log pertain to one transaction; see if there's a commit */
216 (*adbase->read) (adbase, LOGFILE, (char *)&opcode, tpos,
218 if (code != sizeof(afs_int32))
220 opcode = ntohl(opcode);
221 if (opcode == LOGNEW) {
222 /* handle begin trans */
223 tpos += sizeof(afs_int32);
224 } else if (opcode == LOGABORT)
226 else if (opcode == LOGEND) {
229 } else if (opcode == LOGTRUNCATE) {
232 (*adbase->read) (adbase, LOGFILE, (char *)buffer, tpos,
233 2 * sizeof(afs_int32));
234 if (code != 2 * sizeof(afs_int32))
235 break; /* premature eof or io error */
236 tpos += 2 * sizeof(afs_int32);
237 } else if (opcode == LOGDATA) {
240 (*adbase->read) (adbase, LOGFILE, (char *)buffer, tpos,
241 3 * sizeof(afs_int32));
242 if (code != 3 * sizeof(afs_int32))
244 /* otherwise, skip over the data bytes, too */
245 tpos += ntohl(buffer[2]) + 3 * sizeof(afs_int32);
247 ViceLog(0, ("corrupt log opcode (%d) at position %d\n", opcode,
249 break; /* corrupt log! */
253 /* actually do the replay; log should go all the way through the commit record, since
254 * we just read it above. */
260 (*adbase->read) (adbase, LOGFILE, (char *)&opcode, tpos,
262 if (code != sizeof(afs_int32))
264 opcode = ntohl(opcode);
265 if (opcode == LOGNEW) {
266 /* handle begin trans */
267 tpos += sizeof(afs_int32);
268 } else if (opcode == LOGABORT)
269 panic("log abort\n");
270 else if (opcode == LOGEND) {
271 struct ubik_version version;
274 (*adbase->read) (adbase, LOGFILE, (char *)buffer, tpos,
275 2 * sizeof(afs_int32));
276 if (code != 2 * sizeof(afs_int32))
278 version.epoch = ntohl(buffer[0]);
279 version.counter = ntohl(buffer[1]);
280 code = (*adbase->setlabel) (adbase, 0, &version);
283 ViceLog(0, ("Successfully replayed log for interrupted "
284 "transaction; db version is now %ld.%ld\n",
285 (long) version.epoch, (long) version.counter));
287 break; /* all done now */
288 } else if (opcode == LOGTRUNCATE) {
291 (*adbase->read) (adbase, LOGFILE, (char *)buffer, tpos,
292 2 * sizeof(afs_int32));
293 if (code != 2 * sizeof(afs_int32))
294 break; /* premature eof or io error */
295 tpos += 2 * sizeof(afs_int32);
297 (*adbase->truncate) (adbase, ntohl(buffer[0]),
301 } else if (opcode == LOGDATA) {
304 (*adbase->read) (adbase, LOGFILE, (char *)buffer, tpos,
305 3 * sizeof(afs_int32));
306 if (code != 3 * sizeof(afs_int32))
308 tpos += 3 * sizeof(afs_int32);
309 /* otherwise, skip over the data bytes, too */
310 len = ntohl(buffer[2]); /* total number of bytes to copy */
311 filePos = ntohl(buffer[1]);
312 tfile = ntohl(buffer[0]);
313 /* try to minimize file syncs */
314 if (syncFile != tfile) {
316 code = (*adbase->sync) (adbase, syncFile);
324 thisSize = (len > sizeof(data) ? sizeof(data) : len);
325 /* copy sizeof(data) buffer bytes at a time */
327 (*adbase->read) (adbase, LOGFILE, (char *)data, tpos,
329 if (code != thisSize)
332 (*adbase->write) (adbase, tfile, (char *)data, filePos,
334 if (code != thisSize)
341 ViceLog(0, ("corrupt log opcode (%d) at position %d\n",
343 break; /* corrupt log! */
348 code = (*adbase->sync) (adbase, syncFile);
352 ViceLog(0, ("Log read error on pass 2\n"));
357 /* now truncate the log, we're done with it */
358 code = (*adbase->truncate) (adbase, LOGFILE, 0);
363 * Called at initialization to figure out version of the dbase we really have.
365 * This routine is called after replaying the log; it reads the restored labels.
368 InitializeDB(struct ubik_dbase *adbase)
372 code = (*adbase->getlabel) (adbase, 0, &adbase->version);
374 /* try setting the label to a new value */
376 adbase->version.epoch = 1; /* value for newly-initialized db */
377 adbase->version.counter = 1;
378 code = (*adbase->setlabel) (adbase, 0, &adbase->version);
380 /* failed, try to set it back */
381 adbase->version.epoch = 0;
382 adbase->version.counter = 0;
383 (*adbase->setlabel) (adbase, 0, &adbase->version);
385 #ifdef AFS_PTHREAD_ENV
386 opr_cv_broadcast(&adbase->version_cond);
388 LWP_NoYieldSignal(&adbase->version);
396 * \brief initialize the local ubik_dbase
398 * We replay the logs and then read the resulting file to figure out what version we've really got.
401 urecovery_Initialize(struct ubik_dbase *adbase)
406 code = ReplayLog(adbase);
409 code = InitializeDB(adbase);
416 * \brief Main interaction loop for the recovery manager
418 * The recovery light-weight process only runs when you're the
419 * synchronization site. It performs the following tasks, if and only
420 * if the prerequisite tasks have been performed successfully (it
421 * keeps track of which ones have been performed in its bit map,
422 * \p urecovery_state).
424 * First, it is responsible for probing that all servers are up. This
425 * is the only operation that must be performed even if this is not
426 * yet the sync site, since otherwise this site may not notice that
427 * enough other machines are running to even elect this guy to be the
430 * After that, the recovery process does nothing until the beacon and
431 * voting modules manage to get this site elected sync site.
433 * After becoming sync site, recovery first attempts to find the best
434 * database available in the network (it must do this in order to
435 * ensure finding the latest committed data). After finding the right
436 * database, it must fetch this dbase to the sync site.
438 * After fetching the dbase, it relabels it with a new version number,
439 * to ensure that everyone recognizes this dbase as the most recent
442 * One the dbase has been relabelled, this machine can start handling
443 * requests. However, the recovery module still has one more task:
444 * propagating the dbase out to everyone who is up in the network.
447 urecovery_Interact(void *dummy)
450 struct ubik_server *bestServer = NULL;
451 struct ubik_server *ts;
452 int dbok, doingRPC, now;
453 afs_int32 lastProbeTime;
454 /* if we're the sync site, the best db version we've found yet */
455 static struct ubik_version bestDBVersion;
456 struct ubik_version tversion;
458 int length, tlen, offset, file, nbytes;
459 struct rx_call *rxcall;
461 struct ubik_stat ubikstat;
462 struct in_addr inAddr;
468 afs_pthread_setname_self("recovery");
470 /* otherwise, begin interaction */
474 /* Run through this loop every 4 seconds */
477 #ifdef AFS_PTHREAD_ENV
478 select(0, 0, 0, 0, &tv);
480 IOMGR_Select(0, 0, 0, 0, &tv);
483 ViceLog(5, ("recovery running in state %x\n", urecovery_state));
485 /* Every 30 seconds, check all the down servers and mark them
486 * as up if they respond. When a server comes up or found to
487 * not be current, then re-find the the best database and
490 if ((now = FT_ApproxTime()) > 30 + lastProbeTime) {
492 for (ts = ubik_servers, doingRPC = 0; ts; ts = ts->next) {
503 urecovery_state &= ~UBIK_RECFOUNDDB;
510 urecovery_state &= ~UBIK_RECFOUNDDB;
516 now = FT_ApproxTime();
520 /* Mark whether we are the sync site */
522 if (!ubeacon_AmSyncSite()) {
523 urecovery_state &= ~UBIK_RECSYNCSITE;
525 continue; /* nothing to do */
527 urecovery_state |= UBIK_RECSYNCSITE;
529 /* If a server has just come up or if we have not found the
530 * most current database, then go find the most current db.
532 if (!(urecovery_state & UBIK_RECFOUNDDB)) {
535 bestServer = (struct ubik_server *)0;
536 bestDBVersion.epoch = 0;
537 bestDBVersion.counter = 0;
538 for (ts = ubik_servers; ts; ts = ts->next) {
542 continue; /* don't bother with these guys */
548 code = DISK_GetVersion(ts->disk_rxcid, &ts->version);
552 /* perhaps this is the best version */
553 if (vcmp(ts->version, bestDBVersion) > 0) {
554 /* new best version */
555 bestDBVersion = ts->version;
563 if (okcalls + 1 >= ubik_quorum) {
564 /* If we've asked a majority of sites about their db version,
565 * then we can say with confidence that we've found the best db
566 * version. If we haven't contacted most sites (because
567 * GetVersion failed or because we already know the server is
568 * down), then we don't really know if we know about the best
569 * db version. So we can only proceed in here if 'okcalls'
570 * indicates we managed to contact a majority of sites. */
572 /* take into consideration our version. Remember if we,
573 * the sync site, have the best version. Also note that
574 * we may need to send the best version out.
576 if (vcmp(ubik_dbase->version, bestDBVersion) >= 0) {
577 bestDBVersion = ubik_dbase->version;
578 bestServer = (struct ubik_server *)0;
579 urecovery_state |= UBIK_RECHAVEDB;
581 /* Clear the flag only when we know we have to retrieve
582 * the db. Because urecovery_AllBetter() looks at it.
584 urecovery_state &= ~UBIK_RECHAVEDB;
586 urecovery_state |= UBIK_RECFOUNDDB;
587 urecovery_state &= ~UBIK_RECSENTDB;
590 if (!(urecovery_state & UBIK_RECFOUNDDB)) {
592 continue; /* not ready */
595 /* If we, the sync site, do not have the best db version, then
596 * go and get it from the server that does.
598 if ((urecovery_state & UBIK_RECHAVEDB) || !bestServer) {
599 urecovery_state |= UBIK_RECHAVEDB;
601 /* we don't have the best version; we should fetch it. */
602 urecovery_AbortAll(ubik_dbase);
604 /* Rx code to do the Bulk fetch */
608 rxcall = rx_NewCall(bestServer->disk_rxcid);
610 ViceLog(0, ("Ubik: Synchronize database: receive (via GetFile) "
611 "from server %s begin\n",
612 afs_inet_ntoa_r(bestServer->addr[0], hoststr)));
615 code = StartDISK_GetFile(rxcall, file);
617 ViceLog(0, ("StartDiskGetFile failed=%d\n", code));
620 nbytes = rx_Read(rxcall, (char *)&length, sizeof(afs_int32));
621 length = ntohl(length);
622 if (nbytes != sizeof(afs_int32)) {
623 ViceLog(0, ("Rx-read length error=%d\n", BULK_ERROR));
628 /* give invalid label during file transit */
631 code = (*ubik_dbase->setlabel) (ubik_dbase, file, &tversion);
634 ViceLog(0, ("setlabel io error=%d\n", code));
637 snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.TMP",
638 ubik_dbase->pathName, (file<0)?"SYS":"",
639 (file<0)?-file:file);
640 fd = open(pbuffer, O_CREAT | O_RDWR | O_TRUNC, 0600);
645 code = lseek(fd, HDRSIZE, 0);
646 if (code != HDRSIZE) {
653 tlen = (length > sizeof(tbuffer) ? sizeof(tbuffer) : length);
654 #ifndef AFS_PTHREAD_ENV
658 nbytes = rx_Read(rxcall, tbuffer, tlen);
659 if (nbytes != tlen) {
660 ViceLog(0, ("Rx-read bulk error=%d\n", BULK_ERROR));
665 nbytes = write(fd, tbuffer, tlen);
667 if (nbytes != tlen) {
678 code = EndDISK_GetFile(rxcall, &tversion);
680 code = rx_EndCall(rxcall, code);
682 /* we got a new file, set up its header */
683 urecovery_state |= UBIK_RECHAVEDB;
685 memcpy(&ubik_dbase->version, &tversion,
686 sizeof(struct ubik_version));
687 snprintf(tbuffer, sizeof(tbuffer), "%s.DB%s%d",
688 ubik_dbase->pathName, (file<0)?"SYS":"",
689 (file<0)?-file:file);
691 snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.OLD",
692 ubik_dbase->pathName, (file<0)?"SYS":"",
693 (file<0)?-file:file);
694 code = unlink(pbuffer);
696 code = rename(tbuffer, pbuffer);
697 snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.TMP",
698 ubik_dbase->pathName, (file<0)?"SYS":"",
699 (file<0)?-file:file);
702 code = rename(pbuffer, tbuffer);
704 (*ubik_dbase->open) (ubik_dbase, file);
705 /* after data is good, sync disk with correct label */
707 (*ubik_dbase->setlabel) (ubik_dbase, 0,
708 &ubik_dbase->version);
712 snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.OLD",
713 ubik_dbase->pathName, (file<0)?"SYS":"",
714 (file<0)?-file:file);
721 * We will effectively invalidate the old data forever now.
722 * Unclear if we *should* but we do.
725 ubik_dbase->version.epoch = 0;
726 ubik_dbase->version.counter = 0;
729 ("Ubik: Synchronize database: receive (via GetFile) "
730 "from server %s failed (error = %d)\n",
731 afs_inet_ntoa_r(bestServer->addr[0], hoststr), code));
734 ("Ubik: Synchronize database: receive (via GetFile) "
735 "from server %s complete, version: %d.%d\n",
736 afs_inet_ntoa_r(bestServer->addr[0], hoststr),
737 ubik_dbase->version.epoch, ubik_dbase->version.counter));
739 urecovery_state |= UBIK_RECHAVEDB;
741 udisk_Invalidate(ubik_dbase, 0); /* data has changed */
742 #ifdef AFS_PTHREAD_ENV
743 opr_cv_broadcast(&ubik_dbase->version_cond);
745 LWP_NoYieldSignal(&ubik_dbase->version);
748 if (!(urecovery_state & UBIK_RECHAVEDB)) {
750 continue; /* not ready */
753 /* If the database was newly initialized, then when we establish quorum, write
754 * a new label. This allows urecovery_AllBetter() to allow access for reads.
755 * Setting it to 2 also allows another site to come along with a newer
756 * database and overwrite this one.
758 if (ubik_dbase->version.epoch == 1) {
759 urecovery_AbortAll(ubik_dbase);
761 ubik_dbase->version.epoch = 2;
762 ubik_dbase->version.counter = 1;
764 (*ubik_dbase->setlabel) (ubik_dbase, 0, &ubik_dbase->version);
766 udisk_Invalidate(ubik_dbase, 0); /* data may have changed */
767 #ifdef AFS_PTHREAD_ENV
768 opr_cv_broadcast(&ubik_dbase->version_cond);
770 LWP_NoYieldSignal(&ubik_dbase->version);
774 /* Check the other sites and send the database to them if they
775 * do not have the current db.
777 if (!(urecovery_state & UBIK_RECSENTDB)) {
778 /* now propagate out new version to everyone else */
779 dbok = 1; /* start off assuming they all worked */
782 * Check if a write transaction is in progress. We can't send the
783 * db when a write is in progress here because the db would be
784 * obsolete as soon as it goes there. Also, ops after the begin
785 * trans would reach the recepient and wouldn't find a transaction
786 * pending there. Frankly, I don't think it's possible to get past
787 * the write-lock above if there is a write transaction in progress,
788 * but then, it won't hurt to check, will it?
790 if (ubik_dbase->flags & DBWRITING) {
793 long cur_usec = 50000;
794 while ((ubik_dbase->flags & DBWRITING) && (safety < 500)) {
796 /* sleep for a little while */
798 tv.tv_usec = cur_usec;
799 #ifdef AFS_PTHREAD_ENV
800 select(0, 0, 0, 0, &tv);
802 IOMGR_Select(0, 0, 0, 0, &tv);
810 for (ts = ubik_servers; ts; ts = ts->next) {
812 inAddr.s_addr = ts->addr[0];
817 /* It would be nice to have this message at loglevel
818 * 0 as well, but it will log once every 4s for each
819 * down server while in this recovery state. This
820 * should only be changed to loglevel 0 if it is
823 ViceLog(5, ("recovery cannot send version to %s\n",
824 afs_inet_ntoa_r(inAddr.s_addr, hoststr)));
830 if (vcmp(ts->version, ubik_dbase->version) != 0) {
831 ViceLog(0, ("Synchronize database: send (via SendFile) "
832 "to server %s begin\n",
833 afs_inet_ntoa_r(inAddr.s_addr, hoststr)));
835 /* Rx code to do the Bulk Store */
836 code = (*ubik_dbase->stat) (ubik_dbase, 0, &ubikstat);
838 length = ubikstat.size;
841 rxcall = rx_NewCall(ts->disk_rxcid);
844 StartDISK_SendFile(rxcall, file, length,
845 &ubik_dbase->version);
847 ViceLog(0, ("StartDiskSendFile failed=%d\n",
854 sizeof(tbuffer) ? sizeof(tbuffer) : length);
856 (*ubik_dbase->read) (ubik_dbase, file,
857 tbuffer, offset, tlen);
858 if (nbytes != tlen) {
860 ViceLog(0, ("Local disk read error=%d\n", code));
863 nbytes = rx_Write(rxcall, tbuffer, tlen);
864 if (nbytes != tlen) {
866 ViceLog(0, ("Rx-write bulk error=%d\n", code));
872 code = EndDISK_SendFile(rxcall);
874 code = rx_EndCall(rxcall, code);
878 /* we set a new file, process its header */
879 ts->version = ubik_dbase->version;
882 ("Ubik: Synchronize database: send (via SendFile) "
883 "to server %s complete, version: %d.%d\n",
884 afs_inet_ntoa_r(inAddr.s_addr, hoststr),
885 ts->version.epoch, ts->version.counter));
890 ("Ubik: Synchronize database: send (via SendFile) "
891 "to server %s failed (error = %d)\n",
892 afs_inet_ntoa_r(inAddr.s_addr, hoststr), code));
895 /* mark file up to date */
900 urecovery_state |= UBIK_RECSENTDB;
904 AFS_UNREACHED(return(NULL));
908 * \brief send a Probe to all the network address of this server
910 * \return 0 if success, else return 1
913 DoProbe(struct ubik_server *server)
915 struct rx_connection *conns[UBIK_MAX_INTERFACE_ADDR];
916 struct rx_connection *connSuccess = 0;
917 int i, nconns, success_i = -1;
923 for (i = 0; (i < UBIK_MAX_INTERFACE_ADDR) && (addr = server->addr[i]);
926 rx_NewConnection(addr, ubik_callPortal, DISK_SERVICE_ID,
927 addr_globals.ubikSecClass, addr_globals.ubikSecIndex);
929 /* user requirement to use only the primary interface */
930 if (ubikPrimaryAddrOnly) {
937 opr_Assert(nconns); /* at least one interface address for this server */
939 multi_Rx(conns, nconns) {
941 if (!multi_error) { /* first success */
948 if (success_i >= 0) {
950 addr = server->addr[success_i]; /* successful interface addr */
952 if (server->disk_rxcid) /* destroy existing conn */
953 rx_DestroyConnection(server->disk_rxcid);
954 if (server->vote_rxcid)
955 rx_DestroyConnection(server->vote_rxcid);
957 /* make new connections */
958 server->disk_rxcid = conns[success_i];
959 server->vote_rxcid = rx_NewConnection(addr, ubik_callPortal,
960 VOTE_SERVICE_ID, addr_globals.ubikSecClass,
961 addr_globals.ubikSecIndex);
963 connSuccess = conns[success_i];
964 strcpy(buffer, afs_inet_ntoa_r(server->addr[0], hoststr));
966 ViceLog(0, ("ubik:server %s is back up: will be contacted through %s\n",
967 buffer, afs_inet_ntoa_r(addr, hoststr)));
971 /* Destroy all connections except the one on which we succeeded */
972 for (i = 0; i < nconns; i++)
973 if (conns[i] != connSuccess)
974 rx_DestroyConnection(conns[i]);
977 ViceLog(5, ("ubik:server %s still down\n",
978 afs_inet_ntoa_r(server->addr[0], hoststr)));
981 return 0; /* success */
983 return 1; /* failure */