afscp: Fix -s option for writes
authorAndrew Deason <adeason@sinenomine.net>
Thu, 27 Jan 2011 19:13:21 +0000 (13:13 -0600)
committerDerrick Brashear <shadow@dementia.org>
Tue, 8 Feb 2011 06:42:16 +0000 (22:42 -0800)
When writing to AFS with afscp, the -s option was sleeping before any
StoreData RPCs actually got issued to the fileserver. Move the sleep
to after we have done one rx_Read/rx_Write, so we sleep after starting
to contact the fileserver, to make sleeping while writing more
consistent with sleeping while reading.

Change-Id: Ib4e93b65f50cbad30d057ad7905617d00070c1a4
Reviewed-on: http://gerrit.openafs.org/3762
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>

src/tests/afscp.c

index 08b4d65..0568439 100644 (file)
@@ -484,14 +484,6 @@ main(int argc, char **argv)
        bytesremaining = ntohl(bytesremaining);
     }
 
-    if (sleeptime > 0) {
-#ifdef AFS_PTHREAD_ENV
-       sleep(sleeptime);
-#else
-       IOMGR_Sleep(sleeptime);
-#endif
-    }
-
     while (bytesremaining > 0) {
        /*printf("%d bytes remaining\n",bytesremaining); */
        if (slcl) {
@@ -515,6 +507,17 @@ main(int argc, char **argv)
            if (rx_Write(dcall, databuffer, bytes) != bytes)
                break;
        }
+
+       if (sleeptime > 0) {
+#ifdef AFS_PTHREAD_ENV
+           sleep(sleeptime);
+#else
+           IOMGR_Sleep(sleeptime);
+#endif
+           /* only sleep once */
+           sleeptime = 0;
+       }
+
        bytesremaining -= bytes;
        /*printf("%d bytes copied\n",bytes); */
     }