Date: Tue, 21 Mar 2017 08:24:41 +0000 (UTC) From: Peter Holm <pho@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r315664 - user/pho/stress2/lib Message-ID: <201703210824.v2L8Ofwj001491@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pho Date: Tue Mar 21 08:24:40 2017 New Revision: 315664 URL: https://svnweb.freebsd.org/changeset/base/315664 Log: Limit number of retries. Sponsored by: Dell EMC Isilon Modified: user/pho/stress2/lib/resources.c Modified: user/pho/stress2/lib/resources.c ============================================================================== --- user/pho/stress2/lib/resources.c Tue Mar 21 08:23:44 2017 (r315663) +++ user/pho/stress2/lib/resources.c Tue Mar 21 08:24:40 2017 (r315664) @@ -157,25 +157,23 @@ void cleanupdf() void getdf(int64_t *block, int64_t *inode) { - int i, j; + int i; char buf[128]; snprintf(lockpath, sizeof(lockpath), "%s/lock", op->cd); - for (j = 0; j < 10; j++) { - for (i = 0; i < 10000; i++) { - if ((lockfd = open(lockpath, - O_CREAT | O_TRUNC | O_WRONLY | O_EXCL, 0644)) != -1) - break; - usleep(10000); /* sleep 1/100 sec */ - if (i > 0 && i % 1000 == 0) - fprintf(stderr, "%s is waiting for lock file %s\n", - getprogname(), lockpath); - } - if (lockfd != -1) + for (i = 0; i < 10000; i++) { + if ((lockfd = open(lockpath, + O_CREAT | O_TRUNC | O_WRONLY | O_EXCL, 0644)) != -1) break; - fprintf(stderr, "%s. Removing stale %s\n", getprogname(), lockpath); - unlink(lockpath); + usleep(10000); /* sleep 1/100 sec */ + if (i > 0 && i % 1000 == 0) + fprintf(stderr, "%s is waiting for lock file %s\n", + getprogname(), lockpath); } + if (lockfd != -1) + break; + fprintf(stderr, "%s. Removing stale %s\n", getprogname(), lockpath); + unlink(lockpath); if (lockfd == -1) errx(1, "%s. Can not create %s\n", getprogname(), lockpath); snprintf(dfpath, sizeof(dfpath), "%s/df", op->cd);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703210824.v2L8Ofwj001491>