aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2012-08-09 12:06:45 +0100
committerDaniel P. Berrange <berrange@redhat.com>2012-08-15 10:55:51 +0100
commit95e49be5e253248a803301ad6eeb4f00b51b44e7 (patch)
tree00de0953af2eb3a7ff5463248a4363cf6b8d2f26 /src/rpc/virnetserverservice.c
parentAdd APIs for virThreadPoolPtr to query some config params (diff)
downloadlibvirt-95e49be5e253248a803301ad6eeb4f00b51b44e7.tar.gz
libvirt-95e49be5e253248a803301ad6eeb4f00b51b44e7.tar.bz2
libvirt-95e49be5e253248a803301ad6eeb4f00b51b44e7.zip
Change interaction when accepting new RPC client connections
Currently the virNetServerServicePtr is responsible for creating the virNetServerClientPtr instance when accepting a new connection. Change this so that the virNetServerServicePtr merely gives virNetServerPtr a virNetSocketPtr instance. The virNetServerPtr can then create the virNetServerClientPtr as it desires Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'src/rpc/virnetserverservice.c')
-rw-r--r--src/rpc/virnetserverservice.c38
1 files changed, 15 insertions, 23 deletions
diff --git a/src/rpc/virnetserverservice.c b/src/rpc/virnetserverservice.c
index 000b5b6b9..eda5ef91c 100644
--- a/src/rpc/virnetserverservice.c
+++ b/src/rpc/virnetserverservice.c
@@ -69,40 +69,21 @@ static void virNetServerServiceAccept(virNetSocketPtr sock,
void *opaque)
{
virNetServerServicePtr svc = opaque;
- virNetServerClientPtr client = NULL;
virNetSocketPtr clientsock = NULL;
if (virNetSocketAccept(sock, &clientsock) < 0)
- goto error;
+ goto cleanup;
if (!clientsock) /* Connection already went away */
goto cleanup;
- if (!(client = virNetServerClientNew(clientsock,
- svc->auth,
- svc->readonly,
- svc->nrequests_client_max,
- svc->tls)))
- goto error;
-
if (!svc->dispatchFunc)
- goto error;
-
- if (svc->dispatchFunc(svc, client, svc->dispatchOpaque) < 0)
- virNetServerClientClose(client);
+ goto cleanup;
- virObjectUnref(client);
+ svc->dispatchFunc(svc, clientsock, svc->dispatchOpaque);
cleanup:
- return;
-
-error:
- if (client) {
- virNetServerClientClose(client);
- virObjectUnref(client);
- } else {
- virObjectUnref(clientsock);
- }
+ virObjectUnref(clientsock);
}
@@ -240,6 +221,17 @@ bool virNetServerServiceIsReadonly(virNetServerServicePtr svc)
}
+size_t virNetServerServiceGetMaxRequests(virNetServerServicePtr svc)
+{
+ return svc->nrequests_client_max;
+}
+
+virNetTLSContextPtr virNetServerServiceGetTLSContext(virNetServerServicePtr svc)
+{
+ return svc->tls;
+}
+
+
void virNetServerServiceSetDispatcher(virNetServerServicePtr svc,
virNetServerServiceDispatchFunc func,
void *opaque)