[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC PATCH v5 01/14] util: introduce gsource event abst
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [RFC PATCH v5 01/14] util: introduce gsource event abstraction |
Date: |
Fri, 26 Apr 2013 11:19:00 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Fri, Apr 26, 2013 at 10:47:22AM +0800, Liu Ping Fan wrote:
> +GPollFD *events_source_add_gfd(EventsGSource *src, int fd)
> +{
> + GPollFD *retfd;
> +
> + retfd = g_slice_alloc(sizeof(GPollFD));
> + retfd->events = 0;
> + retfd->fd = fd;
> + src->pollfds_list = g_list_append(src->pollfds_list, retfd);
> + if (fd > 0) {
0 (stdin) is a valid fd number. Maybe just assert(fd >= 0)?
> +static gboolean events_source_check(GSource *src)
> +{
> + EventsGSource *nsrc = (EventsGSource *)src;
> + GList *cur;
> + GPollFD *gfd;
> +
> + cur = nsrc->pollfds_list;
> + while (cur) {
> + gfd = cur->data;
> + if (gfd->fd > 0 && (gfd->revents & gfd->events)) {
revents will always be 0 if fd is invalid, since we didn't call
g_source_add_poll(). Is there a reason to perform the fd > 0 check
again?
> +void events_source_release(EventsGSource *src)
> +{
assert that pollfds_list is empty? We don't g_slice_free() GPollFDs so
it must be empty here.
- [Qemu-devel] [RFC PATCH v5 00/14] port network layer onto glib, Liu Ping Fan, 2013/04/25
- [Qemu-devel] [RFC PATCH v5 02/14] net: introduce bind_ctx to NetClientInfo, Liu Ping Fan, 2013/04/25
- [Qemu-devel] [RFC PATCH v5 03/14] net: port tap onto GSource, Liu Ping Fan, 2013/04/25
- [Qemu-devel] [RFC PATCH v5 04/14] net: port vde onto GSource, Liu Ping Fan, 2013/04/25
- [Qemu-devel] [RFC PATCH v5 05/14] net: port socket to GSource, Liu Ping Fan, 2013/04/25