ubik-prototypes-20090315

LICENSE IPL10
FIXES 124245

prototype the ubik directory
This commit is contained in:
Simon Wilkinson 2009-03-16 03:03:14 +00:00 committed by Derrick Brashear
parent b18ec965dd
commit d5158b2ccb
18 changed files with 587 additions and 346 deletions

View File

@ -30,6 +30,7 @@ RCSID
#include <stdio.h> #include <stdio.h>
#include <rx/rx.h> #include <rx/rx.h>
#include <lock.h> #include <lock.h>
#define UBIK_LEGACY_CALLITER 1
#include <ubik.h> #include <ubik.h>
#ifndef AFS_NT40_ENV #ifndef AFS_NT40_ENV
#include <pwd.h> #include <pwd.h>

View File

@ -19,6 +19,8 @@
RCSID RCSID
("$Header$"); ("$Header$");
#define UBIK_LEGACY_CALLITER 1
#if defined(UKERNEL) #if defined(UKERNEL)
#include "afs/sysincludes.h" #include "afs/sysincludes.h"
#include "afsincludes.h" #include "afsincludes.h"

View File

@ -79,7 +79,7 @@ utst_int.cs.o: utst_int.cs.c utst_int.xdr.c
utst_int.xdr.o: utst_int.xdr.c utst_int.h utst_int.xdr.o: utst_int.xdr.c utst_int.h
utst_int.cs.c: utst_int.xg utst_int.cs.c: utst_int.xg
${RXGEN} -A -C -o $@ ${srcdir}/utst_int.xg ${RXGEN} -A -C -u -o $@ ${srcdir}/utst_int.xg
utst_int.ss.c: utst_int.xg utst_int.ss.c: utst_int.xg
${RXGEN} -A -S -o $@ ${srcdir}/utst_int.xg ${RXGEN} -A -S -o $@ ${srcdir}/utst_int.xg
@ -88,7 +88,7 @@ utst_int.xdr.c: utst_int.xg
${RXGEN} -A -c -o $@ ${srcdir}/utst_int.xg ${RXGEN} -A -c -o $@ ${srcdir}/utst_int.xg
utst_int.h: utst_int.xg utst_int.h: utst_int.xg
${RXGEN} -A -h -o $@ ${srcdir}/utst_int.xg ${RXGEN} -A -h -u -o $@ ${srcdir}/utst_int.xg
utst_int.cs.c: utst_int.h utst_int.cs.c: utst_int.h
utst_int.ss.c: utst_int.h utst_int.ss.c: utst_int.h

View File

