libafs: reduce stack space
[openafs.git] / src / afs / afs_server.c
index d7e3d46..afce4e6 100644 (file)
@@ -621,7 +621,7 @@ afs_LoopServers(int adown, struct cell *acellp, int vlalso,
                void (*func2) (int nservers, struct rx_connection **rxconns,
                               struct afs_conn **conns))
 {
-    struct vrequest treq;
+    struct vrequest *treq = NULL;
     struct server *ts;
     struct srvAddr *sa;
     struct afs_conn *tc = NULL;
@@ -644,7 +644,7 @@ afs_LoopServers(int adown, struct cell *acellp, int vlalso,
     if (AFS_IS_DISCONNECTED)
         return;
 
-    if ((code = afs_InitReq(&treq, afs_osi_credp)))
+    if ((code = afs_CreateReq(&treq, afs_osi_credp)))
        return;
     ObtainReadLock(&afs_xserver);      /* Necessary? */
     ObtainReadLock(&afs_xsrvAddr);
@@ -698,7 +698,7 @@ afs_LoopServers(int adown, struct cell *acellp, int vlalso,
        /* check vlserver with special code */
        if (sa->sa_portal == AFS_VLPORT) {
            if (vlalso)
-               CheckVLServer(sa, &treq);
+               CheckVLServer(sa, treq);
            continue;
        }
 
@@ -706,7 +706,7 @@ afs_LoopServers(int adown, struct cell *acellp, int vlalso,
            continue;           /* have just been added by setsprefs */
 
        /* get a connection, even if host is down; bumps conn ref count */
-       tu = afs_GetUser(treq.uid, ts->cell->cellNum, SHARED_LOCK);
+       tu = afs_GetUser(treq->uid, ts->cell->cellNum, SHARED_LOCK);
        tc = afs_ConnBySA(sa, ts->cell->fsport, ts->cell->cellNum, tu,
                          1 /*force */ , 1 /*create */ , SHARED_LOCK, 0,
                          &rxconn);
@@ -746,6 +746,7 @@ afs_LoopServers(int adown, struct cell *acellp, int vlalso,
     afs_osi_Free(conns, j * sizeof(struct afs_conn *));
     afs_osi_Free(rxconns, j * sizeof(struct rx_connection *));
     afs_osi_Free(conntimer, j * sizeof(afs_int32));
+    afs_DestroyReq(treq);
 
 } /*afs_CheckServers*/
 
@@ -1489,7 +1490,7 @@ void
 afs_GetCapabilities(struct server *ts)
 {
     Capabilities caps = {0, NULL};
-    struct vrequest treq;
+    struct vrequest *treq = NULL;
     struct afs_conn *tc;
     struct unixuser *tu;
     struct rx_connection *rxconn;
@@ -1500,16 +1501,20 @@ afs_GetCapabilities(struct server *ts)
     if ( !afs_osi_credp )
        return;
 
-    if ((code = afs_InitReq(&treq, afs_osi_credp)))
+    if ((code = afs_CreateReq(&treq, afs_osi_credp)))
        return;
-    tu = afs_GetUser(treq.uid, ts->cell->cellNum, SHARED_LOCK);
-    if ( !tu )
+    tu = afs_GetUser(treq->uid, ts->cell->cellNum, SHARED_LOCK);
+    if ( !tu ) {
+       afs_DestroyReq(treq);
        return;
+    }
     tc = afs_ConnBySA(ts->addr, ts->cell->fsport, ts->cell->cellNum, tu, 0, 1,
                      SHARED_LOCK, 0, &rxconn);
     afs_PutUser(tu, SHARED_LOCK);
-    if ( !tc )
+    if ( !tc ) {
+       afs_DestroyReq(treq);
        return;
+    }
     /* InitCallBackStateN, triggered by our RPC, may need this */
     ReleaseWriteLock(&afs_xserver);
     code = RXAFS_GetCapabilities(rxconn, &caps);
@@ -1523,6 +1528,7 @@ afs_GetCapabilities(struct server *ts)
     if ( code && code != RXGEN_OPCODE ) {
        afs_warn("RXAFS_GetCapabilities failed with code %d\n", code);
        /* better not be anything to free. we failed! */
+       afs_DestroyReq(treq);
        return;
     }
 
@@ -1535,6 +1541,7 @@ afs_GetCapabilities(struct server *ts)
        caps.Capabilities_val = NULL;
     }
 
+    afs_DestroyReq(treq);
 }
 
 static struct server *