The ability to use virObjectLockable allows to unlock an object at the prepare stage inside the Main Event Loop. Co-authored-by: Denis V. Lunev <den@xxxxxxxxxx> Co-authored-by: Nikolai Barybin <nikolai.barybin@xxxxxxxxxxxxx> Signed-off-by: Fima Shevrin <efim.shevrin@xxxxxxxxxxxxx> --- src/rpc/virnetclient.c | 6 +++--- src/util/vireventglib.c | 4 ++-- src/util/vireventglibwatch.c | 15 ++++++++++++--- src/util/vireventglibwatch.h | 5 ++++- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 4ab8af68c5..de8ebc2da9 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -895,7 +895,7 @@ virNetClientTLSHandshake(virNetClient *client) source = virEventGLibAddSocketWatch(virNetSocketGetFD(client->sock), ev, client->eventCtx, - virNetClientIOEventTLS, client, NULL); + virNetClientIOEventTLS, client, NULL, NULL); return TRUE; } @@ -990,7 +990,7 @@ int virNetClientSetTLSSession(virNetClient *client, source = virEventGLibAddSocketWatch(virNetSocketGetFD(client->sock), G_IO_IN, client->eventCtx, - virNetClientIOEventTLSConfirm, client, NULL); + virNetClientIOEventTLSConfirm, client, NULL, NULL); #ifndef WIN32 /* Block SIGWINCH from interrupting poll in curses programs */ @@ -1695,7 +1695,7 @@ static int virNetClientIOEventLoop(virNetClient *client, source = virEventGLibAddSocketWatch(virNetSocketGetFD(client->sock), ev, client->eventCtx, - virNetClientIOEventFD, &data, NULL); + virNetClientIOEventFD, &data, NULL, NULL); /* Release lock while poll'ing so other threads * can stuff themselves on the queue */ diff --git a/src/util/vireventglib.c b/src/util/vireventglib.c index 023dc37445..fd348eaa05 100644 --- a/src/util/vireventglib.c +++ b/src/util/vireventglib.c @@ -149,7 +149,7 @@ virEventGLibHandleAdd(int fd, if (events != 0) { data->source = virEventGLibAddSocketWatch( - fd, cond, NULL, virEventGLibHandleDispatch, data, NULL); + fd, cond, NULL, virEventGLibHandleDispatch, data, NULL, NULL); } g_ptr_array_add(handles, data); @@ -217,7 +217,7 @@ virEventGLibHandleUpdate(int watch, } data->source = virEventGLibAddSocketWatch( - data->fd, cond, NULL, virEventGLibHandleDispatch, data, NULL); + data->fd, cond, NULL, virEventGLibHandleDispatch, data, NULL, NULL); data->events = events; VIR_DEBUG("Added new handle source=%p", data->source); diff --git a/src/util/vireventglibwatch.c b/src/util/vireventglibwatch.c index b21e505731..7680656ba2 100644 --- a/src/util/vireventglibwatch.c +++ b/src/util/vireventglibwatch.c @@ -29,6 +29,7 @@ struct virEventGLibFDSource { GPollFD pollfd; int fd; GIOCondition condition; + virObjectLockable *client; }; @@ -80,7 +81,8 @@ static GSourceFuncs virEventGLibFDSourceFuncs = { GSource *virEventGLibCreateSocketWatch(int fd, - GIOCondition condition) + GIOCondition condition, + virObjectLockable *client) { GSource *source; virEventGLibFDSource *ssource; @@ -95,6 +97,8 @@ GSource *virEventGLibCreateSocketWatch(int fd, ssource->pollfd.fd = fd; ssource->pollfd.events = condition | G_IO_HUP | G_IO_ERR; + ssource->client = client; + g_source_add_poll(source, &ssource->pollfd); return source; @@ -114,6 +118,7 @@ struct virEventGLibSocketSource { HANDLE event; int revents; GIOCondition condition; + virObjectLockable *client; }; @@ -203,7 +208,8 @@ static GSourceFuncs virEventGLibSocketSourceFuncs = { GSource *virEventGLibCreateSocketWatch(int fd, - GIOCondition condition) + GIOCondition condition, + virObjectLockable *client) { GSource *source; virEventGLibSocketSource *ssource; @@ -221,6 +227,8 @@ GSource *virEventGLibCreateSocketWatch(int fd, ssource->pollfd.fd = (gintptr)ssource->event; ssource->pollfd.events = G_IO_IN; + ssource->client = client; + WSAEventSelect(ssource->socket, ssource->event, FD_READ | FD_ACCEPT | FD_CLOSE | FD_CONNECT | FD_WRITE | FD_OOB); @@ -239,11 +247,12 @@ virEventGLibAddSocketWatch(int fd, GMainContext *context, virEventGLibSocketFunc func, gpointer opaque, + virObjectLockable *client, GDestroyNotify notify) { GSource *source = NULL; - source = virEventGLibCreateSocketWatch(fd, condition); + source = virEventGLibCreateSocketWatch(fd, condition, client); g_source_set_callback(source, (GSourceFunc)func, opaque, notify); g_source_attach(source, context); diff --git a/src/util/vireventglibwatch.h b/src/util/vireventglibwatch.h index f57be1f503..87a48f158d 100644 --- a/src/util/vireventglibwatch.h +++ b/src/util/vireventglibwatch.h @@ -21,6 +21,7 @@ #pragma once #include "internal.h" +#include "virobject.h" /** * virEventGLibCreateSocketWatch: @@ -34,7 +35,8 @@ * Returns: the new main loop source */ GSource *virEventGLibCreateSocketWatch(int fd, - GIOCondition condition); + GIOCondition condition, + virObjectLockable *client); typedef gboolean (*virEventGLibSocketFunc)(int fd, GIOCondition condition, @@ -45,5 +47,6 @@ GSource *virEventGLibAddSocketWatch(int fd, GMainContext *context, virEventGLibSocketFunc func, gpointer opaque, + virObjectLockable *client, GDestroyNotify notify) G_GNUC_WARN_UNUSED_RESULT; -- 2.34.1 _______________________________________________ Devel mailing list -- devel@xxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx