Skip to contentSkip to conversation

generic/478: fix potential test blocking

PATCH New Xiong Zhou 1 participant 1 message Mar 23, 2018

lore
Share & tools
lore

Xiong Zhou

author
#0 lore raw

PATCH 1/1 generic/478: fix potential test blocking

Reduce semtimedop timeout to 5s, 15s is too long if something get tangled up. Add retry counting to getlk routine, infinite loop is dangerous. If something goes wrong unexpextedly, test is blocked wasting time.

---

We are hitting this when testing on cifs samba 2.0.

 src/t_ofd_locks.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
src/t_ofd_locks.c +9 -6
index d578cd7..454b2ce 100644
@@ -317,14 +317,14 @@ int main(int argc, char **argv)
 		sop.sem_num = 0;
 		sop.sem_op = 1;
 		sop.sem_flg = 0;
-		ts.tv_sec = 15;
+		ts.tv_sec = 5;
 		ts.tv_nsec = 0;
 		if (semtimedop(semid, &sop, 1, &ts) == -1)
 			err_exit("inc sem0 2", errno);
 		sop.sem_num = 1;
 		sop.sem_op = 1;
 		sop.sem_flg = 0;
-		ts.tv_sec = 15;
+		ts.tv_sec = 5;
 		ts.tv_nsec = 0;
 		if (semtimedop(semid, &sop, 1, &ts) == -1)
 			err_exit("inc sem1 2", errno);
@@ -376,7 +376,7 @@ int main(int argc, char **argv)
 		sop.sem_num = 1;
 		sop.sem_op = 0;
 		sop.sem_flg = 0;
-		ts.tv_sec = 15;
+		ts.tv_sec = 5;
 		ts.tv_nsec = 0;
 		if (semtimedop(semid, &sop, 1, &ts) == -1)
 			err_exit("wait sem1 0", errno);
@@ -391,13 +391,16 @@ int main(int argc, char **argv)
 	/* getlck */
 	if (lock_cmd == 0) {
 		/* wait sem created and initialized */
+		retry = 5;
 		do {
 			semid = semget(semkey, 2, 0);
 			if (semid != -1)
 				break;
-			if (errno == ENOENT)
+			if (errno == ENOENT && retry) {
+				sleep(1);
+				retry--;
 				continue;
-			else
+			} else
 				err_exit("getlk_semget", errno);
 		} while (1);
 		do {
@@ -410,7 +413,7 @@ int main(int argc, char **argv)
 		sop.sem_num = 0;
 		sop.sem_op = 0;
 		sop.sem_flg = 0;
-		ts.tv_sec = 15;
+		ts.tv_sec = 5;
 		ts.tv_nsec = 0;
 		if (semtimedop(semid, &sop, 1, &ts) == -1)
 			err_exit("wait sem0 0", errno);
Signature · 1 line
1.8.3.1