Re: Review of gnio, round 1

> >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)

- dave

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]