GSocketInput/OutputStream: fix non-blocking on Windows

The GSocket docs point out that g_socket_send/g_socket_receive may
return G_IO_ERROR_WOULD_BLOCK even if g_socket_condition_check claimed
that they wouldn't. Fix the socket streams to check for that.

https://bugzilla.gnome.org/show_bug.cgi?id=603309
This commit is contained in:
Dan Winship
2010-04-23 08:21:41 -04:00
parent 2be38f6926
commit e0ff84e688
3 changed files with 44 additions and 56 deletions

View File

@@ -2489,6 +2489,14 @@ g_socket_create_source (GSocket *socket,
* against the currently-satisfied conditions on @socket. The result
* is returned.
*
* Note that on Windows, it is possible for an operation to return
* %G_IO_ERROR_WOULD_BLOCK even immediately after
* g_socket_condition_check() has claimed that the socket is ready for
* writing. Rather than calling g_socket_condition_check() and then
* writing to the socket if it succeeds, it is generally better to
* simply try writing to the socket right away, and try again later if
* the initial attempt returns %G_IO_ERROR_WOULD_BLOCK.
*
* It is meaningless to specify %G_IO_ERR or %G_IO_HUP in condition;
* these conditions will always be set in the output if they are true.
*