Add backlog parameter to virNetSocketListen

So that callers can change the default value.
This commit is contained in:
Jiri Denemark 2011-08-12 11:07:51 +02:00
parent f4287c7676
commit 70e4295bc4
4 changed files with 8 additions and 8 deletions

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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)