[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 04/14] block/nbd: split connect_thread_cb() out of connect_thread
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH 04/14] block/nbd: split connect_thread_cb() out of connect_thread_func() |
Date: |
Wed, 7 Apr 2021 13:46:27 +0300 |
We are going to split connect-thread to separate file. Start from
splitting the callback.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
block/nbd.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/block/nbd.c b/block/nbd.c
index fbf5154048..a9d351cbbc 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -385,20 +385,11 @@ static void nbd_free_connect_thread(NBDConnectThread *thr)
g_free(thr);
}
-static void *connect_thread_func(void *opaque)
+static void connect_thread_cb(int ret, void *opaque)
{
NBDConnectThread *thr = opaque;
- int ret;
bool do_free = false;
- thr->sioc = qio_channel_socket_new();
-
- ret = qio_channel_socket_connect_sync(thr->sioc, thr->saddr, NULL);
- if (ret < 0) {
- object_unref(OBJECT(thr->sioc));
- thr->sioc = NULL;
- }
-
qemu_mutex_lock(&thr->mutex);
switch (thr->state) {
@@ -423,6 +414,22 @@ static void *connect_thread_func(void *opaque)
if (do_free) {
nbd_free_connect_thread(thr);
}
+}
+
+static void *connect_thread_func(void *opaque)
+{
+ NBDConnectThread *thr = opaque;
+ int ret;
+
+ thr->sioc = qio_channel_socket_new();
+
+ ret = qio_channel_socket_connect_sync(thr->sioc, thr->saddr, NULL);
+ if (ret < 0) {
+ object_unref(OBJECT(thr->sioc));
+ thr->sioc = NULL;
+ }
+
+ connect_thread_cb(ret, thr);
return NULL;
}
--
2.29.2
- [PATCH 00/14] nbd: move reconnect-thread to separate file, Vladimir Sementsov-Ogievskiy, 2021/04/07
- [PATCH 01/14] block/nbd: BDRVNBDState: drop unused connect_err, Vladimir Sementsov-Ogievskiy, 2021/04/07
- [PATCH 03/14] block/nbd: drop unused NBDConnectThread::err field, Vladimir Sementsov-Ogievskiy, 2021/04/07
- [PATCH 04/14] block/nbd: split connect_thread_cb() out of connect_thread_func(),
Vladimir Sementsov-Ogievskiy <=
- [PATCH 06/14] block/nbd: further segregation of connect-thread, Vladimir Sementsov-Ogievskiy, 2021/04/07
- [PATCH 02/14] block/nbd: nbd_co_establish_connection(): drop unused errp, Vladimir Sementsov-Ogievskiy, 2021/04/07
- [PATCH 05/14] block/nbd: rename NBDConnectThread to NBDConnectCB, Vladimir Sementsov-Ogievskiy, 2021/04/07
- [PATCH 08/14] block/nbd: move nbd connect-thread to nbd/client-connect.c, Vladimir Sementsov-Ogievskiy, 2021/04/07
- [PATCH 07/14] block/nbd: drop nbd_free_connect_thread(), Vladimir Sementsov-Ogievskiy, 2021/04/07
- [PATCH 09/14] block/nbd: NBDConnectCB: drop bh_* fields, Vladimir Sementsov-Ogievskiy, 2021/04/07
- [PATCH 10/14] block/nbd: move wait_connect field under mutex protection, Vladimir Sementsov-Ogievskiy, 2021/04/07
- [PATCH 11/14] block/nbd: refactor connect_bh(), Vladimir Sementsov-Ogievskiy, 2021/04/07