mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
remote: create virNetServerServiceNewFDOrUNIX() wrapper
It's just a wrapper around NewFD and NewUNIX that selects the right option and increments the number of used FDs. Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
8989597cd9
commit
9805256d53
@ -159,6 +159,7 @@ virNetServerServiceGetMaxRequests;
|
|||||||
virNetServerServiceGetPort;
|
virNetServerServiceGetPort;
|
||||||
virNetServerServiceIsReadonly;
|
virNetServerServiceIsReadonly;
|
||||||
virNetServerServiceNewFD;
|
virNetServerServiceNewFD;
|
||||||
|
virNetServerServiceNewFDOrUNIX;
|
||||||
virNetServerServiceNewPostExecRestart;
|
virNetServerServiceNewPostExecRestart;
|
||||||
virNetServerServiceNewTCP;
|
virNetServerServiceNewTCP;
|
||||||
virNetServerServiceNewUNIX;
|
virNetServerServiceNewUNIX;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* virnetserverservice.c: generic network RPC server service
|
* virnetserverservice.c: generic network RPC server service
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2012 Red Hat, Inc.
|
* Copyright (C) 2006-2012, 2014 Red Hat, Inc.
|
||||||
* Copyright (C) 2006 Daniel P. Berrange
|
* Copyright (C) 2006 Daniel P. Berrange
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#include "virnetserverservice.h"
|
#include "virnetserverservice.h"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "viralloc.h"
|
#include "viralloc.h"
|
||||||
#include "virerror.h"
|
#include "virerror.h"
|
||||||
#include "virthread.h"
|
#include "virthread.h"
|
||||||
@ -90,6 +92,52 @@ static void virNetServerServiceAccept(virNetSocketPtr sock,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virNetServerServicePtr
|
||||||
|
virNetServerServiceNewFDOrUNIX(const char *path,
|
||||||
|
mode_t mask,
|
||||||
|
gid_t grp,
|
||||||
|
int auth,
|
||||||
|
#if WITH_GNUTLS
|
||||||
|
virNetTLSContextPtr tls,
|
||||||
|
#endif
|
||||||
|
bool readonly,
|
||||||
|
size_t max_queued_clients,
|
||||||
|
size_t nrequests_client_max,
|
||||||
|
unsigned int nfds,
|
||||||
|
unsigned int *cur_fd)
|
||||||
|
{
|
||||||
|
if (*cur_fd - STDERR_FILENO > nfds) {
|
||||||
|
/*
|
||||||
|
* There are no more file descriptors to use, so we have to
|
||||||
|
* fallback to UNIX socket.
|
||||||
|
*/
|
||||||
|
return virNetServerServiceNewUNIX(path,
|
||||||
|
mask,
|
||||||
|
grp,
|
||||||
|
auth,
|
||||||
|
#if WITH_GNUTLS
|
||||||
|
tls,
|
||||||
|
#endif
|
||||||
|
readonly,
|
||||||
|
max_queued_clients,
|
||||||
|
nrequests_client_max);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* There's still enough file descriptors. In this case we'll
|
||||||
|
* use the current one and increment it afterwards.
|
||||||
|
*/
|
||||||
|
return virNetServerServiceNewFD(*cur_fd++,
|
||||||
|
auth,
|
||||||
|
#if WITH_GNUTLS
|
||||||
|
tls,
|
||||||
|
#endif
|
||||||
|
readonly,
|
||||||
|
nrequests_client_max);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
virNetServerServicePtr virNetServerServiceNewTCP(const char *nodename,
|
virNetServerServicePtr virNetServerServiceNewTCP(const char *nodename,
|
||||||
const char *service,
|
const char *service,
|
||||||
int auth,
|
int auth,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* virnetserverservice.h: generic network RPC server service
|
* virnetserverservice.h: generic network RPC server service
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2011 Red Hat, Inc.
|
* Copyright (C) 2006-2011, 2014 Red Hat, Inc.
|
||||||
* Copyright (C) 2006 Daniel P. Berrange
|
* Copyright (C) 2006 Daniel P. Berrange
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
@ -37,6 +37,18 @@ typedef int (*virNetServerServiceDispatchFunc)(virNetServerServicePtr svc,
|
|||||||
virNetSocketPtr sock,
|
virNetSocketPtr sock,
|
||||||
void *opaque);
|
void *opaque);
|
||||||
|
|
||||||
|
virNetServerServicePtr virNetServerServiceNewFDOrUNIX(const char *path,
|
||||||
|
mode_t mask,
|
||||||
|
gid_t grp,
|
||||||
|
int auth,
|
||||||
|
# if WITH_GNUTLS
|
||||||
|
virNetTLSContextPtr tls,
|
||||||
|
# endif
|
||||||
|
bool readonly,
|
||||||
|
size_t max_queued_clients,
|
||||||
|
size_t nrequests_client_max,
|
||||||
|
unsigned int nfds,
|
||||||
|
unsigned int *cur_fd);
|
||||||
virNetServerServicePtr virNetServerServiceNewTCP(const char *nodename,
|
virNetServerServicePtr virNetServerServiceNewTCP(const char *nodename,
|
||||||
const char *service,
|
const char *service,
|
||||||
int auth,
|
int auth,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user