]> git.proxmox.com Git - mirror_qemu.git/commit - chardev/char.c
chardev: introduce qemu_chr_timeout_add_ms()
authorPeter Xu <peterx@redhat.com>
Thu, 4 Jan 2018 14:18:35 +0000 (22:18 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 12 Jan 2018 12:22:02 +0000 (13:22 +0100)
commit2c716ba1506769c9be2caa02f0f6d6e7c00f4304
tree233189ca8b845f83871b104d50dcdedcb264484c
parent938eb9e9c83d34d90cac6ec5c5388e7998840e4e
chardev: introduce qemu_chr_timeout_add_ms()

It's a replacement of g_timeout_add[_seconds]() for chardevs.  Chardevs
now can have dedicated gcontext, we should always bind chardev tasks
onto those gcontext rather than the default main context.  Since there
are quite a few of g_timeout_add[_seconds]() callers, a new function
qemu_chr_timeout_add_ms() is introduced.

One thing to mention is that, terminal3270 is still always running on
main gcontext.  However let's convert that as well since it's still part
of chardev codes and in case one day we'll miss that when we move it out
of main gcontext too.

Also, convert all the timers from GSource tags into GSource pointers.
Gsource tag IDs and g_source_remove()s can only work with default
gcontext, while now these GSources can logically be attached to other
contexts.  So let's use explicit g_source_destroy() plus another
g_source_unref() to remove a timer.

Note: when in the timer handler, we don't need the g_source_destroy()
any more since that'll be done automatically if the timer handler
returns false (and that's what all the current handlers do).

Yet another note: in pty_chr_rearm_timer() we take special care for
ms=1000.  This patch merged the two cases into one.

Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <20180104141835.17987-4-peterx@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
chardev/char-pty.c
chardev/char-socket.c
chardev/char.c
hw/char/terminal3270.c
include/chardev/char.h