(rl.rlim_cur <= num_open.rlim_cur)) {
sprintf(strbuff2, fmt, rl.rlim_cur);
sprintf(strbuff1, fmt, num_open.rlim_cur);
- sprintf(strbuff, "fd needed (%s) > system limit (%s)",
+ sprintf(strbuff, "fds needed %s > system limit %s",
strbuff1, strbuff2);
store_errmsg(strbuff, 0);
fprintf(stderr, "%s\n", msgbuff);
* that it becomes available to the test.
*/
- nitems = INT_MAX / sizeof(*memchunk);
+ for (nitems = i = 1; nitems <= i; i *= 2)
+ nitems = i;
+ if (nitems > 0x7fff)
+ nitems = 0x40000;
do {
+ num_open.rlim_max = sizeof(*memchunk) * (size_t)nitems;
+ sprintf(strbuff, fmt, num_open.rlim_max);
+ fprintf(stderr, "allocating memchunk %s byte array\n", strbuff);
memchunk = malloc(sizeof(*memchunk) * (size_t)nitems);
- if (!memchunk)
+ if (!memchunk) {
+ fprintf(stderr, "memchunk, malloc() failed\n");
nitems /= 2;
+ }
} while (nitems && !memchunk);
if (!memchunk) {
store_errmsg("memchunk, malloc() failed", our_errno());
/* initialize it to fight lazy allocation */
+ fprintf(stderr, "initializing memchunk array\n");
+
for (i = 0; i < nitems; i++)
memchunk[i] = -1;
/* initialize it to fight lazy allocation */
+ fprintf(stderr, "initializing fd array\n");
+
for (num_open.rlim_cur = 0;
num_open.rlim_cur < num_open.rlim_max;
num_open.rlim_cur++)
num_open.rlim_max = NUM_NEEDED;
sprintf(strbuff2, fmt, num_open.rlim_max);
sprintf(strbuff1, fmt, num_open.rlim_cur);
- sprintf(strbuff, "fd needed (%s) > system limit (%s)",
+ sprintf(strbuff, "fds needed %s > system limit %s",
strbuff2, strbuff1);
store_errmsg(strbuff, 0);
fprintf(stderr, "%s\n", msgbuff);
* that it becomes available to the test.
*/
- nitems = INT_MAX / sizeof(*memchunk);
+ for (nitems = i = 1; nitems <= i; i *= 2)
+ nitems = i;
+ if (nitems > 0x7fff)
+ nitems = 0x40000;
do {
+ num_open.rlim_max = sizeof(*memchunk) * (size_t)nitems;
+ sprintf(strbuff, fmt, num_open.rlim_max);
+ fprintf(stderr, "allocating memchunk %s byte array\n", strbuff);
memchunk = malloc(sizeof(*memchunk) * (size_t)nitems);
- if (!memchunk)
+ if (!memchunk) {
+ fprintf(stderr, "memchunk, malloc() failed\n");
nitems /= 2;
+ }
} while (nitems && !memchunk);
if (!memchunk) {
store_errmsg("memchunk, malloc() failed", our_errno());
/* initialize it to fight lazy allocation */
+ fprintf(stderr, "initializing memchunk array\n");
+
for (i = 0; i < nitems; i++)
memchunk[i] = -1;
}
else {
/* a huge number of file descriptors */
- num_open.rlim_max = INT_MAX / sizeof(*fd);
+ for (nitems = i = 1; nitems <= i; i *= 2)
+ nitems = i;
+ if (nitems > 0x7fff)
+ nitems = 0x40000;
+ num_open.rlim_max = nitems;
}
/* verify that we won't overflow size_t in malloc() */
/* initialize it to fight lazy allocation */
+ fprintf(stderr, "initializing fd array\n");
+
for (num_open.rlim_cur = 0;
num_open.rlim_cur < num_open.rlim_max;
num_open.rlim_cur++)