qio: non-default context for async conn
We have worked on qio_task_run_in_thread() already. Further, let all the qio channel APIs use that context. Signed-off-by: Peter Xu <peterx@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
a17536c594
commit
8005fdd8fa
@ -867,7 +867,7 @@ static gboolean socket_reconnect_timeout(gpointer opaque)
|
|||||||
tcp_chr_set_client_ioc_name(chr, sioc);
|
tcp_chr_set_client_ioc_name(chr, sioc);
|
||||||
qio_channel_socket_connect_async(sioc, s->addr,
|
qio_channel_socket_connect_async(sioc, s->addr,
|
||||||
qemu_chr_socket_connected,
|
qemu_chr_socket_connected,
|
||||||
chr, NULL);
|
chr, NULL, NULL);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -951,7 +951,7 @@ static void qmp_chardev_open_socket(Chardev *chr,
|
|||||||
tcp_chr_set_client_ioc_name(chr, sioc);
|
tcp_chr_set_client_ioc_name(chr, sioc);
|
||||||
qio_channel_socket_connect_async(sioc, s->addr,
|
qio_channel_socket_connect_async(sioc, s->addr,
|
||||||
qemu_chr_socket_connected,
|
qemu_chr_socket_connected,
|
||||||
chr, NULL);
|
chr, NULL, NULL);
|
||||||
} else {
|
} else {
|
||||||
if (s->is_listen) {
|
if (s->is_listen) {
|
||||||
char *name;
|
char *name;
|
||||||
|
@ -101,6 +101,8 @@ int qio_channel_socket_connect_sync(QIOChannelSocket *ioc,
|
|||||||
* @callback: the function to invoke on completion
|
* @callback: the function to invoke on completion
|
||||||
* @opaque: user data to pass to @callback
|
* @opaque: user data to pass to @callback
|
||||||
* @destroy: the function to free @opaque
|
* @destroy: the function to free @opaque
|
||||||
|
* @context: the context to run the async task. If %NULL, the default
|
||||||
|
* context will be used.
|
||||||
*
|
*
|
||||||
* Attempt to connect to the address @addr. This method
|
* Attempt to connect to the address @addr. This method
|
||||||
* will run in the background so the caller will regain
|
* will run in the background so the caller will regain
|
||||||
@ -113,7 +115,8 @@ void qio_channel_socket_connect_async(QIOChannelSocket *ioc,
|
|||||||
SocketAddress *addr,
|
SocketAddress *addr,
|
||||||
QIOTaskFunc callback,
|
QIOTaskFunc callback,
|
||||||
gpointer opaque,
|
gpointer opaque,
|
||||||
GDestroyNotify destroy);
|
GDestroyNotify destroy,
|
||||||
|
GMainContext *context);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -138,6 +141,8 @@ int qio_channel_socket_listen_sync(QIOChannelSocket *ioc,
|
|||||||
* @callback: the function to invoke on completion
|
* @callback: the function to invoke on completion
|
||||||
* @opaque: user data to pass to @callback
|
* @opaque: user data to pass to @callback
|
||||||
* @destroy: the function to free @opaque
|
* @destroy: the function to free @opaque
|
||||||
|
* @context: the context to run the async task. If %NULL, the default
|
||||||
|
* context will be used.
|
||||||
*
|
*
|
||||||
* Attempt to listen to the address @addr. This method
|
* Attempt to listen to the address @addr. This method
|
||||||
* will run in the background so the caller will regain
|
* will run in the background so the caller will regain
|
||||||
@ -150,7 +155,8 @@ void qio_channel_socket_listen_async(QIOChannelSocket *ioc,
|
|||||||
SocketAddress *addr,
|
SocketAddress *addr,
|
||||||
QIOTaskFunc callback,
|
QIOTaskFunc callback,
|
||||||
gpointer opaque,
|
gpointer opaque,
|
||||||
GDestroyNotify destroy);
|
GDestroyNotify destroy,
|
||||||
|
GMainContext *context);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -179,6 +185,8 @@ int qio_channel_socket_dgram_sync(QIOChannelSocket *ioc,
|
|||||||
* @callback: the function to invoke on completion
|
* @callback: the function to invoke on completion
|
||||||
* @opaque: user data to pass to @callback
|
* @opaque: user data to pass to @callback
|
||||||
* @destroy: the function to free @opaque
|
* @destroy: the function to free @opaque
|
||||||
|
* @context: the context to run the async task. If %NULL, the default
|
||||||
|
* context will be used.
|
||||||
*
|
*
|
||||||
* Attempt to initialize a datagram socket bound to
|
* Attempt to initialize a datagram socket bound to
|
||||||
* @localAddr and communicating with peer @remoteAddr.
|
* @localAddr and communicating with peer @remoteAddr.
|
||||||
@ -194,7 +202,8 @@ void qio_channel_socket_dgram_async(QIOChannelSocket *ioc,
|
|||||||
SocketAddress *remoteAddr,
|
SocketAddress *remoteAddr,
|
||||||
QIOTaskFunc callback,
|
QIOTaskFunc callback,
|
||||||
gpointer opaque,
|
gpointer opaque,
|
||||||
GDestroyNotify destroy);
|
GDestroyNotify destroy,
|
||||||
|
GMainContext *context);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -174,7 +174,8 @@ void qio_channel_socket_connect_async(QIOChannelSocket *ioc,
|
|||||||
SocketAddress *addr,
|
SocketAddress *addr,
|
||||||
QIOTaskFunc callback,
|
QIOTaskFunc callback,
|
||||||
gpointer opaque,
|
gpointer opaque,
|
||||||
GDestroyNotify destroy)
|
GDestroyNotify destroy,
|
||||||
|
GMainContext *context)
|
||||||
{
|
{
|
||||||
QIOTask *task = qio_task_new(
|
QIOTask *task = qio_task_new(
|
||||||
OBJECT(ioc), callback, opaque, destroy);
|
OBJECT(ioc), callback, opaque, destroy);
|
||||||
@ -189,7 +190,7 @@ void qio_channel_socket_connect_async(QIOChannelSocket *ioc,
|
|||||||
qio_channel_socket_connect_worker,
|
qio_channel_socket_connect_worker,
|
||||||
addrCopy,
|
addrCopy,
|
||||||
(GDestroyNotify)qapi_free_SocketAddress,
|
(GDestroyNotify)qapi_free_SocketAddress,
|
||||||
NULL);
|
context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -234,7 +235,8 @@ void qio_channel_socket_listen_async(QIOChannelSocket *ioc,
|
|||||||
SocketAddress *addr,
|
SocketAddress *addr,
|
||||||
QIOTaskFunc callback,
|
QIOTaskFunc callback,
|
||||||
gpointer opaque,
|
gpointer opaque,
|
||||||
GDestroyNotify destroy)
|
GDestroyNotify destroy,
|
||||||
|
GMainContext *context)
|
||||||
{
|
{
|
||||||
QIOTask *task = qio_task_new(
|
QIOTask *task = qio_task_new(
|
||||||
OBJECT(ioc), callback, opaque, destroy);
|
OBJECT(ioc), callback, opaque, destroy);
|
||||||
@ -248,7 +250,7 @@ void qio_channel_socket_listen_async(QIOChannelSocket *ioc,
|
|||||||
qio_channel_socket_listen_worker,
|
qio_channel_socket_listen_worker,
|
||||||
addrCopy,
|
addrCopy,
|
||||||
(GDestroyNotify)qapi_free_SocketAddress,
|
(GDestroyNotify)qapi_free_SocketAddress,
|
||||||
NULL);
|
context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -310,7 +312,8 @@ void qio_channel_socket_dgram_async(QIOChannelSocket *ioc,
|
|||||||
SocketAddress *remoteAddr,
|
SocketAddress *remoteAddr,
|
||||||
QIOTaskFunc callback,
|
QIOTaskFunc callback,
|
||||||
gpointer opaque,
|
gpointer opaque,
|
||||||
GDestroyNotify destroy)
|
GDestroyNotify destroy,
|
||||||
|
GMainContext *context)
|
||||||
{
|
{
|
||||||
QIOTask *task = qio_task_new(
|
QIOTask *task = qio_task_new(
|
||||||
OBJECT(ioc), callback, opaque, destroy);
|
OBJECT(ioc), callback, opaque, destroy);
|
||||||
@ -325,7 +328,7 @@ void qio_channel_socket_dgram_async(QIOChannelSocket *ioc,
|
|||||||
qio_channel_socket_dgram_worker,
|
qio_channel_socket_dgram_worker,
|
||||||
data,
|
data,
|
||||||
qio_channel_socket_dgram_worker_free,
|
qio_channel_socket_dgram_worker_free,
|
||||||
NULL);
|
context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,7 +103,8 @@ static void socket_start_outgoing_migration(MigrationState *s,
|
|||||||
saddr,
|
saddr,
|
||||||
socket_outgoing_migration,
|
socket_outgoing_migration,
|
||||||
data,
|
data,
|
||||||
socket_connect_data_free);
|
socket_connect_data_free,
|
||||||
|
NULL);
|
||||||
qapi_free_SocketAddress(saddr);
|
qapi_free_SocketAddress(saddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ static void test_io_channel_setup_async(SocketAddress *listen_addr,
|
|||||||
lioc = qio_channel_socket_new();
|
lioc = qio_channel_socket_new();
|
||||||
qio_channel_socket_listen_async(
|
qio_channel_socket_listen_async(
|
||||||
lioc, listen_addr,
|
lioc, listen_addr,
|
||||||
test_io_channel_complete, &data, NULL);
|
test_io_channel_complete, &data, NULL, NULL);
|
||||||
|
|
||||||
g_main_loop_run(data.loop);
|
g_main_loop_run(data.loop);
|
||||||
g_main_context_iteration(g_main_context_default(), FALSE);
|
g_main_context_iteration(g_main_context_default(), FALSE);
|
||||||
@ -200,7 +200,7 @@ static void test_io_channel_setup_async(SocketAddress *listen_addr,
|
|||||||
|
|
||||||
qio_channel_socket_connect_async(
|
qio_channel_socket_connect_async(
|
||||||
QIO_CHANNEL_SOCKET(*src), connect_addr,
|
QIO_CHANNEL_SOCKET(*src), connect_addr,
|
||||||
test_io_channel_complete, &data, NULL);
|
test_io_channel_complete, &data, NULL, NULL);
|
||||||
|
|
||||||
g_main_loop_run(data.loop);
|
g_main_loop_run(data.loop);
|
||||||
g_main_context_iteration(g_main_context_default(), FALSE);
|
g_main_context_iteration(g_main_context_default(), FALSE);
|
||||||
|
Loading…
Reference in New Issue
Block a user