So that callers can change the default value.
---
src/rpc/virnetserverservice.c | 4 ++--
src/rpc/virnetsocket.c | 4 ++--
src/rpc/virnetsocket.h | 2 +-
tests/virnetsockettest.c | 6 +++---
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/rpc/virnetserverservice.c b/src/rpc/virnetserverservice.c
index 8c9ed1e..e63603f 100644
--- a/src/rpc/virnetserverservice.c
+++ b/src/rpc/virnetserverservice.c
@@ -127,7 +127,7 @@ virNetServerServicePtr virNetServerServiceNewTCP(const char
*nodename,
goto error;
for (i = 0 ; i < svc->nsocks ; i++) {
- if (virNetSocketListen(svc->socks[i]) < 0)
+ if (virNetSocketListen(svc->socks[i], 0) < 0)
goto error;
/* IO callback is initially disabled, until we're ready
@@ -187,7 +187,7 @@ virNetServerServicePtr virNetServerServiceNewUNIX(const char *path,
goto error;
for (i = 0 ; i < svc->nsocks ; i++) {
- if (virNetSocketListen(svc->socks[i]) < 0)
+ if (virNetSocketListen(svc->socks[i], 0) < 0)
goto error;
/* IO callback is initially disabled, until we're ready
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index c222743..c19dcfa 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -1076,10 +1076,10 @@ ssize_t virNetSocketWrite(virNetSocketPtr sock, const char *buf,
size_t len)
}
-int virNetSocketListen(virNetSocketPtr sock)
+int virNetSocketListen(virNetSocketPtr sock, int backlog)
{
virMutexLock(&sock->lock);
- if (listen(sock->fd, 30) < 0) {
+ if (listen(sock->fd, backlog > 0 ? backlog : 30) < 0) {
virReportSystemError(errno, "%s", _("Unable to listen on
socket"));
virMutexUnlock(&sock->lock);
return -1;
diff --git a/src/rpc/virnetsocket.h b/src/rpc/virnetsocket.h
index d6c85d2..24110a6 100644
--- a/src/rpc/virnetsocket.h
+++ b/src/rpc/virnetsocket.h
@@ -105,7 +105,7 @@ void virNetSocketFree(virNetSocketPtr sock);
const char *virNetSocketLocalAddrString(virNetSocketPtr sock);
const char *virNetSocketRemoteAddrString(virNetSocketPtr sock);
-int virNetSocketListen(virNetSocketPtr sock);
+int virNetSocketListen(virNetSocketPtr sock, int backlog);
int virNetSocketAccept(virNetSocketPtr sock,
virNetSocketPtr *clientsock);
diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c
index e72b9a0..fba7e15 100644
--- a/tests/virnetsockettest.c
+++ b/tests/virnetsockettest.c
@@ -159,7 +159,7 @@ static int testSocketTCPAccept(const void *opaque)
goto cleanup;
for (i = 0 ; i < nlsock ; i++) {
- if (virNetSocketListen(lsock[i]) < 0)
+ if (virNetSocketListen(lsock[i], 0) < 0)
goto cleanup;
}
@@ -217,7 +217,7 @@ static int testSocketUNIXAccept(const void *data ATTRIBUTE_UNUSED)
if (virNetSocketNewListenUNIX(path, 0700, getgid(), &lsock) < 0)
goto cleanup;
- if (virNetSocketListen(lsock) < 0)
+ if (virNetSocketListen(lsock, 0) < 0)
goto cleanup;
if (virNetSocketNewConnectUNIX(path, false, NULL, &csock) < 0)
@@ -276,7 +276,7 @@ static int testSocketUNIXAddrs(const void *data ATTRIBUTE_UNUSED)
goto cleanup;
}
- if (virNetSocketListen(lsock) < 0)
+ if (virNetSocketListen(lsock, 0) < 0)
goto cleanup;
if (virNetSocketNewConnectUNIX(path, false, NULL, &csock) < 0)
--
1.7.6