DEVEL15-kill-ubik-pthread-env-20080718
[openafs.git] / src / budb / procs.c
index c538dc5..8f5e47c 100644 (file)
@@ -29,14 +29,7 @@ RCSID
 #include <sys/resource.h>
 #endif
 
-#ifdef HAVE_STRING_H
 #include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
-
 #include <sys/types.h>
 #include <afs/stds.h>
 #include <afs/bubasics.h>
@@ -65,8 +58,6 @@ RCSID
 
 extern struct ubik_dbase *BU_dbase;
 extern struct afsconf_dir *BU_conf;    /* for getting cell info */
-extern afs_int32 myHost;
-extern struct memoryDB db;     /* incore copies of db structures */
 
 afs_int32 AddVolume(), AddVolumes(), CreateDump(), DoDeleteDump(),
 DoDeleteTape(), ListDumps();
@@ -119,7 +110,11 @@ AwaitInitialization()
            start = time(0);
        else if (time(0) - start > 5)
            return UNOQUORUM;
+#ifdef AFS_PTHREAD_ENV
+       sleep(1);
+#else
        IOMGR_Sleep(1);
+#endif
     }
     return 0;
 }
@@ -152,6 +147,7 @@ tailCompPtr(pathNamePtr)
  *     1 - yes
  */
 
+int
 callPermitted(call)
      struct rx_call *call;
 {
@@ -165,7 +161,6 @@ callPermitted(call)
     if (afsconf_SuperUser(acdir, call, NULL))
        permitted = 1;
 
-  exit:
     if (acdir)
        afsconf_Close(acdir);
     return (permitted);
@@ -209,7 +204,11 @@ InitRPC(ut, lock, this_op)
                Log("Waiting for quorum election\n");
            if (wait < 15.0)
                wait *= 1.1;
+#ifdef AFS_PTHREAD_ENV
+           sleep((int)wait);
+#else
            IOMGR_Sleep((int)wait);
+#endif
        }
     }
     if (code)
@@ -899,9 +898,8 @@ deleteDump(call, id, dumps)
     struct dump dump;
     struct tape tape;
     dumpId dumpid;
-    int firstdump;
     afs_int32 eval, code = 0;
-    int partialDel;
+    int partialDel = 0;
 
     /* iterate until the dump is truly deleted */
 
@@ -1033,6 +1031,7 @@ struct wantDumpRock {
 };
 
 
+int
 wantDump(dumpAddrParam, dumpParam, dumpListPtrParam)
      char *dumpAddrParam;
      char *dumpParam;
@@ -1057,6 +1056,7 @@ wantDump(dumpAddrParam, dumpParam, dumpListPtrParam)
     return (0);
 }
 
+int
 rememberDump(dumpAddrParam, dumpParam, dumpListPtrParam)
      char *dumpAddrParam;
      char *dumpParam;
@@ -1477,7 +1477,11 @@ CreateDump(call, dump)
            }
 
            /* dump id is in use - wait a while */
+#ifdef AFS_PTHREAD_ENV
+           sleep(1);
+#else
            IOMGR_Sleep(1);
