Re: Review of gnio, round 1
- From: Dave Benson <daveb idealab com>
- To: Mark Mielke <mark mark mielke cc>
- Cc: desrt desrt ca, Dan Winship <danw gnome org>, gicmo gnome org, gtk-devel-list <gtk-devel-list gnome org>, Alexander Larsson <alexl redhat com>
- Subject: Re: Review of gnio, round 1
- Date: Mon, 27 Apr 2009 17:28:57 -0700
> >In libsoup it's also important because it's thread-safe/non-racy. That
> >may not be a relevant criterion for GSocket, although the source
> >returned by g_socket_create_source() could create similar problems; you
> >need to be certain that any such sources are destroyed before you call
> >g_socket_close(), or else they could trigger falsely if the fd gets
> >reused. Delaying close() until finalization makes that easy because then
> >you can just have the source hold a ref on the socket to ensure that the
> >fd doesn't get closed.
Why not just set the FD to -1?
It'll give bad a EBADF instead of ENOTCONNECTED (or whatever),
but it seems better... no flags, i guess it's "racy" but that's
intrinsic to the circumstance of having one thread writing and another closing.
(Really, the caller is going to have to have a lock if they want
multiple threads to write to the same fd)
] [Thread Prev