mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
gsocket: Fix g_socket_send_messages_with_timeout() on win32
Commit a0cefc2217
introduced an unresolved
symbol, g_socket_send_message_with_timeout(), on win32. Windows
unfortunately isn’t clever enough to fill in the gaps and magic up the
implementation of that function from nowhere, so we had better do it
ourselves.
Factor the blocking behaviour out of g_socket_send_message() into a new
internal g_socket_send_message_with_timeout().
https://bugzilla.gnome.org/show_bug.cgi?id=756054
This commit is contained in:
parent
f91d1a2a76
commit
212b0c28cc
@ -159,6 +159,17 @@ g_socket_receive_messages_with_timeout (GSocket *socket,
|
||||
gint64 timeout,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
static gssize
|
||||
g_socket_send_message_with_timeout (GSocket *socket,
|
||||
GSocketAddress *address,
|
||||
GOutputVector *vectors,
|
||||
gint num_vectors,
|
||||
GSocketControlMessage **messages,
|
||||
gint num_messages,
|
||||
gint flags,
|
||||
gint64 timeout,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
static gint
|
||||
g_socket_send_messages_with_timeout (GSocket *socket,
|
||||
GOutputMessage *messages,
|
||||
@ -4094,9 +4105,29 @@ g_socket_send_message (GSocket *socket,
|
||||
gint flags,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
return g_socket_send_message_with_timeout (socket, address,
|
||||
vectors, num_vectors,
|
||||
messages, num_messages, flags,
|
||||
socket->priv->blocking ? -1 : 0,
|
||||
cancellable, error);
|
||||
}
|
||||
|
||||
static gssize
|
||||
g_socket_send_message_with_timeout (GSocket *socket,
|
||||
GSocketAddress *address,
|
||||
GOutputVector *vectors,
|
||||
gint num_vectors,
|
||||
GSocketControlMessage **messages,
|
||||
gint num_messages,
|
||||
gint flags,
|
||||
gint64 timeout,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
GOutputVector one_vector;
|
||||
char zero;
|
||||
gint64 start_time;
|
||||
|
||||
g_return_val_if_fail (G_IS_SOCKET (socket), -1);
|
||||
g_return_val_if_fail (address == NULL || G_IS_SOCKET_ADDRESS (address), -1);
|
||||
@ -4105,6 +4136,8 @@ g_socket_send_message (GSocket *socket,
|
||||
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), -1);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, -1);
|
||||
|
||||
start_time = g_get_monotonic_time ();
|
||||
|
||||
if (!check_socket (socket, error))
|
||||
return -1;
|
||||
|
||||
@ -4172,12 +4205,12 @@ g_socket_send_message (GSocket *socket,
|
||||
if (errsv == EINTR)
|
||||
continue;
|
||||
|
||||
if (socket->priv->blocking &&
|
||||
if (timeout != 0 &&
|
||||
(errsv == EWOULDBLOCK ||
|
||||
errsv == EAGAIN))
|
||||
{
|
||||
if (!g_socket_condition_wait (socket,
|
||||
G_IO_OUT, cancellable, error))
|
||||
if (!block_on_timeout (socket, G_IO_OUT, timeout, start_time,
|
||||
cancellable, error))
|
||||
return -1;
|
||||
|
||||
continue;
|
||||
@ -4253,10 +4286,10 @@ g_socket_send_message (GSocket *socket,
|
||||
{
|
||||
win32_unset_event_mask (socket, FD_WRITE);
|
||||
|
||||
if (socket->priv->blocking)
|
||||
if (timeout != 0)
|
||||
{
|
||||
if (!g_socket_condition_wait (socket,
|
||||
G_IO_OUT, cancellable, error))
|
||||
if (!block_on_timeout (socket, G_IO_OUT, timeout,
|
||||
start_time, cancellable, error))
|
||||
return -1;
|
||||
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user