static void io_watch_poll_finalize(GSource *source)
{
IOWatchPoll *iwp = io_watch_poll_from_source(source);
- g_source_destroy(iwp->src);
- g_source_unref(iwp->src);
- iwp->src = NULL;
+ if (iwp->src) {
+ g_source_destroy(iwp->src);
+ g_source_unref(iwp->src);
+ iwp->src = NULL;
+ }
}
static GSourceFuncs io_watch_poll_funcs = {
if (s->fd_in_tag) {
g_source_remove(s->fd_in_tag);
+ s->fd_in_tag = 0;
}
if (s->fd_in) {
PtyCharDriver *s = chr->opaque;
if (!connected) {
- g_source_remove(s->fd_tag);
- s->fd_tag = 0;
+ if (s->fd_tag) {
+ g_source_remove(s->fd_tag);
+ s->fd_tag = 0;
+ }
s->connected = 0;
s->polling = 0;
/* (re-)connect poll interval for idle guests: once per second.
if (s->fd_tag) {
g_source_remove(s->fd_tag);
+ s->fd_tag = 0;
}
fd = g_io_channel_unix_get_fd(s->fd);
g_io_channel_unref(s->fd);
close(fd);
if (s->timer_tag) {
g_source_remove(s->timer_tag);
+ s->timer_tag = 0;
}
g_free(s);
qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
NetCharDriver *s = chr->opaque;
if (s->tag) {
g_source_remove(s->tag);
+ s->tag = 0;
}
if (s->chan) {
g_io_channel_unref(s->chan);
if (s->listen_chan) {
s->listen_tag = g_io_add_watch(s->listen_chan, G_IO_IN, tcp_chr_accept, chr);
}
- g_source_remove(s->tag);
- s->tag = 0;
+ if (s->tag) {
+ g_source_remove(s->tag);
+ s->tag = 0;
+ }
g_io_channel_unref(s->chan);
s->chan = NULL;
closesocket(s->fd);
socket_set_nodelay(fd);
s->fd = fd;
s->chan = io_channel_from_socket(fd);
- g_source_remove(s->listen_tag);
- s->listen_tag = 0;
+ if (s->listen_tag) {
+ g_source_remove(s->listen_tag);
+ s->listen_tag = 0;
+ }
tcp_chr_connect(chr);
return 0;
if (s->fd >= 0) {
if (s->tag) {
g_source_remove(s->tag);
+ s->tag = 0;
}
if (s->chan) {
g_io_channel_unref(s->chan);
if (s->listen_fd >= 0) {
if (s->listen_tag) {
g_source_remove(s->listen_tag);
+ s->listen_tag = 0;
}
if (s->listen_chan) {
g_io_channel_unref(s->listen_chan);