Skip to content

Commit 7e356ff

Browse files
committed
stress-shm: make child always send a termination message on return
A few of the early child return paths don't inform the parent that they are terminating over the pipe, fix this. Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
1 parent 36710a9 commit 7e356ff

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

stress-shm.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,15 @@ static int stress_shm_posix_child(
115115
addrs = (void **)calloc(shm_posix_objects, sizeof(*addrs));
116116
if (!addrs) {
117117
pr_fail("%s: calloc on addrs failed, out of memory\n", args->name);
118-
return EXIT_NO_RESOURCE;
118+
rc = EXIT_NO_RESOURCE;
119+
goto shm_end_of_run;
119120
}
120121
shm_names = (char *)calloc(shm_posix_objects, SHM_NAME_LEN);
121122
if (!shm_names) {
122123
free(addrs);
123124
pr_fail("%s: calloc on shm_names, out of memory\n", args->name);
124-
return EXIT_NO_RESOURCE;
125+
rc = EXIT_NO_RESOURCE;
126+
goto shm_end_of_run;
125127
}
126128

127129
/* Make sure this is killable by OOM killer */
@@ -138,7 +140,8 @@ static int stress_shm_posix_child(
138140
args->name, errno, strerror(errno));
139141
free(addrs);
140142
free(shm_names);
141-
return EXIT_NO_RESOURCE;
143+
rc = EXIT_NO_RESOURCE;
144+
goto shm_end_of_run;
142145
}
143146

144147
do {
@@ -345,6 +348,10 @@ static int stress_shm_posix_child(
345348
}
346349
} while (ok && stress_continue(args));
347350

351+
free(shm_names);
352+
free(addrs);
353+
354+
shm_end_of_run:
348355
/* Inform parent of end of run */
349356
msg.index = -1;
350357
(void)shim_strscpy(msg.shm_name, "", SHM_NAME_LEN);
@@ -353,8 +360,6 @@ static int stress_shm_posix_child(
353360
args->name, errno, strerror(errno));
354361
rc = EXIT_FAILURE;
355362
}
356-
free(shm_names);
357-
free(addrs);
358363

359364
return rc;
360365
}
@@ -482,7 +487,7 @@ static int stress_shm(stress_args_t *args)
482487
args->name, errno, strerror(errno));
483488
break;
484489
}
485-
pr_fail("%s: pipe read returned zero bytes of data\n", args->name);
490+
pr_fail("%s: pipe read returned zero bytes of data (child died prematurely?)\n", args->name);
486491
break;
487492
}
488493
if (UNLIKELY((msg.index < 0) ||

0 commit comments

Comments
 (0)