summaryrefslogtreecommitdiff
path: root/tests/libtest/lib518.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2007-01-31 15:34:53 +0000
committerYang Tse <yangsita@gmail.com>2007-01-31 15:34:53 +0000
commitc2639e07388464dd920fe239358458e42658b278 (patch)
tree476e61f6763ffdbd700d1521e3cc78783847fde8 /tests/libtest/lib518.c
parente485a23a3e24d6b8149bc87285ff46c6eee1266d (diff)
downloadcurl-c2639e07388464dd920fe239358458e42658b278.tar.gz
when using select() instead of poll, skip the test if the number of
open file descriptors is greater than FD_SETSIZE minus SAFETY_MARGIN, also skip the test if any of the open file descriptors has a number greater than FD_SETSIZE minus SAFETY_MARGIN.
Diffstat (limited to 'tests/libtest/lib518.c')
-rw-r--r--tests/libtest/lib518.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c
index 47cea8244..368b902ae 100644
--- a/tests/libtest/lib518.c
+++ b/tests/libtest/lib518.c
@@ -360,16 +360,31 @@ static int rlimit(int keep_open)
* with an indication that select limit would be exceeded.
*/
- sprintf(strbuff2, fmt, num_open.rlim_max);
- sprintf(strbuff, "fds open %s > select limit %d",
- strbuff2, FD_SETSIZE);
- store_errmsg(strbuff, 0);
- fprintf(stderr, "%s\n", msgbuff);
- close_file_descriptors();
- free(memchunk);
- return -10;
+ num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN;
+ if (num_open.rlim_max > num_open.rlim_cur) {
+ sprintf(strbuff, "select limit is FD_SETSIZE %d", FD_SETSIZE);
+ store_errmsg(strbuff, 0);
+ fprintf(stderr, "%s\n", msgbuff);
+ close_file_descriptors();
+ free(memchunk);
+ return -10;
+ }
-#endif
+ num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN;
+ for (rl.rlim_cur = 0;
+ rl.rlim_cur < num_open.rlim_max;
+ rl.rlim_cur++) {
+ if (fd[rl.rlim_cur] > num_open.rlim_cur) {
+ sprintf(strbuff, "select limit is FD_SETSIZE %d", FD_SETSIZE);
+ store_errmsg(strbuff, 0);
+ fprintf(stderr, "%s\n", msgbuff);
+ close_file_descriptors();
+ free(memchunk);
+ return -11;
+ }
+ }
+
+#endif /* using a FD_SETSIZE bound select() */
/* free the chunk of memory we were reserving so that it
becomes becomes available to the test */