ubik-pause-collapsing-20020624
[openafs.git] / src / ubik / remote.c
index 33b7af5..35f22a1 100644 (file)
@@ -19,6 +19,13 @@ RCSID("$Header$");
 #include <sys/file.h>
 #include <netinet/in.h>
 #endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#else
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#endif
 #include <lock.h>
 #include <rx/xdr.h>
 #include <rx/rx.h>
@@ -28,6 +35,7 @@ RCSID("$Header$");
 #include "ubik_int.h"
 int (*ubik_CheckRXSecurityProc)();
 char *ubik_CheckRXSecurityRock;
+void printServerInfo();
 
 /* routines for handling requests remotely-submitted by the sync site.  These are
     only write transactions (we don't propagate read trans), and there is at most one
@@ -51,22 +59,26 @@ register struct rx_call *acall; {
  * transactions: this is the code executed on the other servers when a
  * sync site is executing a write transaction.
  */
-SDISK_Begin(rxcall, atid)
+afs_int32 SDISK_Begin(rxcall, atid)
     register struct rx_call *rxcall;
     struct ubik_tid *atid;
 {
     register afs_int32 code;
 
-    if (code = ubik_CheckAuth(rxcall)) {
+    if ((code = ubik_CheckAuth(rxcall))) {
       return code;
     }
     DBHOLD(ubik_dbase);
     urecovery_CheckTid(atid);
     if (ubik_currentTrans) {
         /* If the thread is not waiting for lock - ok to end it */
+#if !defined(UBIK_PAUSE)
         if (ubik_currentTrans->locktype != LOCKWAIT) {
+#endif /* UBIK_PAUSE */
           udisk_end(ubik_currentTrans);
+#if !defined(UBIK_PAUSE)
        }
+#endif /* UBIK_PAUSE */
        ubik_currentTrans = (struct ubik_trans *) 0;
     }
     code = udisk_begin(ubik_dbase, UBIK_WRITETRANS, &ubik_currentTrans);
@@ -79,14 +91,14 @@ SDISK_Begin(rxcall, atid)
     return code;}
 
 
-SDISK_Commit(rxcall, atid)
+afs_int32 SDISK_Commit(rxcall, atid)
     register struct rx_call *rxcall;
     struct ubik_tid *atid;
 {
     register afs_int32 code;
     register struct ubik_dbase *dbase;
     
-    if (code = ubik_CheckAuth(rxcall)) {
+    if ((code = ubik_CheckAuth(rxcall))) {
       return code;
     }
 
@@ -117,14 +129,14 @@ SDISK_Commit(rxcall, atid)
     return code;
 }
 
-SDISK_ReleaseLocks(rxcall, atid)
+afs_int32 SDISK_ReleaseLocks(rxcall, atid)
     register struct rx_call *rxcall;
     struct ubik_tid *atid;
 {
     register struct ubik_dbase *dbase;
     register afs_int32 code;
 
-    if (code = ubik_CheckAuth(rxcall)) {
+    if ((code = ubik_CheckAuth(rxcall))) {
       return code;
     }
 
@@ -145,22 +157,26 @@ SDISK_ReleaseLocks(rxcall, atid)
     }
 
     /* If the thread is not waiting for lock - ok to end it */
+#if !defined(UBIK_PAUSE)
     if (ubik_currentTrans->locktype != LOCKWAIT) {
-       udisk_end(ubik_currentTrans);
-    }
+#endif /* UBIK_PAUSE */
+       udisk_end(ubik_currentTrans);
+#if !defined(UBIK_PAUSE)
+    }    
+#endif /* UBIK_PAUSE */
     ubik_currentTrans = (struct ubik_trans *) 0;
     DBRELE(dbase);
     return 0;
 }
 
-SDISK_Abort(rxcall, atid)
+afs_int32 SDISK_Abort(rxcall, atid)
     register struct rx_call *rxcall;
     struct ubik_tid *atid;
 {
     register afs_int32 code;
     register struct ubik_dbase *dbase;
     
-    if (code = ubik_CheckAuth(rxcall)) {
+    if ((code = ubik_CheckAuth(rxcall))) {
       return code;
     }
 
@@ -182,15 +198,19 @@ SDISK_Abort(rxcall, atid)
 
     code = udisk_abort(ubik_currentTrans);
     /* If the thread is not waiting for lock - ok to end it */
+#if !defined(UBIK_PAUSE)
     if (ubik_currentTrans->locktype != LOCKWAIT) {
-       udisk_end(ubik_currentTrans);
-    }
+#endif /* UBIK_PAUSE */
+        udisk_end(ubik_currentTrans);
+#if !defined(UBIK_PAUSE)
+     }
+#endif /* UBIK_PAUSE */
     ubik_currentTrans = (struct ubik_trans *) 0;
     DBRELE(dbase);
     return code;
 }
 
-SDISK_Lock(rxcall, atid, afile, apos, alen, atype)
+afs_int32 SDISK_Lock(rxcall, atid, afile, apos, alen, atype)
     register struct rx_call *rxcall;
     struct ubik_tid *atid;
     afs_int32 afile, apos, alen, atype;   /* apos and alen are not used */
@@ -199,7 +219,7 @@ SDISK_Lock(rxcall, atid, afile, apos, alen, atype)
     register struct ubik_dbase *dbase;
     struct ubik_trans *ubik_thisTrans;
 
-    if (code = ubik_CheckAuth(rxcall)) {
+    if ((code = ubik_CheckAuth(rxcall))) {
       return code;
     }
     if (!ubik_currentTrans) {
@@ -237,7 +257,7 @@ SDISK_Lock(rxcall, atid, afile, apos, alen, atype)
 }
 
 /* Write a vector of data */
-SDISK_WriteV(rxcall, atid, io_vector, io_buffer)
+afs_int32 SDISK_WriteV(rxcall, atid, io_vector, io_buffer)
     register struct rx_call *rxcall;
     struct ubik_tid *atid;
     iovec_wrt *io_vector;
@@ -248,7 +268,7 @@ SDISK_WriteV(rxcall, atid, io_vector, io_buffer)
     struct ubik_iovec *iovec;
     char              *iobuf;
 
-    if (code = ubik_CheckAuth(rxcall)) {
+    if ((code = ubik_CheckAuth(rxcall))) {
       return code;
     }
     if (!ubik_currentTrans) {
@@ -286,7 +306,7 @@ SDISK_WriteV(rxcall, atid, io_vector, io_buffer)
     return code;
 }
 
-SDISK_Write(rxcall, atid, afile, apos, adata)
+afs_int32 SDISK_Write(rxcall, atid, afile, apos, adata)
     register struct rx_call *rxcall;
     struct ubik_tid *atid;
     afs_int32 afile, apos;
@@ -295,7 +315,7 @@ SDISK_Write(rxcall, atid, afile, apos, adata)
     register afs_int32 code;
     register struct ubik_dbase *dbase;
 
-    if (code = ubik_CheckAuth(rxcall)) {
+    if ((code = ubik_CheckAuth(rxcall))) {
       return code;
     }
     if (!ubik_currentTrans) {
@@ -318,7 +338,7 @@ SDISK_Write(rxcall, atid, afile, apos, adata)
     return code;
 }
 
-SDISK_Truncate(rxcall, atid, afile, alen)
+afs_int32 SDISK_Truncate(rxcall, atid, afile, alen)
     register struct rx_call *rxcall;
     struct ubik_tid *atid;
     afs_int32 afile;
@@ -327,7 +347,7 @@ SDISK_Truncate(rxcall, atid, afile, alen)
     register afs_int32 code;
     register struct ubik_dbase *dbase;
 
-    if (code = ubik_CheckAuth(rxcall)) {
+    if ((code = ubik_CheckAuth(rxcall))) {
       return code;
     }
     if (!ubik_currentTrans) { 
@@ -350,13 +370,13 @@ SDISK_Truncate(rxcall, atid, afile, alen)
     return code;
 }
 
-SDISK_GetVersion(rxcall, aversion)
+afs_int32 SDISK_GetVersion(rxcall, aversion)
     register struct rx_call *rxcall;
     register struct ubik_version *aversion; 
 {
     register afs_int32 code;
 
-    if (code = ubik_CheckAuth(rxcall)) {
+    if ((code = ubik_CheckAuth(rxcall))) {
       return code;
     }
 
@@ -387,7 +407,7 @@ SDISK_GetVersion(rxcall, aversion)
     return 0;
 }
 
-SDISK_GetFile(rxcall, file, version)
+afs_int32 SDISK_GetFile(rxcall, file, version)
     register struct rx_call *rxcall;
     register afs_int32 file;
     struct ubik_version *version;
@@ -400,7 +420,7 @@ SDISK_GetFile(rxcall, file, version)
     afs_int32 tlen;
     afs_int32 length;
     
-    if (code = ubik_CheckAuth(rxcall)) {
+    if ((code = ubik_CheckAuth(rxcall))) {
       return code;
     }
 /* temporarily disabled because it causes problems for migration tool.  Hey, it's just
@@ -444,7 +464,7 @@ SDISK_GetFile(rxcall, file, version)
     return code;
 }
 
-SDISK_SendFile(rxcall, file, length, avers)
+afs_int32 SDISK_SendFile(rxcall, file, length, avers)
     register struct rx_call *rxcall;
     afs_int32 file;
     afs_int32 length;
@@ -453,7 +473,7 @@ SDISK_SendFile(rxcall, file, length, avers)
     register afs_int32 code;
     register struct ubik_dbase *dbase;
     char tbuffer[256];
-    afs_int32 offset, t;
+    afs_int32 offset;
     struct ubik_version tversion;
     register int tlen;
     struct rx_peer *tpeer;
@@ -462,7 +482,7 @@ SDISK_SendFile(rxcall, file, length, avers)
 
     /* send the file back to the requester */
     
-    if (code = ubik_CheckAuth(rxcall)) {
+    if ((code = ubik_CheckAuth(rxcall))) {
       goto failed;
     }
 
@@ -522,7 +542,7 @@ SDISK_SendFile(rxcall, file, length, avers)
        This way, good label is only on good database. */
     (*ubik_dbase->sync)(dbase, file);
     code = (*ubik_dbase->setlabel)(dbase, file, avers);
-    bcopy(avers, &ubik_dbase->version, sizeof(struct ubik_version));
+    memcpy(&ubik_dbase->version, avers, sizeof(struct ubik_version));
     udisk_Invalidate(dbase, file); /* new dbase, flush disk buffers */
     LWP_NoYieldSignal(&dbase->version);
     DBRELE(dbase);
@@ -537,7 +557,7 @@ failed:
 }
 
 
-SDISK_Probe(rxcall)
+afs_int32 SDISK_Probe(rxcall)
     register struct rx_call *rxcall;
 {
     return 0;
@@ -548,7 +568,7 @@ SDISK_Probe(rxcall)
 * Send back my addresses to caller of this RPC
 * Returns zero on success, else 1.
 */
-SDISK_UpdateInterfaceAddr(rxcall, inAddr, outAddr)
+afs_int32 SDISK_UpdateInterfaceAddr(rxcall, inAddr, outAddr)
 register struct rx_call *rxcall;
 UbikInterfaceAddr      *inAddr, *outAddr;
 {
@@ -598,6 +618,7 @@ UbikInterfaceAddr   *inAddr, *outAddr;
        for ( i=0; i < UBIK_MAX_INTERFACE_ADDR && inAddr->hostAddr[i]; i++)
            ubik_print("%s ", afs_inet_ntoa(htonl(inAddr->hostAddr[i])));
        ubik_print("\n");
+       fflush(stdout); fflush(stderr);
        printServerInfo();
         return UBADHOST;
     }
@@ -614,6 +635,7 @@ UbikInterfaceAddr   *inAddr, *outAddr;
     return 0;
 }
 
+void
 printServerInfo()
 {
     struct ubik_server *ts;
@@ -629,7 +651,7 @@ printServerInfo()
     ubik_print("\n");
 }
 
-SDISK_SetVersion(rxcall, atid, oldversionp, newversionp)
+afs_int32 SDISK_SetVersion(rxcall, atid, oldversionp, newversionp)
   struct rx_call      *rxcall;
   struct ubik_tid     *atid;
   struct ubik_version *oldversionp; 
@@ -638,7 +660,7 @@ SDISK_SetVersion(rxcall, atid, oldversionp, newversionp)
   afs_int32               code=0;
   struct ubik_dbase   *dbase;
 
-  if (code = ubik_CheckAuth(rxcall)) {
+  if ((code = ubik_CheckAuth(rxcall))) {
      return(code);
   }