aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/socket_wrapper.c3
-rw-r--r--tests/test_max_sockets.c4
2 files changed, 3 insertions, 4 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 61f0f6e..12dfb74 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -1368,6 +1368,7 @@ static int socket_wrapper_first_free_index(void)
int next_free;
if (first_free == -1) {
+ errno = ENFILE;
return -1;
}
@@ -2897,7 +2898,6 @@ static int swrap_socket(int family, int type, int protocol)
idx = socket_wrapper_first_free_index();
if (idx == -1) {
- errno = ENOMEM;
return -1;
}
@@ -3113,7 +3113,6 @@ static int swrap_accept(int s,
idx = socket_wrapper_first_free_index();
if (idx == -1) {
- errno = ENOMEM;
return -1;
}
diff --git a/tests/test_max_sockets.c b/tests/test_max_sockets.c
index 0bc694b..00aa79b 100644
--- a/tests/test_max_sockets.c
+++ b/tests/test_max_sockets.c
@@ -63,7 +63,7 @@ static void test_max_sockets(void **state)
/* no free space for sockets left */
rc = _socket(&s[MAX_SOCKETS]);
assert_int_equal(rc, -1);
- assert_int_equal(errno, ENOMEM);
+ assert_int_equal(errno, ENFILE);
/* closing a socket frees up space */
close(s[0]);
@@ -73,7 +73,7 @@ static void test_max_sockets(void **state)
/* but just one */
rc = _socket(&s[MAX_SOCKETS]);
assert_int_equal(rc, -1);
- assert_int_equal(errno, ENOMEM);
+ assert_int_equal(errno, ENFILE);
for (i = 0; i < MAX_SOCKETS; i++) {
close(s[i]);