Commit 7a43b102 authored by Niels Möller's avatar Niels Möller
Browse files

* src/io.c (write_raw_with_poll): Return an exception on error.

(write_raw): -"-

Rev: src/io.c:1.81
Rev: src/io.h:1.49
parent e7d6c183
......@@ -861,8 +861,8 @@ int address_info2sockaddr_in(struct sockaddr_in *sin,
/* These functions are used by werror() and friends */
/* For fd:s in blocking mode. */
void write_raw(int fd, UINT32 length, const UINT8 *data,
struct exception_handler *e)
const struct exception *
write_raw(int fd, UINT32 length, const UINT8 *data)
{
while(length)
{
......@@ -875,19 +875,18 @@ void write_raw(int fd, UINT32 length, const UINT8 *data,
case EAGAIN:
continue;
default:
EXCEPTION_RAISE(e,
make_io_exception(EXC_IO_BLOCKING_WRITE,
NULL, errno, NULL));
return;
return make_io_exception(EXC_IO_BLOCKING_WRITE,
NULL, errno, NULL);
}
length -= written;
data += written;
}
return NULL;
}
void write_raw_with_poll(int fd, UINT32 length, const UINT8 *data,
struct exception_handler *e)
const struct exception *
write_raw_with_poll(int fd, UINT32 length, const UINT8 *data)
{
while(length)
{
......@@ -907,8 +906,8 @@ void write_raw_with_poll(int fd, UINT32 length, const UINT8 *data,
case EAGAIN:
continue;
default:
EXCEPTION_RAISE(e, make_io_exception(EXC_IO_BLOCKING_WRITE,
NULL, errno, NULL));
return make_io_exception(EXC_IO_BLOCKING_WRITE,
NULL, errno, NULL);
}
written = write(fd, data, length);
......@@ -920,13 +919,14 @@ void write_raw_with_poll(int fd, UINT32 length, const UINT8 *data,
case EAGAIN:
continue;
default:
EXCEPTION_RAISE(e, make_io_exception(EXC_IO_BLOCKING_WRITE,
NULL, errno, NULL));
return make_io_exception(EXC_IO_BLOCKING_WRITE,
NULL, errno, NULL);
}
length -= written;
data += written;
}
return NULL;
}
void io_set_nonblocking(int fd)
......
......@@ -313,10 +313,11 @@ struct address_info *sockaddr2info(size_t addr_len UNUSED,
int address_info2sockaddr_in(struct sockaddr_in *sin,
struct address_info *a);
void write_raw(int fd, UINT32 length, const UINT8 *data,
struct exception_handler *e);
void write_raw_with_poll(int fd, UINT32 length, const UINT8 *data,
struct exception_handler *e);
/* Returns an exception, if anything went wrong */
const struct exception *
write_raw(int fd, UINT32 length, const UINT8 *data);
const struct exception *
write_raw_with_poll(int fd, UINT32 length, const UINT8 *data);
void io_set_nonblocking(int fd);
void io_set_close_on_exec(int fd);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment