|
|
bd6704 |
diff --git a/io.c b/io.c
|
|
|
bd6704 |
index 999c34e5..ceff3784 100644
|
|
|
bd6704 |
--- a/io.c
|
|
|
bd6704 |
+++ b/io.c
|
|
|
bd6704 |
@@ -954,8 +954,17 @@ int send_msg(enum msgcode code, const char *buf, size_t len, int convert)
|
|
|
bd6704 |
} else
|
|
|
bd6704 |
#endif
|
|
|
bd6704 |
needed = len + 4 + 3;
|
|
|
bd6704 |
- if (iobuf.msg.len + needed > iobuf.msg.size)
|
|
|
bd6704 |
- perform_io(needed, PIO_NEED_MSGROOM);
|
|
|
bd6704 |
+ if (iobuf.msg.len + needed > iobuf.msg.size) {
|
|
|
bd6704 |
+ if (!am_receiver)
|
|
|
bd6704 |
+ perform_io(needed, PIO_NEED_MSGROOM);
|
|
|
bd6704 |
+ else { /* We allow the receiver to increase their iobuf.msg size to avoid a deadlock. */
|
|
|
bd6704 |
+ size_t old_size = iobuf.msg.size;
|
|
|
bd6704 |
+ restore_iobuf_size(&iobuf.msg);
|
|
|
bd6704 |
+ realloc_xbuf(&iobuf.msg, iobuf.msg.size * 2);
|
|
|
bd6704 |
+ if (iobuf.msg.pos + iobuf.msg.len > old_size)
|
|
|
bd6704 |
+ memcpy(iobuf.msg.buf + old_size, iobuf.msg.buf, iobuf.msg.pos + iobuf.msg.len - old_size);
|
|
|
bd6704 |
+ }
|
|
|
bd6704 |
+ }
|
|
|
bd6704 |
|
|
|
bd6704 |
pos = iobuf.msg.pos + iobuf.msg.len; /* Must be set after any flushing. */
|
|
|
bd6704 |
if (pos >= iobuf.msg.size)
|
|
|
bd6704 |
@@ -1176,7 +1185,7 @@ int read_line(int fd, char *buf, size_t bufsiz, int flags)
|
|
|
bd6704 |
|
|
|
bd6704 |
#ifdef ICONV_OPTION
|
|
|
bd6704 |
if (flags & RL_CONVERT && iconv_buf.size < bufsiz)
|
|
|
bd6704 |
- realloc_xbuf(&iconv_buf, bufsiz + 1024);
|
|
|
bd6704 |
+ realloc_xbuf(&iconv_buf, ROUND_UP_1024(bufsiz) + 1024);
|
|
|
bd6704 |
#endif
|
|
|
bd6704 |
|
|
|
bd6704 |
start:
|