mirror of
https://github.com/moparisthebest/curl
synced 2024-08-13 17:03:50 -04:00
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.
This commit is contained in:
parent
e485a23a3e
commit
c2639e0738
@ -360,16 +360,31 @@ static int rlimit(int keep_open)
|
|||||||
* with an indication that select limit would be exceeded.
|
* with an indication that select limit would be exceeded.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sprintf(strbuff2, fmt, num_open.rlim_max);
|
num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN;
|
||||||
sprintf(strbuff, "fds open %s > select limit %d",
|
if (num_open.rlim_max > num_open.rlim_cur) {
|
||||||
strbuff2, FD_SETSIZE);
|
sprintf(strbuff, "select limit is FD_SETSIZE %d", FD_SETSIZE);
|
||||||
store_errmsg(strbuff, 0);
|
store_errmsg(strbuff, 0);
|
||||||
fprintf(stderr, "%s\n", msgbuff);
|
fprintf(stderr, "%s\n", msgbuff);
|
||||||
close_file_descriptors();
|
close_file_descriptors();
|
||||||
free(memchunk);
|
free(memchunk);
|
||||||
return -10;
|
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
|
/* free the chunk of memory we were reserving so that it
|
||||||
becomes becomes available to the test */
|
becomes becomes available to the test */
|
||||||
|
@ -26,6 +26,14 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(HAVE_POLL_FINE) && \
|
||||||
|
!defined(CURL_HAVE_WSAPOLL) && \
|
||||||
|
!defined(USE_WINSOCK) && \
|
||||||
|
!defined(TPF) && \
|
||||||
|
!defined(FD_SETSIZE)
|
||||||
|
#error "this test requires FD_SETSIZE"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SAFETY_MARGIN (10)
|
#define SAFETY_MARGIN (10)
|
||||||
|
|
||||||
#if defined(WIN32) || defined(_WIN32) || defined(MSDOS)
|
#if defined(WIN32) || defined(_WIN32) || defined(MSDOS)
|
||||||
@ -356,16 +364,31 @@ static int rlimit(int keep_open)
|
|||||||
* with an indication that select limit would be exceeded.
|
* with an indication that select limit would be exceeded.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sprintf(strbuff1, fmt, num_open.rlim_max);
|
num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN;
|
||||||
sprintf(strbuff, "fds open %s > select limit %d",
|
if (num_open.rlim_max > num_open.rlim_cur) {
|
||||||
strbuff1, FD_SETSIZE);
|
sprintf(strbuff, "select limit is FD_SETSIZE %d", FD_SETSIZE);
|
||||||
store_errmsg(strbuff, 0);
|
store_errmsg(strbuff, 0);
|
||||||
fprintf(stderr, "%s\n", msgbuff);
|
fprintf(stderr, "%s\n", msgbuff);
|
||||||
close_file_descriptors();
|
close_file_descriptors();
|
||||||
free(memchunk);
|
free(memchunk);
|
||||||
return -8;
|
return -8;
|
||||||
|
}
|
||||||
|
|
||||||
#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 -9;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* using a FD_SETSIZE bound select() */
|
||||||
|
|
||||||
/* free the chunk of memory we were reserving so that it
|
/* free the chunk of memory we were reserving so that it
|
||||||
becomes becomes available to the test */
|
becomes becomes available to the test */
|
||||||
|
Loading…
Reference in New Issue
Block a user