if (DEBUG_GTE(IO, 3)) {
rprintf(FINFO, "[%s] perform_io(%ld, outroom) needs to flush %ld\n",
who_am_i(), (long)needed,
if (DEBUG_GTE(IO, 3)) {
rprintf(FINFO, "[%s] perform_io(%ld, outroom) needs to flush %ld\n",
who_am_i(), (long)needed,
if (DEBUG_GTE(IO, 3)) {
rprintf(FINFO, "[%s] perform_io(%ld, msgroom) needs to flush %ld\n",
who_am_i(), (long)needed,
if (DEBUG_GTE(IO, 3)) {
rprintf(FINFO, "[%s] perform_io(%ld, msgroom) needs to flush %ld\n",
who_am_i(), (long)needed,
- if (iobuf.out.len <= iobuf.out.size - needed)
+ /* Note that iobuf.out_empty_len doesn't factor into this check
+ * because iobuf.out.len already holds any needed header len. */
+ if (iobuf.out.len + needed <= iobuf.out.size)
if (iobuf.raw_flushing_ends_before
|| (!iobuf.msg.len && iobuf.out.len > iobuf.out_empty_len && !(flags & PIO_NEED_MSGROOM))) {
if (OUT_MULTIPLEXED && !iobuf.raw_flushing_ends_before) {
if (iobuf.raw_flushing_ends_before
|| (!iobuf.msg.len && iobuf.out.len > iobuf.out_empty_len && !(flags & PIO_NEED_MSGROOM))) {
if (OUT_MULTIPLEXED && !iobuf.raw_flushing_ends_before) {
/* The iobuf.raw_flushing_ends_before value can point off the end
* of the iobuf.out buffer for a while, for easier subtracting. */
iobuf.raw_flushing_ends_before = iobuf.out.pos + iobuf.out.len;
SIVAL(iobuf.out.buf + iobuf.raw_data_header_pos, 0,
((MPLEX_BASE + (int)MSG_DATA)<<24) + iobuf.out.len - 4);
/* The iobuf.raw_flushing_ends_before value can point off the end
* of the iobuf.out buffer for a while, for easier subtracting. */
iobuf.raw_flushing_ends_before = iobuf.out.pos + iobuf.out.len;
SIVAL(iobuf.out.buf + iobuf.raw_data_header_pos, 0,
((MPLEX_BASE + (int)MSG_DATA)<<24) + iobuf.out.len - 4);
/* We used some of the overflow bytes, so move them. */
if (DEBUG_GTE(IO, 4)) {
rprintf(FINFO, "[%s] wrap-bytes moved: %d (perform_io)\n",
/* We used some of the overflow bytes, so move them. */
if (DEBUG_GTE(IO, 4)) {
rprintf(FINFO, "[%s] wrap-bytes moved: %d (perform_io)\n",
iobuf.raw_data_header_pos = iobuf.raw_flushing_ends_before;
if (iobuf.raw_data_header_pos >= iobuf.out.size)
iobuf.raw_data_header_pos -= iobuf.out.size;
iobuf.raw_data_header_pos = iobuf.raw_flushing_ends_before;
if (iobuf.raw_data_header_pos >= iobuf.out.size)
iobuf.raw_data_header_pos -= iobuf.out.size;
SIVAL(hdr, 0, ((MPLEX_BASE + (int)code)<<24) + len);
/* If the header used any overflow bytes, move them to the start. */
if ((pos = hdr+4 - iobuf.msg.buf) > iobuf.msg.size) {
SIVAL(hdr, 0, ((MPLEX_BASE + (int)code)<<24) + len);
/* If the header used any overflow bytes, move them to the start. */
if ((pos = hdr+4 - iobuf.msg.buf) > iobuf.msg.size) {
- rprintf(FINFO, "[%s] wrap-bytes moved: %d (send_msg)\n", who_am_i(), (int)siz);
- memcpy(iobuf.msg.buf, hdr+4 - siz, siz);
+ rprintf(FINFO, "[%s] wrap-bytes moved: %d (send_msg)\n", who_am_i(), siz);
+ memcpy(iobuf.msg.buf, iobuf.msg.buf + iobuf.msg.size, siz);
if (msg_bytes != 4 || am_sender)
goto invalid_msg;
data = perform_io(4, PIO_INPUT_AND_CONSUME);
if (msg_bytes != 4 || am_sender)
goto invalid_msg;
data = perform_io(4, PIO_INPUT_AND_CONSUME);
exit_cleanup(RERR_STREAMIO);
}
data = perform_io(4, PIO_INPUT_AND_CONSUME);
exit_cleanup(RERR_STREAMIO);
}
data = perform_io(4, PIO_INPUT_AND_CONSUME);
perform_io(len, PIO_NEED_OUTROOM);
pos = iobuf.out.pos + iobuf.out.len; /* Must be set after any flushing. */
perform_io(len, PIO_NEED_OUTROOM);
pos = iobuf.out.pos + iobuf.out.len; /* Must be set after any flushing. */