[EXAMPLE PATCH 13/15] rpc: Add virNetSubServerGetNClients

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This function accesses the number of connected clients while properly
locking the subserver it returns the data about.

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 src/libvirt_remote.syms   |  1 +
 src/rpc/virnetsubserver.c | 10 ++++++++++
 src/rpc/virnetsubserver.h |  2 ++
 3 files changed, 13 insertions(+)

diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms
index f7cf226..8501b90 100644
--- a/src/libvirt_remote.syms
+++ b/src/libvirt_remote.syms
@@ -209,6 +209,7 @@ virNetSocketWrite;
 virNetSubServerAddProgram;
 virNetSubServerAddService;
 virNetSubServerClose;
+virNetSubServerGetNClients;
 virNetSubServerHasClients;
 virNetSubServerKeepAliveRequired;
 virNetSubServerNew;
diff --git a/src/rpc/virnetsubserver.c b/src/rpc/virnetsubserver.c
index 8d9defb..a2c6568 100644
--- a/src/rpc/virnetsubserver.c
+++ b/src/rpc/virnetsubserver.c
@@ -660,3 +660,13 @@ virNetSubServerProcessClients(virNetSubServerPtr subsrv)

     virObjectUnlock(subsrv);
 }
+
+size_t
+virNetSubServerGetNClients(virNetSubServerPtr subsrv)
+{
+    size_t ret = 0;
+    virObjectLock(subsrv);
+    ret = subsrv->nclients;
+    virObjectUnlock(subsrv);
+    return ret;
+}
diff --git a/src/rpc/virnetsubserver.h b/src/rpc/virnetsubserver.h
index cf7c213..0b943f8 100644
--- a/src/rpc/virnetsubserver.h
+++ b/src/rpc/virnetsubserver.h
@@ -73,4 +73,6 @@ void virNetSubServerProcessClients(virNetSubServerPtr subsrv);

 void virNetSubServerUpdateServices(virNetSubServerPtr subsrv, bool enabled);

+size_t virNetSubServerGetNClients(virNetSubServerPtr subsrv);
+
 #endif /* __VIR_NET_SUBSERVER_H__ */
--
2.3.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]