- cancel_fd = g_cancellable_get_fd (cancellable);
- if (cancel_fd != -1)
- {
- do
- {
- poll_fds[0].events = POLLOUT;
- poll_fds[0].fd = socket_stream->priv->fd;
- poll_fds[1].events = POLLIN;
- poll_fds[1].fd = cancel_fd;
- poll_ret = poll (poll_fds, 2, -1);
- }
- while (poll_ret == -1 && errno == EINTR);
-
- if (poll_ret == -1)
- {
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error writing to socket: %s"),
- g_strerror (errno));
- return -1;
- }
- }
-
- while (1)
- {
- if (g_cancellable_set_error_if_cancelled (cancellable, error))
- return -1;
-
- res = write (socket_stream->priv->fd, buffer, count);
- if (res == -1)
- {
- if (errno == EINTR)
- continue;
-
- g_set_error (error, G_IO_ERROR,
- g_io_error_from_errno (errno),
- _("Error writing to socket: %s"),
- g_strerror (errno));
- }
-
- break;
- }
-
- return res;