@ -14,6 +14,10 @@ RCSID
("$Header$"); ("$Header$");
#include <sys/types.h> #include <sys/types.h>
#include <string.h>
#include <stdarg.h>
#include <errno.h>
#ifdef AFS_NT40_ENV #ifdef AFS_NT40_ENV
#include <winsock2.h> #include <winsock2.h>
#include <time.h> #include <time.h>
@ -24,9 +28,8 @@ RCSID
#include <netinet/in.h> #include <netinet/in.h>
#include <netdb.h> #include <netdb.h>
#endif #endif
#include <errno.h>
#include <lock.h> #include <lock.h>
#include <string.h>
#include <rx/xdr.h> #include <rx/xdr.h>
#include <rx/rx.h> #include <rx/rx.h>
#include <rx/rx_multi.h> #include <rx/rx_multi.h>
@ -43,16 +46,23 @@ RCSID
/*! \name statics used to determine if we're the sync site */ /*! \name statics used to determine if we're the sync site */
static afs_int32 syncSiteUntil = 0; /*!< valid only if amSyncSite */ static afs_int32 syncSiteUntil = 0; /*!< valid only if amSyncSite */
int ubik_amSyncSite = 0; /*!< flag telling if I'm sync site */ int ubik_amSyncSite = 0; /*!< flag telling if I'm sync site */
static nServers; /*!< total number of servers */ static int nServers; /*!< total number of servers */
static char amIMagic = 0; /*!< is this host the magic host */ static char amIMagic = 0; /*!< is this host the magic host */
char amIClone = 0; /*!< is this a clone which doesn't vote */ char amIClone = 0; /*!< is this a clone which doesn't vote */
static char ubik_singleServer = 0; static char ubik_singleServer = 0;
/*\}*/ /*\}*/
int (*ubik_CRXSecurityProc) (); int (*ubik_CRXSecurityProc) (void *rock, struct rx_securityClass **,
char *ubik_CRXSecurityRock; afs_int32 *);
void *ubik_CRXSecurityRock;
afs_int32 ubikSecIndex; afs_int32 ubikSecIndex;
struct rx_securityClass *ubikSecClass; struct rx_securityClass *ubikSecClass;
static verifyInterfaceAddress(); static int ubeacon_InitServerListCommon(afs_int32 ame,
struct afsconf_cell *info,
char clones[],
afs_int32 aservers[]);
static int verifyInterfaceAddress(afs_uint32 *ame, struct afsconf_cell *info,
afs_uint32 aservers[]);
static int updateUbikNetworkAddress(afs_uint32 ubik_host[UBIK_MAX_INTERFACE_ADDR]);
/*! \file /*! \file
@ -80,8 +90,7 @@ static verifyInterfaceAddress();
/*! \brief procedure called from debug rpc call to get this module's state for debugging */ /*! \brief procedure called from debug rpc call to get this module's state for debugging */
void void
ubeacon_Debug(aparm) ubeacon_Debug(register struct ubik_debug *aparm)
register struct ubik_debug *aparm;
{ {
/* fill in beacon's state fields in the ubik_debug structure */ /* fill in beacon's state fields in the ubik_debug structure */
aparm->syncSiteUntil = syncSiteUntil; aparm->syncSiteUntil = syncSiteUntil;
@ -104,7 +113,8 @@ ubeacon_Debug(aparm)
* \return 1 if local site is the sync site * \return 1 if local site is the sync site
* \return 0 if sync site is elsewhere * \return 0 if sync site is elsewhere
*/ */
ubeacon_AmSyncSite() int
ubeacon_AmSyncSite(void)
{ {
register afs_int32 now; register afs_int32 now;
register afs_int32 rcode; register afs_int32 rcode;
@ -136,10 +146,9 @@ ubeacon_AmSyncSite()
/*! /*!
* \see ubeacon_InitServerListCommon() * \see ubeacon_InitServerListCommon()
*/ */
ubeacon_InitServerListByInfo(ame, info, clones) int
afs_int32 ame; ubeacon_InitServerListByInfo(afs_int32 ame, struct afsconf_cell *info,
struct afsconf_cell *info; char clones[])
char clones[];
{ {
afs_int32 code; afs_int32 code;
@ -153,9 +162,7 @@ ubeacon_InitServerListByInfo(ame, info, clones)
* *
* \see ubeacon_InitServerListCommon() * \see ubeacon_InitServerListCommon()
*/ */
ubeacon_InitServerList(ame, aservers) ubeacon_InitServerList(afs_int32 ame, register afs_int32 aservers[])
afs_int32 ame;
register afs_int32 aservers[];
{ {
afs_int32 code; afs_int32 code;
@ -171,8 +178,8 @@ ubeacon_InitServerList(ame, aservers)
* \param ame "address of me" * \param ame "address of me"
* \param aservers list of other servers * \param aservers list of other servers
* *
* called only at initialization to set up the list of servers to contact for votes. Just creates * called only at initialization to set up the list of servers to
* the server structure. * contact for votes. Just creates the server structure.
* *
* The "magic" host is the one with the lowest internet address. It is * The "magic" host is the one with the lowest internet address. It is
* magic because its vote counts epsilon more than the others. This acts * magic because its vote counts epsilon more than the others. This acts
@ -182,18 +189,16 @@ ubeacon_InitServerList(ame, aservers)
* site system, we'd be out of business. * site system, we'd be out of business.
* *
* \note There are two connections in every server structure, one for * \note There are two connections in every server structure, one for
* vote calls (which must always go through quickly) and one for database operations, which * vote calls (which must always go through quickly) and one for database
* are subject to waiting for locks. If we used only one, the votes would sometimes get * operations, which are subject to waiting for locks. If we used only
* held up behind database operations, and the sync site guarantees would timeout * one, the votes would sometimes get held up behind database operations,
* even though the host would be up for communication. * and the sync site guarantees would timeout even though the host would be
* up for communication.
* *
* \see ubeacon_InitServerList(), ubeacon_InitServerListByInfo() * \see ubeacon_InitServerList(), ubeacon_InitServerListByInfo()
*/ */
ubeacon_InitServerListCommon(ame, info, clones, aservers) ubeacon_InitServerListCommon(afs_int32 ame, struct afsconf_cell *info,
afs_int32 ame; char clones[], register afs_int32 aservers[])
struct afsconf_cell *info;
char clones[];
register afs_int32 aservers[];
{ {
register struct ubik_server *ts; register struct ubik_server *ts;
afs_int32 me = -1; afs_int32 me = -1;
@ -511,11 +516,8 @@ ubeacon_Interact(void *dummy)
* \return 0 on success, non-zero on failure * \return 0 on success, non-zero on failure
*/ */
static static
verifyInterfaceAddress(ame, info, aservers) verifyInterfaceAddress(afs_uint32 *ame, struct afsconf_cell *info,
afs_uint32 *ame; /* one of my interface addr in net byte order */ afs_uint32 aservers[]) {
struct afsconf_cell *info;
afs_uint32 aservers[]; /* list of all possible server addresses */
{
afs_uint32 myAddr[UBIK_MAX_INTERFACE_ADDR], *servList, tmpAddr; afs_uint32 myAddr[UBIK_MAX_INTERFACE_ADDR], *servList, tmpAddr;
afs_uint32 myAddr2[UBIK_MAX_INTERFACE_ADDR]; afs_uint32 myAddr2[UBIK_MAX_INTERFACE_ADDR];
int tcount, count, found, i, j, totalServers, start, end, usednetfiles = int tcount, count, found, i, j, totalServers, start, end, usednetfiles =
@ -658,8 +660,7 @@ verifyInterfaceAddress(ame, info, aservers)
* \return 0 on success, non-zero on failure * \return 0 on success, non-zero on failure
*/ */
int int
updateUbikNetworkAddress(ubik_host) updateUbikNetworkAddress(afs_uint32 ubik_host[UBIK_MAX_INTERFACE_ADDR])
afs_uint32 ubik_host[UBIK_MAX_INTERFACE_ADDR];
{ {
int j, count, code = 0; int j, count, code = 0;
UbikInterfaceAddr inAddr, outAddr; UbikInterfaceAddr inAddr, outAddr;

View File

@ -14,14 +14,17 @@ RCSID
("$Header$"); ("$Header$");
#include <sys/types.h> #include <sys/types.h>
#include <string.h>
#include <stdarg.h>
#include <errno.h>
#ifdef AFS_NT40_ENV #ifdef AFS_NT40_ENV
#include <winsock2.h> #include <winsock2.h>
#else #else
#include <sys/file.h> #include <sys/file.h>
#include <netinet/in.h> #include <netinet/in.h>
#endif #endif
#include <errno.h>
#include <string.h>
#include <lock.h> #include <lock.h>
#include <rx/xdr.h> #include <rx/xdr.h>
@ -55,10 +58,10 @@ static int calls = 0, ios = 0, lastb = 0;
static char *BufferData; static char *BufferData;
static struct buffer *newslot(struct ubik_dbase *adbase, afs_int32 afid, static struct buffer *newslot(struct ubik_dbase *adbase, afs_int32 afid,
afs_int32 apage); afs_int32 apage);
static initd = 0; static int initd = 0;
#define BADFID 0xffffffff #define BADFID 0xffffffff
static DTrunc(struct ubik_dbase *dbase, afs_int32 fid, afs_int32 length); static int DTrunc(struct ubik_dbase *dbase, afs_int32 fid, afs_int32 length);
static struct ubik_trunc *freeTruncList = 0; static struct ubik_trunc *freeTruncList = 0;
@ -83,7 +86,7 @@ unthread(struct ubik_trans *atrans)
/*! /*!
* \brief some debugging assistance * \brief some debugging assistance
*/ */
int void
udisk_Debug(struct ubik_debug *aparm) udisk_Debug(struct ubik_debug *aparm)
{ {
struct buffer *tb; struct buffer *tb;
@ -101,7 +104,6 @@ udisk_Debug(struct ubik_debug *aparm)
aparm->writeLockedPages++; aparm->writeLockedPages++;
} }
} }
return 0;
} }
/*! /*!
@ -212,7 +214,7 @@ udisk_LogTruncate(struct ubik_dbase *adbase, afs_int32 afile,
* \brief Write some data to the log, never syncing. * \brief Write some data to the log, never syncing.
*/ */
int int
udisk_LogWriteData(struct ubik_dbase *adbase, afs_int32 afile, char *abuffer, udisk_LogWriteData(struct ubik_dbase *adbase, afs_int32 afile, void *abuffer,
afs_int32 apos, afs_int32 alen) afs_int32 apos, afs_int32 alen)
{ {
struct ubik_stat ustat; struct ubik_stat ustat;
@ -441,7 +443,7 @@ static int
DoTruncs(struct ubik_trans *atrans) DoTruncs(struct ubik_trans *atrans)
{ {
struct ubik_trunc *tt, *nt; struct ubik_trunc *tt, *nt;
int (*tproc) (); int (*tproc) (struct ubik_dbase *, afs_int32, afs_int32);
afs_int32 rcode = 0, code; afs_int32 rcode = 0, code;
tproc = atrans->dbase->truncate; tproc = atrans->dbase->truncate;
@ -658,7 +660,7 @@ DNew(struct ubik_dbase *dbase, afs_int32 fid, int page)
* \brief Read data from database. * \brief Read data from database.
*/ */
int int
udisk_read(struct ubik_trans *atrans, afs_int32 afile, char *abuffer, udisk_read(struct ubik_trans *atrans, afs_int32 afile, void *abuffer,
afs_int32 apos, afs_int32 alen) afs_int32 apos, afs_int32 alen)
{ {
char *bp; char *bp;
@ -679,7 +681,7 @@ udisk_read(struct ubik_trans *atrans, afs_int32 afile, char *abuffer,
if (len > alen) if (len > alen)
len = alen; len = alen;
memcpy(abuffer, bp + offset, len); memcpy(abuffer, bp + offset, len);
abuffer += len; abuffer = (char *)abuffer + len;
apos += len; apos += len;
alen -= len; alen -= len;
totalLen += len; totalLen += len;
@ -726,7 +728,7 @@ udisk_truncate(struct ubik_trans *atrans, afs_int32 afile, afs_int32 alength)
* \brief Write data to database, using logs. * \brief Write data to database, using logs.
*/ */
int int
udisk_write(struct ubik_trans *atrans, afs_int32 afile, char *abuffer, udisk_write(struct ubik_trans *atrans, afs_int32 afile, void *abuffer,
afs_int32 apos, afs_int32 alen) afs_int32 apos, afs_int32 alen)
{ {
char *bp; char *bp;
@ -770,7 +772,7 @@ udisk_write(struct ubik_trans *atrans, afs_int32 afile, char *abuffer,
if (len > alen) if (len > alen)
len = alen; len = alen;
memcpy(bp + offset, abuffer, len); memcpy(bp + offset, abuffer, len);
abuffer += len; abuffer = (char *)abuffer + len;
apos += len; apos += len;
alen -= len; alen -= len;
totalLen += len; totalLen += len;
@ -847,8 +849,8 @@ udisk_commit(struct ubik_trans *atrans)
* marked down and when we detect it is up again, we will * marked down and when we detect it is up again, we will
* send the entire database to it. * send the entire database to it.
*/ */
ContactQuorum(DISK_SetVersion, atrans, 1 /*CStampVersion */ , ContactQuorum_DISK_SetVersion( atrans, 1 /*CStampVersion */ ,
&oldversion, &newversion); &oldversion, &newversion);
urecovery_state |= UBIK_RECLABELDB; urecovery_state |= UBIK_RECLABELDB;
} }
@ -952,7 +954,7 @@ udisk_end(struct ubik_trans *atrans)
if (atrans->flags & TRSETLOCK) { if (atrans->flags & TRSETLOCK) {
atrans->flags |= TRSTALE; atrans->flags |= TRSTALE;
ulock_relLock(atrans); ulock_relLock(atrans);
return; return UINTERNAL;
} }
#endif /* UBIK_PAUSE */ #endif /* UBIK_PAUSE */
if (!(atrans->flags & TRDONE)) if (!(atrans->flags & TRDONE))

View File

@ -14,10 +14,13 @@ RCSID
("$Header$"); ("$Header$");
#include <sys/types.h> #include <sys/types.h>
#include <stdarg.h>
#include <errno.h>
#ifndef AFS_NT40_ENV #ifndef AFS_NT40_ENV
#include <sys/file.h> #include <sys/file.h>
#endif #endif
#include <errno.h>
#include <lock.h> #include <lock.h>
#include <rx/xdr.h> #include <rx/xdr.h>
@ -62,9 +65,8 @@ int rwlockinit = 1;
* *
* \note The #DBHOLD lock must be held. * \note The #DBHOLD lock must be held.
*/ */
ulock_getLock(atrans, atype, await) extern int
struct ubik_trans *atrans; ulock_getLock(struct ubik_trans *atrans, int atype, int await)
int atype, await;
{ {
struct ubik_dbase *dbase = atrans->dbase; struct ubik_dbase *dbase = atrans->dbase;
@ -151,8 +153,7 @@ ulock_getLock(atrans, atype, await)
* \brief Release the transaction lock. * \brief Release the transaction lock.
*/ */
void void
ulock_relLock(atrans) ulock_relLock(struct ubik_trans *atrans)
struct ubik_trans *atrans;
{ {
if (rwlockinit) if (rwlockinit)
return; return;
@ -175,8 +176,8 @@ ulock_relLock(atrans)
/*! /*!
* \brief debugging hooks * \brief debugging hooks
*/ */
ulock_Debug(aparm) void
struct ubik_debug *aparm; ulock_Debug(struct ubik_debug *aparm)
{ {
if (rwlockinit) { if (rwlockinit) {
aparm->anyReadLocks = 0; aparm->anyReadLocks = 0;
@ -185,5 +186,4 @@ ulock_Debug(aparm)
aparm->anyReadLocks = rwlock.readers_reading; aparm->anyReadLocks = rwlock.readers_reading;
aparm->anyWriteLocks = ((rwlock.excl_locked == WRITE_LOCK) ? 1 : 0); aparm->anyWriteLocks = ((rwlock.excl_locked == WRITE_LOCK) ? 1 : 0);
} }
return 0;
} }

View File

@ -14,6 +14,10 @@ RCSID
("$Header$"); ("$Header$");
#include <sys/types.h> #include <sys/types.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#ifdef AFS_NT40_ENV #ifdef AFS_NT40_ENV
#include <winsock2.h> #include <winsock2.h>
#include <io.h> #include <io.h>
@ -32,8 +36,7 @@ RCSID
#endif #endif
#include <lock.h> #include <lock.h>
#include <errno.h> #include <afs/afsutil.h>
#include <string.h>
#define UBIK_INTERNALS 1 #define UBIK_INTERNALS 1
#include "ubik.h" #include "ubik.h"
@ -60,7 +63,6 @@ static char pbuffer[1024];
static int static int
uphys_open(register struct ubik_dbase *adbase, afs_int32 afid) uphys_open(register struct ubik_dbase *adbase, afs_int32 afid)
{ {
char temp[20];
register int fd; register int fd;
static int initd; static int initd;
register int i; register int i;
@ -188,7 +190,7 @@ uphys_stat(struct ubik_dbase *adbase, afs_int32 afid, struct ubik_stat *astat)
int int
uphys_read(register struct ubik_dbase *adbase, afs_int32 afile, uphys_read(register struct ubik_dbase *adbase, afs_int32 afile,
register char *abuffer, afs_int32 apos, afs_int32 alength) register void *abuffer, afs_int32 apos, afs_int32 alength)
{ {
register int fd; register int fd;
register afs_int32 code; register afs_int32 code;
@ -208,7 +210,7 @@ uphys_read(register struct ubik_dbase *adbase, afs_int32 afile,
int int
uphys_write(register struct ubik_dbase *adbase, afs_int32 afile, uphys_write(register struct ubik_dbase *adbase, afs_int32 afile,
register char *abuffer, afs_int32 apos, afs_int32 alength) register void *abuffer, afs_int32 apos, afs_int32 alength)
{ {
register int fd; register int fd;
register afs_int32 code; register afs_int32 code;

View File

@ -14,6 +14,11 @@ RCSID
("$Header$"); ("$Header$");
#include <sys/types.h> #include <sys/types.h>
#include <string.h>
#include <stdarg.h>
#include <errno.h>
#include <assert.h>
#ifdef AFS_NT40_ENV #ifdef AFS_NT40_ENV
#include <winsock2.h> #include <winsock2.h>
#include <time.h> #include <time.h>
@ -23,12 +28,10 @@ RCSID
#include <netinet/in.h> #include <netinet/in.h>
#include <sys/time.h> #include <sys/time.h>
#endif #endif
#include <assert.h>
#include <lock.h> #include <lock.h>
#include <string.h>
#include <rx/xdr.h> #include <rx/xdr.h>
#include <rx/rx.h> #include <rx/rx.h>
#include <errno.h>
#include <afs/afsutil.h> #include <afs/afsutil.h>
#define UBIK_INTERNALS #define UBIK_INTERNALS
@ -458,7 +461,7 @@ urecovery_Interact(void *dummy)
#ifndef OLD_URECOVERY #ifndef OLD_URECOVERY
char pbuffer[1028]; char pbuffer[1028];
int flen, fd = -1; int flen, fd = -1;
afs_int32 epoch, pass; afs_int32 pass;
#endif #endif
/* otherwise, begin interaction */ /* otherwise, begin interaction */

View File

@ -14,6 +14,9 @@ RCSID
("$Header$"); ("$Header$");
#include <sys/types.h> #include <sys/types.h>
#include <string.h>
#include <stdarg.h>
#ifdef AFS_NT40_ENV #ifdef AFS_NT40_ENV
#include <winsock2.h> #include <winsock2.h>
#include <fcntl.h> #include <fcntl.h>
@ -21,7 +24,7 @@ RCSID
#include <sys/file.h> #include <sys/file.h>
#include <netinet/in.h> #include <netinet/in.h>
#endif #endif
#include <string.h>
#include <lock.h> #include <lock.h>
#include <rx/xdr.h> #include <rx/xdr.h>
#include <rx/rx.h> #include <rx/rx.h>
@ -31,9 +34,11 @@ RCSID
#define UBIK_INTERNALS #define UBIK_INTERNALS
#include "ubik.h" #include "ubik.h"
#include "ubik_int.h" #include "ubik_int.h"
int (*ubik_CheckRXSecurityProc) ();
char *ubik_CheckRXSecurityRock; int (*ubik_CheckRXSecurityProc) (void *, struct rx_call *);
void printServerInfo(); void *ubik_CheckRXSecurityRock;
static void printServerInfo(void);
/*! \file /*! \file
* routines for handling requests remotely-submitted by the sync site. These are * routines for handling requests remotely-submitted by the sync site. These are
@ -43,9 +48,8 @@ void printServerInfo();
struct ubik_trans *ubik_currentTrans = 0; struct ubik_trans *ubik_currentTrans = 0;
int
ubik_CheckAuth(acall) ubik_CheckAuth(register struct rx_call *acall)
register struct rx_call *acall;
{ {
register afs_int32 code; register afs_int32 code;
if (ubik_CheckRXSecurityProc) { if (ubik_CheckRXSecurityProc) {
@ -60,9 +64,7 @@ ubik_CheckAuth(acall)
* sync site is executing a write transaction. * sync site is executing a write transaction.
*/ */
afs_int32 afs_int32
SDISK_Begin(rxcall, atid) SDISK_Begin(register struct rx_call *rxcall, struct ubik_tid *atid)
register struct rx_call *rxcall;
struct ubik_tid *atid;
{ {
register afs_int32 code; register afs_int32 code;
@ -94,9 +96,7 @@ SDISK_Begin(rxcall, atid)
afs_int32 afs_int32
SDISK_Commit(rxcall, atid) SDISK_Commit(register struct rx_call *rxcall, struct ubik_tid *atid)
register struct rx_call *rxcall;
struct ubik_tid *atid;
{ {
register afs_int32 code; register afs_int32 code;
register struct ubik_dbase *dbase; register struct ubik_dbase *dbase;
@ -133,9 +133,7 @@ SDISK_Commit(rxcall, atid)
} }
afs_int32 afs_int32
SDISK_ReleaseLocks(rxcall, atid) SDISK_ReleaseLocks(register struct rx_call *rxcall, struct ubik_tid *atid)
register struct rx_call *rxcall;
struct ubik_tid *atid;
{ {
register struct ubik_dbase *dbase; register struct ubik_dbase *dbase;
register afs_int32 code; register afs_int32 code;
@ -174,9 +172,7 @@ SDISK_ReleaseLocks(rxcall, atid)
} }
afs_int32 afs_int32
SDISK_Abort(rxcall, atid) SDISK_Abort(register struct rx_call *rxcall, struct ubik_tid *atid)
register struct rx_call *rxcall;
struct ubik_tid *atid;
{ {
register afs_int32 code; register afs_int32 code;
register struct ubik_dbase *dbase; register struct ubik_dbase *dbase;
@ -215,12 +211,11 @@ SDISK_Abort(rxcall, atid)
return code; return code;
} }
/* apos and alen are not used */
afs_int32 afs_int32
SDISK_Lock(rxcall, atid, afile, apos, alen, atype) SDISK_Lock(register struct rx_call *rxcall, struct ubik_tid *atid,
register struct rx_call *rxcall; afs_int32 afile, afs_int32 apos, afs_int32 alen, afs_int32 atype)
struct ubik_tid *atid; {
afs_int32 afile, apos, alen, atype; /* apos and alen are not used */
{
register afs_int32 code; register afs_int32 code;
register struct ubik_dbase *dbase; register struct ubik_dbase *dbase;
struct ubik_trans *ubik_thisTrans; struct ubik_trans *ubik_thisTrans;
@ -266,11 +261,8 @@ SDISK_Lock(rxcall, atid, afile, apos, alen, atype)
* \brief Write a vector of data * \brief Write a vector of data
*/ */
afs_int32 afs_int32
SDISK_WriteV(rxcall, atid, io_vector, io_buffer) SDISK_WriteV(register struct rx_call *rxcall, struct ubik_tid *atid,
register struct rx_call *rxcall; iovec_wrt *io_vector, iovec_buf *io_buffer)
struct ubik_tid *atid;
iovec_wrt *io_vector;
iovec_buf *io_buffer;
{ {
afs_int32 code, i, offset; afs_int32 code, i, offset;
struct ubik_dbase *dbase; struct ubik_dbase *dbase;
@ -318,11 +310,8 @@ SDISK_WriteV(rxcall, atid, io_vector, io_buffer)
} }
afs_int32 afs_int32
SDISK_Write(rxcall, atid, afile, apos, adata) SDISK_Write(register struct rx_call *rxcall, struct ubik_tid *atid,
register struct rx_call *rxcall; afs_int32 afile, afs_int32 apos, register bulkdata *adata)
struct ubik_tid *atid;
afs_int32 afile, apos;
register bulkdata *adata;
{ {
register afs_int32 code; register afs_int32 code;
register struct ubik_dbase *dbase; register struct ubik_dbase *dbase;
@ -353,11 +342,8 @@ SDISK_Write(rxcall, atid, afile, apos, adata)
} }
afs_int32 afs_int32
SDISK_Truncate(rxcall, atid, afile, alen) SDISK_Truncate(register struct rx_call *rxcall, struct ubik_tid *atid,
register struct rx_call *rxcall; afs_int32 afile, afs_int32 alen)
struct ubik_tid *atid;
afs_int32 afile;
afs_int32 alen;
{ {
register afs_int32 code; register afs_int32 code;
register struct ubik_dbase *dbase; register struct ubik_dbase *dbase;
@ -386,9 +372,8 @@ SDISK_Truncate(rxcall, atid, afile, alen)
} }
afs_int32 afs_int32
SDISK_GetVersion(rxcall, aversion) SDISK_GetVersion(register struct rx_call *rxcall,
register struct rx_call *rxcall; register struct ubik_version *aversion)
register struct ubik_version *aversion;
{ {
register afs_int32 code; register afs_int32 code;
@ -424,10 +409,8 @@ SDISK_GetVersion(rxcall, aversion)
} }
afs_int32 afs_int32
SDISK_GetFile(rxcall, file, version) SDISK_GetFile(register struct rx_call *rxcall, register afs_int32 file,
register struct rx_call *rxcall; struct ubik_version *version)
register afs_int32 file;
struct ubik_version *version;
{ {
register afs_int32 code; register afs_int32 code;
register struct ubik_dbase *dbase; register struct ubik_dbase *dbase;
@ -485,11 +468,8 @@ SDISK_GetFile(rxcall, file, version)
} }
afs_int32 afs_int32
SDISK_SendFile(rxcall, file, length, avers) SDISK_SendFile(register struct rx_call *rxcall, afs_int32 file,
register struct rx_call *rxcall; afs_int32 length, struct ubik_version *avers)
afs_int32 file;
afs_int32 length;
struct ubik_version *avers;
{ {
register afs_int32 code; register afs_int32 code;
struct ubik_dbase *dbase = NULL; struct ubik_dbase *dbase = NULL;
@ -658,8 +638,7 @@ SDISK_SendFile(rxcall, file, length, avers)
afs_int32 afs_int32
SDISK_Probe(rxcall) SDISK_Probe(register struct rx_call *rxcall)
register struct rx_call *rxcall;
{ {
return 0; return 0;
} }
@ -671,9 +650,9 @@ SDISK_Probe(rxcall)
* \return zero on success, else 1. * \return zero on success, else 1.
*/ */
afs_int32 afs_int32
SDISK_UpdateInterfaceAddr(rxcall, inAddr, outAddr) SDISK_UpdateInterfaceAddr(register struct rx_call *rxcall,
register struct rx_call *rxcall; UbikInterfaceAddr *inAddr,
UbikInterfaceAddr *inAddr, *outAddr; UbikInterfaceAddr *outAddr)
{ {
struct ubik_server *ts, *tmp; struct ubik_server *ts, *tmp;
afs_uint32 remoteAddr; /* in net byte order */ afs_uint32 remoteAddr; /* in net byte order */
@ -735,8 +714,8 @@ SDISK_UpdateInterfaceAddr(rxcall, inAddr, outAddr)
return 0; return 0;
} }
void static void
printServerInfo() printServerInfo(void)
{ {
struct ubik_server *ts; struct ubik_server *ts;
int i, j = 1; int i, j = 1;
@ -751,11 +730,9 @@ printServerInfo()
} }
afs_int32 afs_int32
SDISK_SetVersion(rxcall, atid, oldversionp, newversionp) SDISK_SetVersion(struct rx_call *rxcall, struct ubik_tid *atid,
struct rx_call *rxcall; struct ubik_version *oldversionp,
struct ubik_tid *atid; struct ubik_version *newversionp)
struct ubik_version *oldversionp;
struct ubik_version *newversionp;
{ {
afs_int32 code = 0; afs_int32 code = 0;
struct ubik_dbase *dbase; struct ubik_dbase *dbase;

View File

@ -14,6 +14,10 @@ RCSID
("$Header$"); ("$Header$");
#include <sys/types.h> #include <sys/types.h>
#include <string.h>
#include <stdarg.h>
#include <time.h>
#ifdef AFS_NT40_ENV #ifdef AFS_NT40_ENV
#include <winsock2.h> #include <winsock2.h>
#else #else
@ -21,9 +25,8 @@ RCSID
#include <netinet/in.h> #include <netinet/in.h>
#include <sys/param.h> #include <sys/param.h>
#endif #endif
#include <time.h>
#include <lock.h> #include <lock.h>
#include <string.h>
#include <rx/xdr.h> #include <rx/xdr.h>
#include <rx/rx.h> #include <rx/rx.h>
#include <afs/cellconfig.h> #include <afs/cellconfig.h>
@ -80,12 +83,13 @@ struct ubik_stats ubik_stats;
afs_uint32 ubik_host[UBIK_MAX_INTERFACE_ADDR]; afs_uint32 ubik_host[UBIK_MAX_INTERFACE_ADDR];
afs_int32 ubik_epochTime = 0; afs_int32 ubik_epochTime = 0;
afs_int32 urecovery_state = 0; afs_int32 urecovery_state = 0;
int (*ubik_SRXSecurityProc) (); int (*ubik_SRXSecurityProc) (void *, struct rx_securityClass **, afs_int32 *);
char *ubik_SRXSecurityRock; void *ubik_SRXSecurityRock;
struct ubik_server *ubik_servers; struct ubik_server *ubik_servers;
short ubik_callPortal; short ubik_callPortal;
static int BeginTrans(); static int BeginTrans(register struct ubik_dbase *dbase, afs_int32 transMode,
struct ubik_trans **transPtr, int readAny);
struct rx_securityClass *ubik_sc[3]; struct rx_securityClass *ubik_sc[3];
@ -97,20 +101,17 @@ struct rx_securityClass *ubik_sc[3];
* \return otherwise mark failing server as down and return #UERROR * \return otherwise mark failing server as down and return #UERROR
* *
* \note If any server misses an update, we must wait #BIGTIME seconds before * \note If any server misses an update, we must wait #BIGTIME seconds before
* allowing the transaction to commit, to ensure that the missing and possibly still * allowing the transaction to commit, to ensure that the missing and
* functioning server times out and stops handing out old data. This is done in the commit * possibly still functioning server times out and stops handing out old
* code, where we wait for a server marked down to have stayed down for #BIGTIME seconds * data. This is done in the commit code, where we wait for a server marked
* before we allow a transaction to commit. A server that fails but comes back up won't give * down to have stayed down for #BIGTIME seconds before we allow a transaction
* out old data because it is sent the sync count along with the beacon message that * to commit. A server that fails but comes back up won't give out old data
* because it is sent the sync count along with the beacon message that
* marks it as \b really up (\p beaconSinceDown). * marks it as \b really up (\p beaconSinceDown).
*/ */
afs_int32 afs_int32
ContactQuorum(aproc, atrans, aflags, aparm0, aparm1, aparm2, aparm3, aparm4, ContactQuorum_NoArguments(afs_int32 (*proc)(struct rx_connection *, ubik_tid *),
aparm5) register struct ubik_trans *atrans, int aflags)
int (*aproc) ();
int aflags;
register struct ubik_trans *atrans;
long aparm0, aparm1, aparm2, aparm3, aparm4, aparm5;
{ {
register struct ubik_server *ts; register struct ubik_server *ts;
register afs_int32 code; register afs_int32 code;
@ -124,25 +125,176 @@ ContactQuorum(aproc, atrans, aflags, aparm0, aparm1, aparm2, aparm3, aparm4,
ts->currentDB = 0; /* db is no longer current; we just missed an update */ ts->currentDB = 0; /* db is no longer current; we just missed an update */
continue; /* not up-to-date, don't bother */ continue; /* not up-to-date, don't bother */
} }
code = code = (*proc)(ts->disk_rxcid, &atrans->tid);
(*aproc) (ts->disk_rxcid, &atrans->tid, aparm0, aparm1, aparm2, if (code) { /* failure */
aparm3, aparm4, aparm5); rcode = code;
if ((aproc == DISK_WriteV) && (code <= -450) && (code > -500)) { ts->up = 0; /* mark as down now; beacons will no longer be sent */
ts->currentDB = 0;
ts->beaconSinceDown = 0;
urecovery_LostServer(); /* tell recovery to try to resend dbase later */
} else { /* success */
if (!ts->isClone)
okcalls++; /* count up how many worked */
if (aflags & CStampVersion) {
ts->version = atrans->dbase->version;
}
}
}
/* return 0 if we successfully contacted a quorum, otherwise return error code. We don't have to contact ourselves (that was done locally) */
if (okcalls + 1 >= ubik_quorum)
return 0;
else
return rcode;
}
afs_int32
ContactQuorum_DISK_Lock(register struct ubik_trans *atrans, int aflags,afs_int32 file,
afs_int32 position, afs_int32 length, afs_int32 type)
{
register struct ubik_server *ts;
register afs_int32 code;
afs_int32 rcode, okcalls;
rcode = 0;
okcalls = 0;
for (ts = ubik_servers; ts; ts = ts->next) {
/* for each server */
if (!ts->up || !ts->currentDB) {
ts->currentDB = 0; /* db is no longer current; we just missed an update */
continue; /* not up-to-date, don't bother */
}
code = DISK_Lock(ts->disk_rxcid, &atrans->tid, file, position, length,
type);
if (code) { /* failure */
rcode = code;
ts->up = 0; /* mark as down now; beacons will no longer be sent */
ts->currentDB = 0;
ts->beaconSinceDown = 0;
urecovery_LostServer(); /* tell recovery to try to resend dbase later */
} else { /* success */
if (!ts->isClone)
okcalls++; /* count up how many worked */
if (aflags & CStampVersion) {
ts->version = atrans->dbase->version;
}
}
}
/* return 0 if we successfully contacted a quorum, otherwise return error code. We don't have to contact ourselves (that was done locally) */
if (okcalls + 1 >= ubik_quorum)
return 0;
else
return rcode;
}
afs_int32
ContactQuorum_DISK_Write(register struct ubik_trans *atrans, int aflags,
afs_int32 file, afs_int32 position, bulkdata *data)
{
register struct ubik_server *ts;
register afs_int32 code;
afs_int32 rcode, okcalls;
rcode = 0;
okcalls = 0;
for (ts = ubik_servers; ts; ts = ts->next) {
/* for each server */
if (!ts->up || !ts->currentDB) {
ts->currentDB = 0; /* db is no longer current; we just missed an update */
continue; /* not up-to-date, don't bother */
}
code = DISK_Write(ts->disk_rxcid, &atrans->tid, file, position, data);
if (code) { /* failure */
rcode = code;
ts->up = 0; /* mark as down now; beacons will no longer be sent */
ts->currentDB = 0;
ts->beaconSinceDown = 0;
urecovery_LostServer(); /* tell recovery to try to resend dbase later */
} else { /* success */
if (!ts->isClone)
okcalls++; /* count up how many worked */
if (aflags & CStampVersion) {
ts->version = atrans->dbase->version;
}
}
}
/* return 0 if we successfully contacted a quorum, otherwise return error code. We don't have to contact ourselves (that was done locally) */
if (okcalls + 1 >= ubik_quorum)
return 0;
else
return rcode;
}
afs_int32
ContactQuorum_DISK_Truncate(register struct ubik_trans *atrans, int aflags,
afs_int32 file, afs_int32 length)
{
register struct ubik_server *ts;
register afs_int32 code;
afs_int32 rcode, okcalls;
rcode = 0;
okcalls = 0;
for (ts = ubik_servers; ts; ts = ts->next) {
/* for each server */
if (!ts->up || !ts->currentDB) {
ts->currentDB = 0; /* db is no longer current; we just missed an update */
continue; /* not up-to-date, don't bother */
}
code = DISK_Truncate(ts->disk_rxcid, &atrans->tid, file, length);
if (code) { /* failure */
rcode = code;
ts->up = 0; /* mark as down now; beacons will no longer be sent */
ts->currentDB = 0;
ts->beaconSinceDown = 0;
urecovery_LostServer(); /* tell recovery to try to resend dbase later */
} else { /* success */
if (!ts->isClone)
okcalls++; /* count up how many worked */
if (aflags & CStampVersion) {
ts->version = atrans->dbase->version;
}
}
}
/* return 0 if we successfully contacted a quorum, otherwise return error code. We don't have to contact ourselves (that was done locally) */
if (okcalls + 1 >= ubik_quorum)
return 0;
else
return rcode;
}
afs_int32
ContactQuorum_DISK_WriteV(register struct ubik_trans *atrans, int aflags,
iovec_wrt * io_vector, iovec_buf *io_buffer)
{
register struct ubik_server *ts;
register afs_int32 code;
afs_int32 rcode, okcalls;
rcode = 0;
okcalls = 0;
for (ts = ubik_servers; ts; ts = ts->next) {
/* for each server */
if (!ts->up || !ts->currentDB) {
ts->currentDB = 0; /* db is no longer current; we just missed an update */
continue; /* not up-to-date, don't bother */
}
code = DISK_WriteV(ts->disk_rxcid, &atrans->tid, io_vector, io_buffer);
if ((code <= -450) && (code > -500)) {
/* An RPC interface mismatch (as defined in comerr/error_msg.c). /* An RPC interface mismatch (as defined in comerr/error_msg.c).
* Un-bulk the entries and do individual DISK_Write calls * Un-bulk the entries and do individual DISK_Write calls
* instead of DISK_WriteV. * instead of DISK_WriteV.
*/ */
iovec_wrt *iovec_infoP = (iovec_wrt *) aparm0;
iovec_buf *iovec_dataP = (iovec_buf *) aparm1;
struct ubik_iovec *iovec = struct ubik_iovec *iovec =
(struct ubik_iovec *)iovec_infoP->iovec_wrt_val; (struct ubik_iovec *)io_vector->iovec_wrt_val;
char *iobuf = (char *)iovec_dataP->iovec_buf_val; char *iobuf = (char *)io_buffer->iovec_buf_val;
bulkdata tcbs; bulkdata tcbs;
afs_int32 i, offset; afs_int32 i, offset;
for (i = 0, offset = 0; i < iovec_infoP->iovec_wrt_len; i++) { for (i = 0, offset = 0; i < io_vector->iovec_wrt_len; i++) {
/* Sanity check for going off end of buffer */ /* Sanity check for going off end of buffer */
if ((offset + iovec[i].length) > iovec_dataP->iovec_buf_len) { if ((offset + iovec[i].length) > io_buffer->iovec_buf_len) {
code = UINTERNAL; code = UINTERNAL;
break; break;
} }
@ -157,6 +309,47 @@ ContactQuorum(aproc, atrans, aflags, aparm0, aparm1, aparm2, aparm3, aparm4,
offset += iovec[i].length; offset += iovec[i].length;
} }
} }
if (code) { /* failure */
rcode = code;
ts->up = 0; /* mark as down now; beacons will no longer be sent */
ts->currentDB = 0;
ts->beaconSinceDown = 0;
urecovery_LostServer(); /* tell recovery to try to resend dbase later */
} else { /* success */
if (!ts->isClone)
okcalls++; /* count up how many worked */
if (aflags & CStampVersion) {
ts->version = atrans->dbase->version;
}
}
}
/* return 0 if we successfully contacted a quorum, otherwise return error code. We don't have to contact ourselves (that was done locally) */
if (okcalls + 1 >= ubik_quorum)
return 0;
else
return rcode;
}
afs_int32
ContactQuorum_DISK_SetVersion(register struct ubik_trans *atrans, int aflags,
ubik_version *OldVersion,
ubik_version *NewVersion)
{
register struct ubik_server *ts;
register afs_int32 code;
afs_int32 rcode, okcalls;
rcode = 0;
okcalls = 0;
for (ts = ubik_servers; ts; ts = ts->next) {
/* for each server */
if (!ts->up || !ts->currentDB) {
ts->currentDB = 0; /* db is no longer current; we just missed an update */
continue; /* not up-to-date, don't bother */
}
code = DISK_SetVersion(ts->disk_rxcid, &atrans->tid, OldVersion,
NewVersion);
if (code) { /* failure */ if (code) { /* failure */
rcode = code; rcode = code;
ts->up = 0; /* mark as down now; beacons will no longer be sent */ ts->up = 0; /* mark as down now; beacons will no longer be sent */
@ -214,7 +407,6 @@ ubik_ServerInitCommon(afs_int32 myHost, short myPort,
struct rx_securityClass *secClass; struct rx_securityClass *secClass;
struct rx_service *tservice; struct rx_service *tservice;
extern int VOTE_ExecuteRequest(), DISK_ExecuteRequest();
extern int rx_stackSize; extern int rx_stackSize;
initialize_U_error_table(); initialize_U_error_table();
@ -504,11 +696,11 @@ BeginTrans(register struct ubik_dbase *dbase, afs_int32 transMode,
#endif /* UBIK_PAUSE */ #endif /* UBIK_PAUSE */
/* next try to start transaction on appropriate number of machines */ /* next try to start transaction on appropriate number of machines */
code = ContactQuorum(DISK_Begin, tt, 0); code = ContactQuorum_NoArguments(DISK_Begin, tt, 0);
if (code) { if (code) {
/* we must abort the operation */ /* we must abort the operation */
udisk_abort(tt); udisk_abort(tt);
ContactQuorum(DISK_Abort, tt, 0); /* force aborts to the others */ ContactQuorum_NoArguments(DISK_Abort, tt, 0); /* force aborts to the others */
udisk_end(tt); udisk_end(tt);
DBRELE(dbase); DBRELE(dbase);
return code; return code;
@ -577,7 +769,7 @@ ubik_AbortTrans(register struct ubik_trans *transPtr)
} }
/* now it is safe to try remote abort */ /* now it is safe to try remote abort */
code = ContactQuorum(DISK_Abort, transPtr, 0); code = ContactQuorum_NoArguments(DISK_Abort, transPtr, 0);
code2 = udisk_abort(transPtr); code2 = udisk_abort(transPtr);
udisk_end(transPtr); udisk_end(transPtr);
DBRELE(dbase); DBRELE(dbase);
@ -637,7 +829,7 @@ ubik_EndTrans(register struct ubik_trans *transPtr)
/* now it is safe to do commit */ /* now it is safe to do commit */
code = udisk_commit(transPtr); code = udisk_commit(transPtr);
if (code == 0) if (code == 0)
code = ContactQuorum(DISK_Commit, transPtr, CStampVersion); code = ContactQuorum_NoArguments(DISK_Commit, transPtr, CStampVersion);
if (code) { if (code) {
/* failed to commit, so must return failure. Try to clear locks first, just for fun /* failed to commit, so must return failure. Try to clear locks first, just for fun
* Note that we don't know if this transaction will eventually commit at this point. * Note that we don't know if this transaction will eventually commit at this point.
@ -645,7 +837,7 @@ ubik_EndTrans(register struct ubik_trans *transPtr)
* we lose. If we contact a majority of sites, then we won't be here: contacting * we lose. If we contact a majority of sites, then we won't be here: contacting
* a majority guarantees commit, since it guarantees that one dude will be a * a majority guarantees commit, since it guarantees that one dude will be a
* member of the next quorum. */ * member of the next quorum. */
ContactQuorum(DISK_ReleaseLocks, transPtr, 0); ContactQuorum_NoArguments(DISK_ReleaseLocks, transPtr, 0);
udisk_end(transPtr); udisk_end(transPtr);
DBRELE(dbase); DBRELE(dbase);
return code; return code;
@ -689,7 +881,7 @@ ubik_EndTrans(register struct ubik_trans *transPtr)
* The transaction is committed anyway, since we succeeded in contacting a quorum * The transaction is committed anyway, since we succeeded in contacting a quorum
* at the start (when invoking the DiskCommit function). * at the start (when invoking the DiskCommit function).
*/ */
ContactQuorum(DISK_ReleaseLocks, transPtr, 0); ContactQuorum_NoArguments(DISK_ReleaseLocks, transPtr, 0);
success: success:
udisk_end(transPtr); udisk_end(transPtr);
@ -709,7 +901,7 @@ ubik_EndTrans(register struct ubik_trans *transPtr)
* \note *length is an INOUT parameter: at the start it represents the size of the buffer, and when done, it contains the number of bytes actually transferred. * \note *length is an INOUT parameter: at the start it represents the size of the buffer, and when done, it contains the number of bytes actually transferred.
*/ */
int int
ubik_Read(register struct ubik_trans *transPtr, char *buffer, ubik_Read(register struct ubik_trans *transPtr, void *buffer,
afs_int32 length) afs_int32 length)
{ {
register afs_int32 code; register afs_int32 code;
@ -756,11 +948,11 @@ ubik_Flush(struct ubik_trans *transPtr)
/* Update the rest of the servers in the quorum */ /* Update the rest of the servers in the quorum */
code = code =
ContactQuorum(DISK_WriteV, transPtr, 0, &transPtr->iovec_info, ContactQuorum_DISK_WriteV(transPtr, 0, &transPtr->iovec_info,
&transPtr->iovec_data); &transPtr->iovec_data);
if (code) { if (code) {
udisk_abort(transPtr); udisk_abort(transPtr);
ContactQuorum(DISK_Abort, transPtr, 0); /* force aborts to the others */ ContactQuorum_NoArguments(DISK_Abort, transPtr, 0); /* force aborts to the others */
transPtr->iovec_info.iovec_wrt_len = 0; transPtr->iovec_info.iovec_wrt_len = 0;
transPtr->iovec_data.iovec_buf_len = 0; transPtr->iovec_data.iovec_buf_len = 0;
ERROR_EXIT(code); ERROR_EXIT(code);
@ -776,7 +968,7 @@ ubik_Flush(struct ubik_trans *transPtr)
} }
int int
ubik_Write(register struct ubik_trans *transPtr, char *buffer, ubik_Write(register struct ubik_trans *transPtr, void *buffer,
afs_int32 length) afs_int32 length)
{ {
struct ubik_iovec *iovec; struct ubik_iovec *iovec;
@ -791,7 +983,7 @@ ubik_Write(register struct ubik_trans *transPtr, char *buffer,
if (length > IOVEC_MAXBUF) { if (length > IOVEC_MAXBUF) {
for (pos = 0, len = length; len > 0; len -= size, pos += size) { for (pos = 0, len = length; len > 0; len -= size, pos += size) {
size = ((len < IOVEC_MAXBUF) ? len : IOVEC_MAXBUF); size = ((len < IOVEC_MAXBUF) ? len : IOVEC_MAXBUF);
code = ubik_Write(transPtr, &buffer[pos], size); code = ubik_Write(transPtr, buffer+pos, size);
if (code) if (code)
return (code); return (code);
} }
@ -926,13 +1118,13 @@ ubik_Truncate(register struct ubik_trans *transPtr, afs_int32 length)
code = udisk_truncate(transPtr, transPtr->seekFile, length); code = udisk_truncate(transPtr, transPtr->seekFile, length);
if (!code) { if (!code) {
code = code =
ContactQuorum(DISK_Truncate, transPtr, 0, transPtr->seekFile, ContactQuorum_DISK_Truncate(transPtr, 0, transPtr->seekFile,
length); length);
} }
if (code) { if (code) {
/* we must abort the operation */ /* we must abort the operation */
udisk_abort(transPtr); udisk_abort(transPtr);
ContactQuorum(DISK_Abort, transPtr, 0); /* force aborts to the others */ ContactQuorum_NoArguments(DISK_Abort, transPtr, 0); /* force aborts to the others */
ERROR_EXIT(code); ERROR_EXIT(code);
} }
@ -973,13 +1165,13 @@ ubik_SetLock(struct ubik_trans *atrans, afs_int32 apos, afs_int32 alen,
/* now do the operation locally, and propagate it out */ /* now do the operation locally, and propagate it out */
code = ulock_getLock(atrans, atype, 1); code = ulock_getLock(atrans, atype, 1);
if (code == 0) { if (code == 0) {
code = ContactQuorum(DISK_Lock, atrans, 0, 0, 1 /*unused */ , code = ContactQuorum_DISK_Lock(atrans, 0, 0, 1 /*unused */ ,
1 /*unused */ , LOCKWRITE); 1 /*unused */ , LOCKWRITE);
} }
if (code) { if (code) {
/* we must abort the operation */ /* we must abort the operation */
udisk_abort(atrans); udisk_abort(atrans);
ContactQuorum(DISK_Abort, atrans, 0); /* force aborts to the others */ ContactQuorum_NoArguments(DISK_Abort, atrans, 0); /* force aborts to the others */
ERROR_EXIT(code); ERROR_EXIT(code);
} }
} }
@ -1045,11 +1237,16 @@ ubik_CacheUpdate(register struct ubik_trans *atrans)
* *
* \returns There is no return from panic. * \returns There is no return from panic.
*/ */
int void
panic(char *a, char *b, char *c, char *d) panic(char *format, ...)
{ {
va_list ap;
va_start(ap, format);
ubik_print("Ubik PANIC: "); ubik_print("Ubik PANIC: ");
ubik_print(a, b, c, d); ubik_vprint(format, ap);
va_end(ap);
abort(); abort();
ubik_print("BACK FROM ABORT\n"); /* shouldn't come back */ ubik_print("BACK FROM ABORT\n"); /* shouldn't come back */
exit(1); /* never know, though */ exit(1); /* never know, though */

View File

@ -174,9 +174,9 @@ struct ubik_dbase {
afs_int32 writeTidCounter; /*!< last write trans tid counter */ afs_int32 writeTidCounter; /*!< last write trans tid counter */
afs_int32 flags; /*!< flags */ afs_int32 flags; /*!< flags */
/* physio procedures */ /* physio procedures */
int (*read) (struct ubik_dbase * adbase, afs_int32 afile, char *abuffer, int (*read) (struct ubik_dbase * adbase, afs_int32 afile, void *abuffer,
afs_int32 apos, afs_int32 alength); afs_int32 apos, afs_int32 alength);
int (*write) (struct ubik_dbase * adbase, afs_int32 afile, char *abuffer, int (*write) (struct ubik_dbase * adbase, afs_int32 afile, void *abuffer,
afs_int32 apos, afs_int32 alength); afs_int32 apos, afs_int32 alength);
int (*truncate) (struct ubik_dbase * adbase, afs_int32 afile, int (*truncate) (struct ubik_dbase * adbase, afs_int32 afile,
afs_int32 asize); afs_int32 asize);
@ -198,12 +198,14 @@ struct ubik_dbase {
}; };
/*! \name procedures for automatically authenticating ubik connections */ /*! \name procedures for automatically authenticating ubik connections */
extern int (*ubik_CRXSecurityProc) (); extern int (*ubik_CRXSecurityProc) (void *, struct rx_securityClass **,
extern char *ubik_CRXSecurityRock; afs_int32 *);
extern int (*ubik_SRXSecurityProc) (); extern void *ubik_CRXSecurityRock;
extern char *ubik_SRXSecurityRock; extern int (*ubik_SRXSecurityProc) (void *, struct rx_securityClass **,
extern int (*ubik_CheckRXSecurityProc) (); afs_int32 *);
extern char *ubik_CheckRXSecurityRock; extern void *ubik_SRXSecurityRock;
extern int (*ubik_CheckRXSecurityProc) (void *, struct rx_call *);
extern void *ubik_CheckRXSecurityRock;
/*\}*/ /*\}*/
/****************INTERNALS BELOW ****************/ /****************INTERNALS BELOW ****************/
@ -331,10 +333,10 @@ extern int uphys_close(register int afd);
extern int uphys_stat(struct ubik_dbase *adbase, afs_int32 afid, extern int uphys_stat(struct ubik_dbase *adbase, afs_int32 afid,
struct ubik_stat *astat); struct ubik_stat *astat);
extern int uphys_read(register struct ubik_dbase *adbase, afs_int32 afile, extern int uphys_read(register struct ubik_dbase *adbase, afs_int32 afile,
register char *abuffer, afs_int32 apos, register void *abuffer, afs_int32 apos,
afs_int32 alength); afs_int32 alength);
extern int uphys_write(register struct ubik_dbase *adbase, afs_int32 afile, extern int uphys_write(register struct ubik_dbase *adbase, afs_int32 afile,
register char *abuffer, afs_int32 apos, register void *abuffer, afs_int32 apos,
afs_int32 alength); afs_int32 alength);
extern int uphys_truncate(register struct ubik_dbase *adbase, afs_int32 afile, extern int uphys_truncate(register struct ubik_dbase *adbase, afs_int32 afile,
afs_int32 asize); afs_int32 asize);
@ -359,25 +361,87 @@ extern void *urecovery_Interact(void *);
extern int DoProbe(struct ubik_server *server); extern int DoProbe(struct ubik_server *server);
/*\}*/ /*\}*/
/*! \name ubik.c */
extern afs_int32 ContactQuorum_NoArguments(afs_int32 (*proc)
(struct rx_connection *,
ubik_tid *),
struct ubik_trans *atrans,
int aflags);
extern afs_int32 ContactQuorum_DISK_Lock(struct ubik_trans *atrans,
int aflags,
afs_int32 file, afs_int32 position,
afs_int32 length, afs_int32 type);
extern afs_int32 ContactQuorum_DISK_Write(struct ubik_trans *atrans,
int aflags,
afs_int32 file, afs_int32 position,
bulkdata *data);
extern afs_int32 ContactQuorum_DISK_Truncate(struct ubik_trans *atrans,
int aflags,
afs_int32 file, afs_int32 length);
extern afs_int32 ContactQuorum_DISK_WriteV(struct ubik_trans *atrans,
int aflags,
iovec_wrt * io_vector,
iovec_buf *io_buffer);
extern afs_int32 ContactQuorum_DISK_SetVersion(struct ubik_trans *atrans,
int aflags,
ubik_version *OldVersion,
ubik_version *NewVersion);
extern void panic(char *format, ...);
extern afs_uint32 ubikGetPrimaryInterfaceAddr(afs_uint32 addr);
/*\}*/
/*! \name beacon.c */
struct afsconf_cell;
extern void ubeacon_Debug(struct ubik_debug *aparm);
extern int ubeacon_AmSyncSite(void);
extern int ubeacon_InitServerListByInfo(afs_int32 ame,
struct afsconf_cell *info,
char clones[]);
extern int ubeacon_InitServerList(afs_int32 ame, afs_int32 aservers[]);
extern void *ubeacon_Interact(void *); extern void *ubeacon_Interact(void *);
extern int sdisk_Interact(); /*\}*/
extern int uvote_Interact();
extern int DISK_Abort();
extern int DISK_Begin();
extern int DISK_ReleaseLocks();
extern int DISK_Commit();
extern int DISK_Lock();
extern int DISK_Write();
extern int DISK_WriteV();
extern int DISK_Truncate();
extern int DISK_SetVersion();
/*! \name disk.c */ /*! \name disk.c */
extern void udisk_Debug(struct ubik_debug *aparm);
extern int udisk_Invalidate(struct ubik_dbase *adbase, afs_int32 afid);
extern int udisk_read(struct ubik_trans *atrans, afs_int32 afile,
void *abuffer, afs_int32 apos, afs_int32 alen);
extern int udisk_truncate(struct ubik_trans *atrans, afs_int32 afile,
afs_int32 alength);
extern int udisk_write(struct ubik_trans *atrans, afs_int32 afile,
void *abuffer, afs_int32 apos, afs_int32 alen);
extern int udisk_begin(struct ubik_dbase *adbase, int atype,
struct ubik_trans **atrans);
extern int udisk_commit(struct ubik_trans *atrans);
extern int udisk_abort(struct ubik_trans *atrans); extern int udisk_abort(struct ubik_trans *atrans);
extern int udisk_end(struct ubik_trans *atrans);
/*\}*/ /*\}*/
/*! \name lock.c */ /*! \name lock.c */
extern int ulock_getLock(struct ubik_trans *atrans, int atype, int await);
extern void ulock_relLock(struct ubik_trans *atrans); extern void ulock_relLock(struct ubik_trans *atrans);
extern void ulock_Debug(struct ubik_debug *aparm);
/*\}*/
/*! \name vote.c */
extern int uvote_ShouldIRun(void);
extern afs_int32 uvote_GetSyncSite(void);
extern int uvote_Init(void);
extern void ubik_vprint(const char *format, va_list ap);
extern void ubik_print(const char *format, ...);
extern void ubik_dprint(const char *format, ...);
/*\}*/
/*! \name ubik_int.xg - rxgen really should prototype these for us ... */
extern int VOTE_ExecuteRequest(register struct rx_call *);
extern int DISK_ExecuteRequest(register struct rx_call *);
/*\}*/ /*\}*/
#endif /* UBIK_INTERNALS */ #endif /* UBIK_INTERNALS */
@ -388,36 +452,74 @@ extern afs_int32 ubik_nBuffers;
* \name Public function prototypes * \name Public function prototypes
*/ */
/*! \name ubik.c */
struct afsconf_cell;
extern int ubik_ServerInitByInfo(afs_int32 myHost, short myPort,
struct afsconf_cell *info, char clones[],
char *pathName, struct ubik_dbase **dbase);
extern int ubik_ServerInit(afs_int32 myHost, short myPort,
afs_int32 serverList[],
char *pathName, struct ubik_dbase **dbase);
extern int ubik_BeginTrans(register struct ubik_dbase *dbase,
afs_int32 transMode, struct ubik_trans **transPtr);
extern int ubik_BeginTransReadAny(register struct ubik_dbase *dbase,
afs_int32 transMode,
struct ubik_trans **transPtr);
extern int ubik_AbortTrans(register struct ubik_trans *transPtr);
extern int ubik_EndTrans(register struct ubik_trans *transPtr);
extern int ubik_Read(register struct ubik_trans *transPtr, void *buffer,
afs_int32 length);
extern int ubik_Flush(struct ubik_trans *transPtr);
extern int ubik_Write(register struct ubik_trans *transPtr, void *buffer,
afs_int32 length);
extern int ubik_Seek(register struct ubik_trans *transPtr, afs_int32 fileid,
afs_int32 position);
extern int ubik_Tell(register struct ubik_trans *transPtr, afs_int32 * fileid,
afs_int32 * position);
extern int ubik_Truncate(register struct ubik_trans *transPtr,
afs_int32 length);
extern int ubik_SetLock(struct ubik_trans *atrans, afs_int32 apos,
afs_int32 alen, int atype);
extern int ubik_WaitVersion(register struct ubik_dbase *adatabase,
register struct ubik_version *aversion);
extern int ubik_GetVersion(register struct ubik_trans *atrans,
register struct ubik_version *avers);
extern int ubik_CacheUpdate(register struct ubik_trans *atrans);
/*\}*/
/*! \name ubikclient.c */
extern int ubik_ParseClientList(int argc, char **argv, afs_int32 * aothers); extern int ubik_ParseClientList(int argc, char **argv, afs_int32 * aothers);
extern unsigned int afs_random(void);
extern unsigned int afs_random(void
);
extern int ubik_ClientInit(register struct rx_connection **serverconns, extern int ubik_ClientInit(register struct rx_connection **serverconns,
struct ubik_client **aclient); struct ubik_client **aclient);
extern afs_int32 ubik_ClientDestroy(struct ubik_client *aclient); extern afs_int32 ubik_ClientDestroy(struct ubik_client *aclient);
extern struct rx_connection *ubik_RefreshConn(struct rx_connection *tc);
#ifdef UBIK_LEGACY_CALLITER
extern afs_int32 ubik_CallIter(int (*aproc) (), struct ubik_client *aclient, extern afs_int32 ubik_CallIter(int (*aproc) (), struct ubik_client *aclient,
afs_int32 aflags, int *apos, long p1, long p2, afs_int32 aflags, int *apos, long p1, long p2,
long p3, long p4, long p5, long p6, long p7, long p3, long p4, long p5, long p6, long p7,
long p8, long p9, long p10, long p11, long p12, long p8, long p9, long p10, long p11, long p12,
long p13, long p14, long p15, long p16); long p13, long p14, long p15, long p16);
#endif
extern struct rx_connection *ubik_RefreshConn(struct rx_connection *tc);
/*\}*/ /*\}*/
/* ubik.c */ /* \name ubikcmd.c */
extern int ubik_BeginTrans(register struct ubik_dbase *dbase, extern int ubik_ParseServerList(int argc, char **argv, afs_int32 *ahost,
afs_int32 transMode, struct ubik_trans **transPtr); afs_int32 *aothers);
extern int ubik_EndTrans(register struct ubik_trans *transPtr); /*\}*/
/* uinit.c */ /* \name uinit.c */
struct rx_securityClass;
extern afs_int32 ugen_ClientInit(int noAuthFlag, char *confDir, char *cellName, extern afs_int32 ugen_ClientInit(int noAuthFlag, char *confDir, char *cellName,
afs_int32 sauth, afs_int32 sauth,
struct ubik_client **uclientp, struct ubik_client **uclientp,
int (*secproc) (), char *funcName, int (*secproc) (struct rx_securityClass *sc,
afs_int32 scIndex),
char *funcName,
afs_int32 gen_rxkad_level, afs_int32 gen_rxkad_level,
afs_int32 maxservers, char *serviceid, afs_int32 maxservers, char *serviceid,
afs_int32 deadtime, afs_uint32 server, afs_int32 deadtime, afs_uint32 server,

View File

@ -25,6 +25,7 @@ RCSID
#include "rx/rx.h" #include "rx/rx.h"
#include "afs/lock.h" #include "afs/lock.h"
#include "afs/rxgen_consts.h" #include "afs/rxgen_consts.h"
#define UBIK_LEGACY_CALLITER 1
#include "ubik.h" #include "ubik.h"
#include "afs/pthread_glock.h" #include "afs/pthread_glock.h"
#else /* defined(UKERNEL) */ #else /* defined(UKERNEL) */
@ -32,6 +33,7 @@ RCSID
#include <afs/pthread_glock.h> #include <afs/pthread_glock.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <rx/xdr.h> #include <rx/xdr.h>
#include <rx/rx.h> #include <rx/rx.h>
#include <lock.h> #include <lock.h>
@ -342,7 +344,7 @@ pthread_mutex_t ubik_client_mutex;
#define UNLOCK_UCLNT_CACHE assert(pthread_mutex_unlock(&ubik_client_mutex)==0) #define UNLOCK_UCLNT_CACHE assert(pthread_mutex_unlock(&ubik_client_mutex)==0)
void void
ubik_client_init_mutex() ubik_client_init_mutex(void)
{ {
assert(pthread_mutex_init(&ubik_client_mutex, NULL) == 0); assert(pthread_mutex_init(&ubik_client_mutex, NULL) == 0);
} }
@ -364,27 +366,10 @@ static int synccount = 0;
* \todo In the future, we should also put in a protocol to find the sync site. * \todo In the future, we should also put in a protocol to find the sync site.
*/ */
afs_int32 afs_int32
ubik_Call(aproc, aclient, aflags, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, ubik_Call(int (*aproc) (), register struct ubik_client *aclient,
p11, p12, p13, p14, p15, p16) afs_int32 aflags, long p1, long p2, long p3, long p4,
int (*aproc) (); long p5, long p6, long p7, long p8, long p9, long p10,
register struct ubik_client *aclient; long p11, long p12, long p13, long p14, long p15, long p16)
afs_int32 aflags;
long p1;
long p2;
long p3;
long p4;
long p5;
long p6;
long p7;
long p8;
long p9;
long p10;
long p11;
long p12;
long p13;
long p14;
long p15;
long p16;
{ {
afs_int32 rcode, code, newHost, thisHost, i, count; afs_int32 rcode, code, newHost, thisHost, i, count;
int chaseCount, pass, needsync, inlist, j; int chaseCount, pass, needsync, inlist, j;
@ -582,29 +567,10 @@ try_GetSyncSite(register struct ubik_client *aclient, afs_int32 apos)
* been locked. * been locked.
*/ */
static afs_int32 static afs_int32
CallIter(aproc, aclient, aflags, apos, p1, p2, p3, p4, p5, p6, p7, p8, p9, CallIter(int (*aproc) (), register struct ubik_client *aclient,
p10, p11, p12, p13, p14, p15, p16, needlock) afs_int32 aflags, int *apos, long p1, long p2, long p3, long p4,
int (*aproc) (); long p5, long p6, long p7, long p8, long p9, long p10, long p11,
register struct ubik_client *aclient; long p12, long p13, long p14, long p15, long p16, int needlock)
afs_int32 aflags;
int *apos;
long p1;
long p2;
long p3;
long p4;
long p5;
long p6;
long p7;
long p8;
long p9;
long p10;
long p11;
long p12;
long p13;
long p14;
long p15;
long p16;
int needlock;
{ {
register afs_int32 code; register afs_int32 code;
struct rx_connection *tc; struct rx_connection *tc;
@ -676,27 +642,10 @@ CallIter(aproc, aclient, aflags, apos, p1, p2, p3, p4, p5, p6, p7, p8, p9,
* \todo In the future, we should also put in a protocol to find the sync site. * \todo In the future, we should also put in a protocol to find the sync site.
*/ */
afs_int32 afs_int32
ubik_Call_New(aproc, aclient, aflags, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, ubik_Call_New(int (*aproc) (), register struct ubik_client *aclient,
p11, p12, p13, p14, p15, p16) afs_int32 aflags, long p1, long p2, long p3, long p4, long p5,
int (*aproc) (); long p6, long p7, long p8, long p9, long p10, long p11,
register struct ubik_client *aclient; long p12, long p13, long p14, long p15, long p16)
afs_int32 aflags;
long p1;
long p2;
long p3;
long p4;
long p5;
long p6;
long p7;
long p8;
long p9;
long p10;
long p11;
long p12;
long p13;
long p14;
long p15;
long p16;
{ {
afs_int32 code, rcode; afs_int32 code, rcode;
afs_int32 count; afs_int32 count;

View File

@ -14,6 +14,10 @@ RCSID
("$Header$"); ("$Header$");
#include <sys/types.h> #include <sys/types.h>
#include <string.h>
#include <stdarg.h>
#include <time.h>
#ifdef AFS_NT40_ENV #ifdef AFS_NT40_ENV
#include <winsock2.h> #include <winsock2.h>
#else #else
@ -22,9 +26,7 @@ RCSID
#include <sys/param.h> #include <sys/param.h>
#include <netdb.h> #include <netdb.h>
#endif #endif
#include <time.h>
#include <lock.h> #include <lock.h>
#include <string.h>
#include <rx/xdr.h> #include <rx/xdr.h>
#include <rx/rx.h> #include <rx/rx.h>
@ -35,11 +37,9 @@ RCSID
* This file contain useful subroutines for parsing command line args for ubik * This file contain useful subroutines for parsing command line args for ubik
* applications. * applications.
*/ */
ubik_ParseServerList(argc, argv, ahost, aothers) int
int argc; ubik_ParseServerList(int argc, char **argv, afs_int32 *ahost,
char **argv; afs_int32 *aothers)
afs_int32 *ahost;
afs_int32 *aothers;
{ {
register afs_int32 i; register afs_int32 i;
register char *tp; register char *tp;

View File

@ -15,7 +15,11 @@ RCSID
#include <sys/types.h> #include <sys/types.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h>
#include <string.h> #include <string.h>
#include <signal.h>
#include <time.h>
#ifdef AFS_NT40_ENV #ifdef AFS_NT40_ENV
#include <winsock2.h> #include <winsock2.h>
#else #else
@ -24,25 +28,21 @@ RCSID
#include <netinet/in.h> #include <netinet/in.h>
#include <netdb.h> #include <netdb.h>
#endif #endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <signal.h>
#include <afs/afsutil.h>
#include <time.h>
#include <lock.h> #include <lock.h>
#include <rx/xdr.h> #include <rx/xdr.h>
#include <rx/rx.h> #include <rx/rx.h>
#include <afs/cmd.h> #include <afs/cmd.h>
#include <afs/afsutil.h>
#define UBIK_INTERNALS #define UBIK_INTERNALS
#include "ubik.h" #include "ubik.h"
#include "ubik_int.h" #include "ubik_int.h"
/*! needed by Irix. Include a header to get it, or leave it alone. */
extern struct hostent *hostutil_GetHostByName();
static short static short
PortNumber(register char *aport) PortNumber(register char *aport)
{ {

View File

@ -48,7 +48,8 @@ RCSID
*/ */
afs_int32 afs_int32
ugen_ClientInit(int noAuthFlag, char *confDir, char *cellName, afs_int32 sauth, ugen_ClientInit(int noAuthFlag, char *confDir, char *cellName, afs_int32 sauth,
struct ubik_client **uclientp, int (*secproc) (), struct ubik_client **uclientp,
int (*secproc) (struct rx_securityClass *, afs_int32),
char *funcName, afs_int32 gen_rxkad_level, char *funcName, afs_int32 gen_rxkad_level,
afs_int32 maxservers, char *serviceid, afs_int32 deadtime, afs_int32 maxservers, char *serviceid, afs_int32 deadtime,
afs_uint32 server, afs_uint32 port, afs_int32 usrvid) afs_uint32 server, afs_uint32 port, afs_int32 usrvid)

View File

@ -31,16 +31,12 @@ RCSID
#include "ubik.h" #include "ubik.h"
#include "utst_int.h" #include "utst_int.h"
extern int SAMPLE_Inc(), SAMPLE_Test(), SAMPLE_Get(), SAMPLE_Trun(),
SAMPLE_QGet();
/* main program */ /* main program */
#include "AFS_component_version_number.c" #include "AFS_component_version_number.c"
main(argc, argv) int
int argc; main(int argc, char **argv)
char **argv;
{ {
register afs_int32 code; register afs_int32 code;
struct ubik_client *cstruct = 0; struct ubik_client *cstruct = 0;
@ -87,7 +83,7 @@ main(argc, argv)
/* check code from init */ /* check code from init */
if (code) { if (code) {
printf("ubik client init failed with code %d\n", code); printf("ubik client init failed with code %d\n", code);
return; exit(1);
} }
/* parse command line for our own operations */ /* parse command line for our own operations */
@ -95,19 +91,19 @@ main(argc, argv)
if (!strcmp(argv[i], "-inc")) { if (!strcmp(argv[i], "-inc")) {
/* use ubik_Call to do the work, finding an up server and handling /* use ubik_Call to do the work, finding an up server and handling
* the job of finding a sync site, if need be */ * the job of finding a sync site, if need be */
code = ubik_Call(SAMPLE_Inc, cstruct, 0); code = ubik_SAMPLE_Inc(cstruct, 0);
printf("return code is %d\n", code); printf("return code is %d\n", code);
} else if (!strcmp(argv[i], "-try")) { } else if (!strcmp(argv[i], "-try")) {
code = ubik_Call(SAMPLE_Test, cstruct, 0); code = ubik_SAMPLE_Test(cstruct, 0);
printf("return code is %d\n", code); printf("return code is %d\n", code);
} else if (!strcmp(argv[i], "-qget")) { } else if (!strcmp(argv[i], "-qget")) {
code = ubik_Call(SAMPLE_QGet, cstruct, 0, &temp); code = ubik_SAMPLE_QGet(cstruct, 0, &temp);
printf("got quick value %d (code %d)\n", temp, code); printf("got quick value %d (code %d)\n", temp, code);
} else if (!strcmp(argv[i], "-get")) { } else if (!strcmp(argv[i], "-get")) {
code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp); code = ubik_SAMPLE_Get(cstruct, 0, &temp);
printf("got value %d (code %d)\n", temp, code); printf("got value %d (code %d)\n", temp, code);
} else if (!strcmp(argv[i], "-trunc")) { } else if (!strcmp(argv[i], "-trunc")) {
code = ubik_Call(SAMPLE_Trun, cstruct, 0); code = ubik_SAMPLE_Trun(cstruct, 0);
printf("return code is %d\n", code); printf("return code is %d\n", code);
} else if (!strcmp(argv[i], "-minc")) { } else if (!strcmp(argv[i], "-minc")) {
afs_int32 temp; afs_int32 temp;
@ -118,22 +114,22 @@ main(argc, argv)
while (1) { while (1) {
temp = 0; temp = 0;
code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp); code = ubik_SAMPLE_Get(cstruct, 0, &temp);
if (code != 0) { if (code != 0) {
printf("SAMPLE_Inc #1 failed with code %ld\n", code); printf("SAMPLE_Get #1 failed with code %ld\n", code);
} else { } else {
printf("SAMPLE_Get #1 succeeded, got value %d\n", temp); printf("SAMPLE_Get #1 succeeded, got value %d\n", temp);
} }
temp = 0; temp = 0;
code = ubik_Call(SAMPLE_Inc, cstruct, 0); code = ubik_SAMPLE_Inc(cstruct, 0);
if (code != 0) { if (code != 0) {
printf("SAMPLE_Inc #1 failed with code %ld\n", code); printf("SAMPLE_Inc #1 failed with code %ld\n", code);
} else { } else {
printf("SAMPLE_Inc #1 succeeded, incremented integer\n"); printf("SAMPLE_Inc #1 succeeded, incremented integer\n");
} }
temp = 0; temp = 0;
code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp); code = ubik_SAMPLE_Get(cstruct, 0, &temp);
if (code != 0) { if (code != 0) {
printf("SAMPLE_Get #2 failed with code %ld\n", code); printf("SAMPLE_Get #2 failed with code %ld\n", code);
} else { } else {
@ -141,7 +137,7 @@ main(argc, argv)
} }
temp = 0; temp = 0;
code = ubik_Call(SAMPLE_Inc, cstruct, 0); code = ubik_SAMPLE_Inc(cstruct, 0);
if (code != 0) if (code != 0)
printf("SAMPLE_Inc #2 failed with code %ld\n", code); printf("SAMPLE_Inc #2 failed with code %ld\n", code);
else else
@ -162,16 +158,16 @@ main(argc, argv)
tv.tv_sec = 1; tv.tv_sec = 1;
tv.tv_usec = 0; tv.tv_usec = 0;
while (1) { while (1) {
code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp); code = ubik_SAMPLE_Get(cstruct, 0, &temp);
printf("got value %d (code %d)\n", temp, code); printf("got value %d (code %d)\n", temp, code);
code = ubik_Call(SAMPLE_Inc, cstruct, 0); code = ubik_SAMPLE_Inc(cstruct, 0);
printf("update return code is %d\n", code); printf("update return code is %d\n", code);
code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp); code = ubik_SAMPLE_Get(cstruct, 0, &temp);
printf("got value %d (code %d)\n", temp, code); printf("got value %d (code %d)\n", temp, code);
code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp); code = ubik_SAMPLE_Get(cstruct, 0, &temp);
printf("got value %d (code %d)\n", temp, code); printf("got value %d (code %d)\n", temp, code);
tv.tv_sec = 1; tv.tv_sec = 1;
@ -184,4 +180,5 @@ main(argc, argv)
} }
} }
} }
return 0;
} }

View File

@ -29,6 +29,7 @@ RCSID
#include <rx/xdr.h> #include <rx/xdr.h>
#include <rx/rx.h> #include <rx/rx.h>
#include <lock.h> #include <lock.h>
#include <afs/afsutil.h>
#include "ubik.h" #include "ubik.h"
#include "utst_int.h" #include "utst_int.h"
@ -38,8 +39,8 @@ struct ubik_dbase *dbase;
afs_int32 sleepTime; afs_int32 sleepTime;
/*\}*/ /*\}*/
SAMPLE_Inc(rxconn) int
struct rx_connection *rxconn; SAMPLE_Inc(struct rx_connection *rxconn)
{ {
afs_int32 code, temp; afs_int32 code, temp;
struct ubik_trans *tt; struct ubik_trans *tt;
@ -97,10 +98,8 @@ SAMPLE_Inc(rxconn)
return code; return code;
} }
int
SAMPLE_Get(rxconn, gnumber) SAMPLE_Get(struct rx_connection *rxconn, afs_int32 *gnumber)
struct rx_connection *rxconn;
afs_int32 *gnumber;
{ {
afs_int32 code, temp; afs_int32 code, temp;
struct ubik_trans *tt; struct ubik_trans *tt;
@ -144,10 +143,8 @@ SAMPLE_Get(rxconn, gnumber)
return code; return code;
} }
int
SAMPLE_QGet(rxconn, gnumber) SAMPLE_QGet(struct rx_connection *rxconn, afs_int32 *gnumber)
struct rx_connection *rxconn;
afs_int32 *gnumber;
{ {
afs_int32 code, temp; afs_int32 code, temp;
struct ubik_trans *tt; struct ubik_trans *tt;
@ -191,9 +188,8 @@ SAMPLE_QGet(rxconn, gnumber)
return code; return code;
} }
int
SAMPLE_Trun(rxconn) SAMPLE_Trun(struct rx_connection *rxconn)
struct rx_connection *rxconn;
{ {
afs_int32 code; afs_int32 code;
struct ubik_trans *tt; struct ubik_trans *tt;
@ -231,9 +227,8 @@ SAMPLE_Trun(rxconn)
return code; return code;
} }
int
SAMPLE_Test(rxconn) SAMPLE_Test(struct rx_connection *rxconn)
struct rx_connection *rxconn;
{ {
afs_int32 code, temp; afs_int32 code, temp;
struct ubik_trans *tt; struct ubik_trans *tt;
@ -281,16 +276,16 @@ SAMPLE_Test(rxconn)
#include "AFS_component_version_number.c" #include "AFS_component_version_number.c"
main(argc, argv) extern int SAMPLE_ExecuteRequest(struct rx_call *);
int argc;
char **argv; int
main(int argc, char **argv)
{ {
register afs_int32 code, i; register afs_int32 code, i;
afs_int32 serverList[MAXSERVERS]; afs_int32 serverList[MAXSERVERS];
afs_int32 myHost; afs_int32 myHost;
struct rx_service *tservice; struct rx_service *tservice;
struct rx_securityClass *sc[2]; struct rx_securityClass *sc[2];
extern int SAMPLE_ExecuteRequest();
char dbfileName[128]; char dbfileName[128];
if (argc == 1) { if (argc == 1) {
@ -333,7 +328,7 @@ main(argc, argv)
if (code) { if (code) {
printf("ubik init failed with code %d\n", code); printf("ubik init failed with code %d\n", code);
return; exit(1);
} }
sc[0] = rxnull_NewServerSecurityObject(); sc[0] = rxnull_NewServerSecurityObject();
@ -350,4 +345,6 @@ main(argc, argv)
rx_SetMaxProcs(tservice, 3); rx_SetMaxProcs(tservice, 3);
rx_StartServer(1); /* Why waste this idle process?? */ rx_StartServer(1); /* Why waste this idle process?? */
return 0;
} }

View File

@ -557,20 +557,30 @@ SVOTE_GetSyncSite(register struct rx_call * rxcall,
return 0; return 0;
} }
int void
ubik_dprint(char *a, char *b, char *c, char *d, char *e, char *f, char *g, ubik_dprint(const char *format, ...)
char *h)
{ {
ViceLog(5, (a, b, c, d, e, f, g, h)); va_list ap;
return 0;
va_start(ap, format);
vViceLog(5, (format, ap));
va_end(ap);
} }
int void
ubik_print(char *a, char *b, char *c, char *d, char *e, char *f, char *g, ubik_vprint(const char *format, va_list ap)
char *h)
{ {
ViceLog(0, (a, b, c, d, e, f, g, h)); vViceLog(0, (format, ap));
return 0; }
void
ubik_print(const char *format, ...)
{
va_list ap;
va_start(ap, format);
ubik_vprint(format, ap);
va_end(ap);
} }
/*! /*!