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