qga: drop unnecessary GA_CHANNEL_UNIX_LISTEN checks
Throughout the code there are c->listen_channel checks which manage the listen socket file descriptor (waiting for accept(2), closing the file descriptor, etc). These checks are currently preceded by explicit c->method == GA_CHANNEL_UNIX_LISTEN checks. Explicit GA_CHANNEL_UNIX_LISTEN checks are not necessary since serial channel types do not create the listen channel (c->listen_channel). As more listen channel types are added, explicitly checking all of them becomes messy. Rely on c->listen_channel to determine whether or not a listen socket file descriptor is used. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
This commit is contained in:
parent
b8093d38e8
commit
f06b2031a3
@ -61,7 +61,6 @@ static void ga_channel_listen_add(GAChannel *c, int listen_fd, bool create)
|
|||||||
|
|
||||||
static void ga_channel_listen_close(GAChannel *c)
|
static void ga_channel_listen_close(GAChannel *c)
|
||||||
{
|
{
|
||||||
g_assert(c->method == GA_CHANNEL_UNIX_LISTEN);
|
|
||||||
g_assert(c->listen_channel);
|
g_assert(c->listen_channel);
|
||||||
g_io_channel_shutdown(c->listen_channel, true, NULL);
|
g_io_channel_shutdown(c->listen_channel, true, NULL);
|
||||||
g_io_channel_unref(c->listen_channel);
|
g_io_channel_unref(c->listen_channel);
|
||||||
@ -77,7 +76,7 @@ static void ga_channel_client_close(GAChannel *c)
|
|||||||
g_io_channel_shutdown(c->client_channel, true, NULL);
|
g_io_channel_shutdown(c->client_channel, true, NULL);
|
||||||
g_io_channel_unref(c->client_channel);
|
g_io_channel_unref(c->client_channel);
|
||||||
c->client_channel = NULL;
|
c->client_channel = NULL;
|
||||||
if (c->method == GA_CHANNEL_UNIX_LISTEN && c->listen_channel) {
|
if (c->listen_channel) {
|
||||||
ga_channel_listen_add(c, 0, false);
|
ga_channel_listen_add(c, 0, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -255,8 +254,7 @@ GAChannel *ga_channel_new(GAChannelMethod method, const gchar *path,
|
|||||||
|
|
||||||
void ga_channel_free(GAChannel *c)
|
void ga_channel_free(GAChannel *c)
|
||||||
{
|
{
|
||||||
if (c->method == GA_CHANNEL_UNIX_LISTEN
|
if (c->listen_channel) {
|
||||||
&& c->listen_channel) {
|
|
||||||
ga_channel_listen_close(c);
|
ga_channel_listen_close(c);
|
||||||
}
|
}
|
||||||
if (c->client_channel) {
|
if (c->client_channel) {
|
||||||
|
Loading…
Reference in New Issue
Block a user