Problem: test_system fails on Solaris due to lower file limit

Solution: use a different max socket value on Solaris, where the
default limit is 256 instead of 1024
This commit is contained in:
Luca Boccassi 2018-05-13 13:18:08 +01:00
parent b78cfb2395
commit 510a42c3d5

View File

@ -38,6 +38,13 @@
#include <unistd.h>
#endif
// Solaris has a default of 256 max files per process
#ifdef ZMQ_HAVE_SOLARIS
#define MAX_SOCKETS 200
#else
#define MAX_SOCKETS 1000
#endif
#if defined(ZMQ_HAVE_WINDOWS)
void initialise_network (void)
@ -75,9 +82,9 @@ int main (void)
return -1;
}
// Check that we can create 1,000 sockets
int handle[1000];
int handle[MAX_SOCKETS];
int count;
for (count = 0; count < 1000; count++) {
for (count = 0; count < MAX_SOCKETS; count++) {
handle[count] = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (handle[count] == -1) {
printf ("W: Only able to create %d sockets on this box\n", count);
@ -92,7 +99,7 @@ int main (void)
}
}
// Release the socket handles
for (count = 0; count < 1000; count++) {
for (count = 0; count < MAX_SOCKETS; count++) {
close (handle[count]);
}