From: Marc Dionne Date: Wed, 6 Apr 2011 01:30:20 +0000 (-0400) Subject: ubik: don't rely on timeout value after select() X-Git-Tag: upstream/1.6.1.pre1^2~49 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=a9ee7f8f821f73ba0a1dd6a8fd8ed4abc8ef9040;p=packages%2Fo%2Fopenafs.git ubik: don't rely on timeout value after select() The value of timeout after a select() call should be considered undefined; relying on its value is not portable. Since IOMGR_Select doesn't modify the timeout it is given, the intention of the code seems to be to wait for gradually increasing timeout values, starting at 50ms. At least under Linux, the timeout gets set to 0 by select() if it waited for the full specified time, resulting in a much shorter maximum possible wait period. Initialize the timeout value for each loop according to the existing logic, to get consistent behaviour between the lwp and pthreaded code. Reviewed-on: http://gerrit.openafs.org/4441 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Reviewed-by: Derrick Brashear (cherry picked from commit 0b510fe30afb34202342364e96bd9030052e1567) Change-Id: I24eb4d4b1f758f33e3517671cb576ff23e641fb3 Reviewed-on: http://gerrit.openafs.org/6282 Tested-by: Derrick Brashear Reviewed-by: Derrick Brashear --- diff --git a/src/ubik/recovery.c b/src/ubik/recovery.c index 3ad7b9853..f0b09ae63 100644 --- a/src/ubik/recovery.c +++ b/src/ubik/recovery.c @@ -776,17 +776,18 @@ urecovery_Interact(void *dummy) if (ubik_dbase->flags & DBWRITING) { struct timeval tv; int safety = 0; - tv.tv_sec = 0; - tv.tv_usec = 50000; + long cur_usec = 50000; while ((ubik_dbase->flags & DBWRITING) && (safety < 500)) { DBRELE(ubik_dbase); /* sleep for a little while */ + tv.tv_sec = 0; + tv.tv_usec = cur_usec; #ifdef AFS_PTHREAD_ENV select(0, 0, 0, 0, &tv); #else IOMGR_Select(0, 0, 0, 0, &tv); #endif - tv.tv_usec += 10000; + cur_usec += 10000; safety++; DBHOLD(ubik_dbase); }