diff options
Diffstat (limited to 'src/core/net-nonblock.c')
-rw-r--r-- | src/core/net-nonblock.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/core/net-nonblock.c b/src/core/net-nonblock.c index 3eeef228..461b2b87 100644 --- a/src/core/net-nonblock.c +++ b/src/core/net-nonblock.c @@ -35,38 +35,37 @@ typedef struct { int tag; } SIMPLE_THREAD_REC; -#define is_fatal_error(err) \ - (err != 0 && err != G_IO_ERROR_AGAIN && errno != EINTR) - static int g_io_channel_write_block(GIOChannel *channel, void *data, int len) { gsize ret; - int err, sent; + int sent; + GIOStatus status; sent = 0; do { - err = g_io_channel_write(channel, (char *) data + sent, - len-sent, &ret); + status = g_io_channel_write_chars(channel, (char *) data + sent, + len-sent, &ret, NULL); sent += ret; - } while (sent < len && !is_fatal_error(err)); + } while (sent < len && status != G_IO_STATUS_ERROR); - return err != 0 ? -1 : 0; + return sent < len ? -1 : 0; } static int g_io_channel_read_block(GIOChannel *channel, void *data, int len) { time_t maxwait; gsize ret; - int err, received; + int received; + GIOStatus status; maxwait = time(NULL)+2; received = 0; do { - err = g_io_channel_read(channel, (char *) data + received, - len-received, &ret); + status = g_io_channel_read_chars(channel, (char *) data + received, + len-received, &ret, NULL); received += ret; } while (received < len && time(NULL) < maxwait && - (ret != 0 || !is_fatal_error(err))); + status != G_IO_STATUS_ERROR && status != G_IO_STATUS_EOF); return received < len ? -1 : 0; } @@ -282,8 +281,8 @@ int net_connect_nonblock(const char *server, int port, const IPADDR *my_ip, } rec->func = func; rec->data = data; - rec->pipes[0] = g_io_channel_unix_new(fd[0]); - rec->pipes[1] = g_io_channel_unix_new(fd[1]); + rec->pipes[0] = g_io_channel_new(fd[0]); + rec->pipes[1] = g_io_channel_new(fd[1]); /* start nonblocking host name lookup */ net_gethostbyname_nonblock(server, rec->pipes[1], 0); |