+#endif
        }                       /*w */
     } else {
        /* dump id supplied (e.g. for database restore) */
@@ -1611,8 +1615,7 @@ ListDumps(call, sflags, groupid, fromTime, toTime, dumps, flags)
     dbadr dbAddr, dbAppAddr;
 
     afs_int32 eval, code = 0;
-    int old, hash, length, entrySize, j, k, count = 0;
-    afs_uint32 toList, toFlag;
+    int old, hash, length, entrySize, count = 0;
 
     if (!callPermitted(call))
        return BUDB_NOTPERMITTED;
@@ -1912,7 +1915,7 @@ FindClone(call, dumpID, volName, clonetime)
      afs_int32 *clonetime;
 {
     struct ubik_trans *ut;
-    dbadr da, ta, hvia, via, vfa;
+    dbadr da, hvia, via, vfa;
     struct dump d;
     struct tape t;
     struct volFragment vf;
@@ -2693,7 +2696,6 @@ GetDumps(call, majorVersion, flags, name, start, end, index, nextIndexP,
     if (eval)
        ABORT(eval);
 
-  error_exit:
     FreeReturnList(&list);
     code = ubik_EndTrans(ut);
     return code;
@@ -3655,7 +3657,6 @@ T_DumpDatabase(call, filename)
     char *path = 0;
     dbadr dbAddr;
     int type, old, length, hash;
-    int block, index;
     struct memoryHashTable *mht;
     afs_int32 eval, code = 0;
 
@@ -3705,8 +3706,8 @@ T_DumpDatabase(call, filename)
                                ERROR(eval);
 
                            fprintf(dumpfid,
-                                   "\ndumpId hash %d, entry at %u: block %d, index %d\n",
-                                   hash, dbAddr, block, index);
+                                   "\ndumpId hash %d, entry at %u\n",
+                                   hash, dbAddr);
                            fprintf(dumpfid,
                                    "----------------------------\n");
                            dump_ntoh(&diskDump, &hostDump);
@@ -3726,8 +3727,8 @@ T_DumpDatabase(call, filename)
                                ERROR(eval);
 
                            fprintf(dumpfid,
-                                   "\ndumpname hash %d, entry at %u: block %d, index %d\n",
-                                   hash, dbAddr, block, index);
+                                   "\ndumpname hash %d, entry at %u\n",
+                                   hash, dbAddr);
                            fprintf(dumpfid,
                                    "----------------------------\n");
                            dump_ntoh(&diskDump, &hostDump);
@@ -3747,8 +3748,8 @@ T_DumpDatabase(call, filename)
                                ERROR(eval);
 
                            fprintf(dumpfid,
-                                   "\ntapename hash %d, entry at %u: block %d, index %d\n",
-                                   hash, dbAddr, block, index);
+                                   "\ntapename hash %d, entry at %u\n",
+                                   hash, dbAddr);
                            fprintf(dumpfid,
                                    "----------------------------\n");
                            tape_ntoh(&diskTape, &hostTape);
@@ -3768,8 +3769,8 @@ T_DumpDatabase(call, filename)
                                ERROR(eval);
 
                            fprintf(dumpfid,
-                                   "\nvolname hash %d, entry at %u: block %d, index %d\n",
-                                   hash, dbAddr, block, index);
+                                   "\nvolname hash %d, entry at %u\n",
+                                   hash, dbAddr);
                            fprintf(dumpfid,
                                    "----------------------------\n");
                            volInfo_ntoh(&diskVolInfo, &hostVolInfo);
@@ -3800,6 +3801,7 @@ T_DumpDatabase(call, filename)
     return (code);
 }
 
+int
 volFragsDump(ut, dumpfid, dbAddr)
      struct ubik_trans *ut;
      FILE *dumpfid;
@@ -3807,7 +3809,6 @@ volFragsDump(ut, dumpfid, dbAddr)
 {
     struct volFragment hostVolFragment, diskVolFragment;
     afs_int32 code;
-    int block, index;
 
     while (dbAddr) {
        code =
@@ -3818,8 +3819,7 @@ volFragsDump(ut, dumpfid, dbAddr)
            return (0);
        }
 
-       fprintf(dumpfid, "\nvolfragment entry at %u: block %d, index %d\n",
-               dbAddr, block, index);
+       fprintf(dumpfid, "\nvolfragment entry at %u\n", dbAddr);
        fprintf(dumpfid, "----------------------------\n");
        volFragment_ntoh(&diskVolFragment, &hostVolFragment);
        printVolFragment(dumpfid, &hostVolFragment);
@@ -3907,6 +3907,7 @@ dumpDiskToHost(diskDumpPtr, hostDumpPtr)
 
 #endif /* notdef */
 
+int
 checkHash(ut, hashType)
      struct ubik_trans *ut;
      int hashType;
@@ -3915,7 +3916,7 @@ checkHash(ut, hashType)
     int entrySize, hashTableLength;
     int bucket;
     int old;
-    afs_int32 code;
+    afs_int32 code = 0;
 
     mhtPtr = ht_GetType(hashType, &entrySize);
     if (mhtPtr == 0)