version 1.39, 2004/07/17 05:31:41 |
version 1.40, 2005/05/24 17:32:43 |
|
|
PUT_32BIT(buf, mlen + 1); |
PUT_32BIT(buf, mlen + 1); |
buf[4] = (u_char) type; /* 1st byte of payload is mesg-type */ |
buf[4] = (u_char) type; /* 1st byte of payload is mesg-type */ |
if (atomicio(vwrite, sock, buf, sizeof(buf)) != sizeof(buf)) |
if (atomicio(vwrite, sock, buf, sizeof(buf)) != sizeof(buf)) |
fatal("%s: write", __func__); |
fatal("%s: write: %s", __func__, strerror(errno)); |
if (atomicio(vwrite, sock, buffer_ptr(m), mlen) != mlen) |
if (atomicio(vwrite, sock, buffer_ptr(m), mlen) != mlen) |
fatal("%s: write", __func__); |
fatal("%s: write: %s", __func__, strerror(errno)); |
} |
} |
|
|
void |
void |
|
|
{ |
{ |
u_char buf[4]; |
u_char buf[4]; |
u_int msg_len; |
u_int msg_len; |
ssize_t res; |
|
|
|
debug3("%s entering", __func__); |
debug3("%s entering", __func__); |
|
|
res = atomicio(read, sock, buf, sizeof(buf)); |
if (atomicio(read, sock, buf, sizeof(buf)) != sizeof(buf)) { |
if (res != sizeof(buf)) { |
if (errno == EPIPE) |
if (res == 0) |
|
cleanup_exit(255); |
cleanup_exit(255); |
fatal("%s: read: %ld", __func__, (long)res); |
fatal("%s: read: %s", __func__, strerror(errno)); |
} |
} |
msg_len = GET_32BIT(buf); |
msg_len = GET_32BIT(buf); |
if (msg_len > 256 * 1024) |
if (msg_len > 256 * 1024) |
fatal("%s: read: bad msg_len %d", __func__, msg_len); |
fatal("%s: read: bad msg_len %d", __func__, msg_len); |
buffer_clear(m); |
buffer_clear(m); |
buffer_append_space(m, msg_len); |
buffer_append_space(m, msg_len); |
res = atomicio(read, sock, buffer_ptr(m), msg_len); |
if (atomicio(read, sock, buffer_ptr(m), msg_len) != msg_len) |
if (res != msg_len) |
fatal("%s: read: %s", __func__, strerror(errno)); |
fatal("%s: read: %ld != msg_len", __func__, (long)res); |
|
} |
} |
|
|
void |
void |