From: "Daniel P. Berrange" <berrange(a)redhat.com>
In preparation for adding further constructors, refactor
the virNetServerClientNew method to move most of the code
into a common virNetServerClientNewInternal helper API.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/rpc/virnetserverclient.c | 52 +++++++++++++++++++++++++++++---------------
1 file changed, 34 insertions(+), 18 deletions(-)
diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
index c9703fd..acd2b4d 100644
--- a/src/rpc/virnetserverclient.c
+++ b/src/rpc/virnetserverclient.c
@@ -336,19 +336,15 @@ static void virNetServerClientSockTimerFunc(int timer,
}
-virNetServerClientPtr virNetServerClientNew(virNetSocketPtr sock,
- int auth,
- bool readonly,
- size_t nrequests_max,
- virNetTLSContextPtr tls,
- virNetServerClientPrivNew privNew,
- virFreeCallback privFree,
- void *privOpaque)
+static virNetServerClientPtr
+virNetServerClientNewInternal(virNetSocketPtr sock,
+ int auth,
+ bool readonly,
+ size_t nrequests_max,
+ virNetTLSContextPtr tls)
{
virNetServerClientPtr client;
- VIR_DEBUG("sock=%p auth=%d tls=%p", sock, auth, tls);
-
if (virNetServerClientInitialize() < 0)
return NULL;
@@ -381,14 +377,6 @@ virNetServerClientPtr virNetServerClientNew(virNetSocketPtr sock,
}
client->nrequests = 1;
- if (privNew) {
- if (!(client->privateData = privNew(client, privOpaque))) {
- virObjectUnref(client);
- goto error;
- }
- client->privateDataFreeFunc = privFree;
- }
-
PROBE(RPC_SERVER_CLIENT_NEW,
"client=%p sock=%p",
client, client->sock);
@@ -401,6 +389,34 @@ error:
}
+virNetServerClientPtr virNetServerClientNew(virNetSocketPtr sock,
+ int auth,
+ bool readonly,
+ size_t nrequests_max,
+ virNetTLSContextPtr tls,
+ virNetServerClientPrivNew privNew,
+ virFreeCallback privFree,
+ void *privOpaque)
+{
+ virNetServerClientPtr client;
+
+ VIR_DEBUG("sock=%p auth=%d tls=%p", sock, auth, tls);
+
+ if (!(client = virNetServerClientNewInternal(sock, auth, readonly, nrequests_max,
tls)))
+ return NULL;
+
+ if (privNew) {
+ if (!(client->privateData = privNew(client, privOpaque))) {
+ virObjectUnref(client);
+ return NULL;
+ }
+ client->privateDataFreeFunc = privFree;
+ }
+
+ return client;
+}
+
+
int virNetServerClientGetAuth(virNetServerClientPtr client)
{
int auth;
--
1.7.11.2