mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
Refactor impl of the virNetServerClientNew method
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@redhat.com>
This commit is contained in:
parent
42c60a7843
commit
4eb6cae884
@ -336,19 +336,15 @@ static void virNetServerClientSockTimerFunc(int timer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virNetServerClientPtr virNetServerClientNew(virNetSocketPtr sock,
|
static virNetServerClientPtr
|
||||||
int auth,
|
virNetServerClientNewInternal(virNetSocketPtr sock,
|
||||||
bool readonly,
|
int auth,
|
||||||
size_t nrequests_max,
|
bool readonly,
|
||||||
virNetTLSContextPtr tls,
|
size_t nrequests_max,
|
||||||
virNetServerClientPrivNew privNew,
|
virNetTLSContextPtr tls)
|
||||||
virFreeCallback privFree,
|
|
||||||
void *privOpaque)
|
|
||||||
{
|
{
|
||||||
virNetServerClientPtr client;
|
virNetServerClientPtr client;
|
||||||
|
|
||||||
VIR_DEBUG("sock=%p auth=%d tls=%p", sock, auth, tls);
|
|
||||||
|
|
||||||
if (virNetServerClientInitialize() < 0)
|
if (virNetServerClientInitialize() < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -381,14 +377,6 @@ virNetServerClientPtr virNetServerClientNew(virNetSocketPtr sock,
|
|||||||
}
|
}
|
||||||
client->nrequests = 1;
|
client->nrequests = 1;
|
||||||
|
|
||||||
if (privNew) {
|
|
||||||
if (!(client->privateData = privNew(client, privOpaque))) {
|
|
||||||
virObjectUnref(client);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
client->privateDataFreeFunc = privFree;
|
|
||||||
}
|
|
||||||
|
|
||||||
PROBE(RPC_SERVER_CLIENT_NEW,
|
PROBE(RPC_SERVER_CLIENT_NEW,
|
||||||
"client=%p sock=%p",
|
"client=%p sock=%p",
|
||||||
client, client->sock);
|
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 virNetServerClientGetAuth(virNetServerClientPtr client)
|
||||||
{
|
{
|
||||||
int auth;
|
int auth;
|
||||||
|
Loading…
Reference in New Issue
Block a user