1 /* -*- c-file-style: "linux" -*-
3 * Copyright (C) 1996-2001 by Andrew Tridgell
4 * Copyright (C) Paul Mackerras 1996
5 * Copyright (C) 2001, 2002 by Martin Pool <mbp@samba.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 * Socket and pipe I/O utilities used in rsync.
27 * rsync provides its own multiplexing system, which is used to send
28 * stderr and stdout over a single socket. We need this because
29 * stdout normally carries the binary data stream, and stderr all our
32 * For historical reasons this is off during the start of the
33 * connection, but it's switched on quite early using
34 * io_start_multiplex_out() and io_start_multiplex_in().
39 /** If no timeout is specified then use a 60 second select timeout */
40 #define SELECT_TIMEOUT 60
43 extern size_t bwlimit_writemax;
45 extern int io_timeout;
50 extern int checksum_seed;
51 extern int protocol_version;
52 extern char *remote_filesfrom_file;
53 extern struct stats stats;
55 const char phase_unknown[] = "unknown";
56 int select_timeout = SELECT_TIMEOUT;
60 * The connection might be dropped at some point; perhaps because the
61 * remote instance crashed. Just giving the offset on the stream is
62 * not very helpful. So instead we try to make io_phase_name point to
65 * For buffered/multiplexed I/O these names will be somewhat
66 * approximate; perhaps for ease of support we would rather make the
67 * buffer always flush when a single application-level I/O finishes.
69 * @todo Perhaps we want some simple stack functionality, but there's
70 * no need to overdo it.
72 const char *io_write_phase = phase_unknown;
73 const char *io_read_phase = phase_unknown;
75 /** Ignore EOF errors while reading a module listing if the remote
76 version is 24 or less. */
77 int kludge_around_eof = False;
82 static int io_multiplexing_out;
83 static int io_multiplexing_in;
84 static int sock_f_in = -1;
85 static int sock_f_out = -1;
86 static time_t last_io;
89 static int write_batch_monitor_in = -1;
90 static int write_batch_monitor_out = -1;
92 static int io_filesfrom_f_in = -1;
93 static int io_filesfrom_f_out = -1;
94 static char io_filesfrom_buf[2048];
95 static char *io_filesfrom_bp;
96 static char io_filesfrom_lastchar;
97 static int io_filesfrom_buflen;
99 static void read_loop(int fd, char *buf, size_t len);
102 struct redo_list *next;
106 static struct redo_list *redo_list_head;
107 static struct redo_list *redo_list_tail;
110 struct msg_list *next;
115 static struct msg_list *msg_list_head;
116 static struct msg_list *msg_list_tail;
118 static void redo_list_add(int num)
120 struct redo_list *rl;
122 if (!(rl = new(struct redo_list)))
123 exit_cleanup(RERR_MALLOC);
127 redo_list_tail->next = rl;
133 static void check_timeout(void)
141 last_io = time(NULL);
147 if (t - last_io >= io_timeout) {
148 if (!am_server && !am_daemon) {
149 rprintf(FERROR, "io timeout after %d seconds - exiting\n",
152 exit_cleanup(RERR_TIMEOUT);
156 /* Note the fds used for the main socket (which might really be a pipe
157 * for a local transfer, but we can ignore that). */
158 void io_set_sock_fds(int f_in, int f_out)
164 /** Setup the fd used to receive MSG_* messages. Only needed when
165 * we're the generator because the sender and receiver both use the
166 * multiplexed I/O setup. */
167 void set_msg_fd_in(int fd)
172 /** Setup the fd used to send our MSG_* messages. Only needed when
173 * we're the receiver because the generator and the sender both use
174 * the multiplexed I/O setup. */
175 void set_msg_fd_out(int fd)
178 set_nonblocking(msg_fd_out);
181 /* Add a message to the pending MSG_* list. */
182 static void msg_list_add(int code, char *buf, int len)
186 if (!(ml = new(struct msg_list)))
187 exit_cleanup(RERR_MALLOC);
189 if (!(ml->buf = new_array(char, len+4)))
190 exit_cleanup(RERR_MALLOC);
191 SIVAL(ml->buf, 0, ((code+MPLEX_BASE)<<24) | len);
192 memcpy(ml->buf+4, buf, len);
195 msg_list_tail->next = ml;
201 void send_msg(enum msgcode code, char *buf, int len)
203 msg_list_add(code, buf, len);
204 msg_list_push(NORMAL_FLUSH);
207 /** Read a message from the MSG_* fd and dispatch it. This is only
208 * called by the generator. */
209 static void read_msg_fd(void)
216 /* Temporarily disable msg_fd_in. This is needed to avoid looping back
217 * to this routine from read_timeout() and writefd_unbuffered(). */
220 read_loop(fd, buf, 4);
223 len = tag & 0xFFFFFF;
224 tag = (tag >> 24) - MPLEX_BASE;
229 rprintf(FERROR, "invalid message %d:%d\n", tag, len);
230 exit_cleanup(RERR_STREAMIO);
236 rprintf(FERROR, "invalid message %d:%d\n", tag, len);
237 exit_cleanup(RERR_STREAMIO);
239 read_loop(fd, buf, 4);
240 redo_list_add(IVAL(buf,0));
249 read_loop(fd, buf, n);
250 rwrite((enum logcode)tag, buf, n);
255 rprintf(FERROR, "unknown message %d:%d\n", tag, len);
256 exit_cleanup(RERR_STREAMIO);
262 /* Try to push messages off the list onto the wire. If we leave with more
263 * to do, return 0. On error, return -1. If everything flushed, return 1.
264 * This is only active in the receiver. */
265 int msg_list_push(int flush_it_all)
267 static int written = 0;
274 while (msg_list_head) {
275 struct msg_list *ml = msg_list_head;
276 int n = write(msg_fd_out, ml->buf + written, ml->len - written);
280 if (errno != EWOULDBLOCK && errno != EAGAIN)
285 FD_SET(msg_fd_out, &fds);
286 tv.tv_sec = select_timeout;
288 if (!select(msg_fd_out+1, NULL, &fds, NULL, &tv))
290 } else if ((written += n) == ml->len) {
292 msg_list_head = ml->next;
294 msg_list_tail = NULL;
302 int get_redo_num(void)
304 struct redo_list *next;
307 while (!redo_list_head)
310 num = redo_list_head->num;
311 next = redo_list_head->next;
312 free(redo_list_head);
313 redo_list_head = next;
315 redo_list_tail = NULL;
321 * When we're the receiver and we have a local --files-from list of names
322 * that needs to be sent over the socket to the sender, we have to do two
323 * things at the same time: send the sender a list of what files we're
324 * processing and read the incoming file+info list from the sender. We do
325 * this by augmenting the read_timeout() function to copy this data. It
326 * uses the io_filesfrom_buf to read a block of data from f_in (when it is
327 * ready, since it might be a pipe) and then blast it out f_out (when it
328 * is ready to receive more data).
330 void io_set_filesfrom_fds(int f_in, int f_out)
332 io_filesfrom_f_in = f_in;
333 io_filesfrom_f_out = f_out;
334 io_filesfrom_bp = io_filesfrom_buf;
335 io_filesfrom_lastchar = '\0';
336 io_filesfrom_buflen = 0;
340 * It's almost always an error to get an EOF when we're trying to read
341 * from the network, because the protocol is self-terminating.
343 * However, there is one unfortunate cases where it is not, which is
344 * rsync <2.4.6 sending a list of modules on a server, since the list
345 * is terminated by closing the socket. So, for the section of the
346 * program where that is a problem (start_socket_client),
347 * kludge_around_eof is True and we just exit.
349 static void whine_about_eof(int fd)
351 if (kludge_around_eof && fd == sock_f_in)
354 rprintf(FERROR, RSYNC_NAME ": connection unexpectedly closed "
355 "(%.0f bytes read so far)\n",
356 (double)stats.total_read);
358 exit_cleanup(RERR_STREAMIO);
363 * Read from a socket with I/O timeout. return the number of bytes
364 * read. If no bytes can be read then exit, never return a number <= 0.
366 * TODO: If the remote shell connection fails, then current versions
367 * actually report an "unexpected EOF" error here. Since it's a
368 * fairly common mistake to try to use rsh when ssh is required, we
369 * should trap that: if we fail to read any data at all, we should
370 * give a better explanation. We can tell whether the connection has
371 * started by looking e.g. at whether the remote version is known yet.
373 static int read_timeout(int fd, char *buf, size_t len)
377 io_flush(NORMAL_FLUSH);
380 /* until we manage to read *something* */
389 if (msg_fd_in >= 0) {
390 FD_SET(msg_fd_in, &r_fds);
391 if (msg_fd_in > maxfd)
393 } else if (msg_list_head) {
394 FD_SET(msg_fd_out, &w_fds);
395 if (msg_fd_out > maxfd)
398 if (io_filesfrom_f_out >= 0) {
400 if (io_filesfrom_buflen == 0) {
401 if (io_filesfrom_f_in >= 0) {
402 FD_SET(io_filesfrom_f_in, &r_fds);
403 new_fd = io_filesfrom_f_in;
405 io_filesfrom_f_out = -1;
409 FD_SET(io_filesfrom_f_out, &w_fds);
410 new_fd = io_filesfrom_f_out;
416 tv.tv_sec = select_timeout;
421 count = select(maxfd + 1, &r_fds, &w_fds, NULL, &tv);
425 exit_cleanup(RERR_SOCKETIO);
430 if (msg_fd_in >= 0 && FD_ISSET(msg_fd_in, &r_fds))
432 else if (msg_list_head && FD_ISSET(msg_fd_out, &w_fds))
433 msg_list_push(NORMAL_FLUSH);
435 if (io_filesfrom_f_out >= 0) {
436 if (io_filesfrom_buflen) {
437 if (FD_ISSET(io_filesfrom_f_out, &w_fds)) {
438 int l = write(io_filesfrom_f_out,
440 io_filesfrom_buflen);
442 if (!(io_filesfrom_buflen -= l))
443 io_filesfrom_bp = io_filesfrom_buf;
445 io_filesfrom_bp += l;
447 /* XXX should we complain? */
448 io_filesfrom_f_out = -1;
451 } else if (io_filesfrom_f_in >= 0) {
452 if (FD_ISSET(io_filesfrom_f_in, &r_fds)) {
453 int l = read(io_filesfrom_f_in,
455 sizeof io_filesfrom_buf);
457 /* Send end-of-file marker */
458 io_filesfrom_buf[0] = '\0';
459 io_filesfrom_buf[1] = '\0';
460 io_filesfrom_buflen = io_filesfrom_lastchar? 2 : 1;
461 io_filesfrom_f_in = -1;
464 char *s = io_filesfrom_buf + l;
465 /* Transform CR and/or LF into '\0' */
466 while (s-- > io_filesfrom_buf) {
467 if (*s == '\n' || *s == '\r')
471 if (!io_filesfrom_lastchar) {
472 /* Last buf ended with a '\0', so don't
473 * let this buf start with one. */
474 while (l && !*io_filesfrom_bp)
475 io_filesfrom_bp++, l--;
478 io_filesfrom_bp = io_filesfrom_buf;
480 char *f = io_filesfrom_bp;
483 /* Eliminate any multi-'\0' runs. */
485 if (!(*t++ = *f++)) {
486 while (f != eob && !*f)
490 io_filesfrom_lastchar = f[-1];
492 io_filesfrom_buflen = l;
498 if (!FD_ISSET(fd, &r_fds))
501 n = read(fd, buf, len);
505 whine_about_eof(fd); /* Doesn't return. */
506 if (errno == EINTR || errno == EWOULDBLOCK
510 /* Don't write errors on a dead socket. */
512 io_multiplexing_close();
513 rsyserr(FERROR, errno, "read error");
514 exit_cleanup(RERR_STREAMIO);
521 if (io_timeout && fd == sock_f_in)
522 last_io = time(NULL);
529 * Read a line into the "fname" buffer (which must be at least MAXPATHLEN
532 int read_filesfrom_line(int fd, char *fname)
534 char ch, *s, *eob = fname + MAXPATHLEN - 1;
536 int reading_remotely = remote_filesfrom_file != NULL;
537 int nulls = eol_nulls || reading_remotely;
542 cnt = read(fd, &ch, 1);
543 if (cnt < 0 && (errno == EWOULDBLOCK
544 || errno == EINTR || errno == EAGAIN)) {
549 tv.tv_sec = select_timeout;
551 if (!select(fd+1, &fds, NULL, NULL, &tv))
557 if (nulls? !ch : (ch == '\r' || ch == '\n')) {
558 /* Skip empty lines if reading locally. */
559 if (!reading_remotely && s == fname)
569 if (*fname == '#' || *fname == ';')
576 static char *iobuf_out;
577 static int iobuf_out_cnt;
579 void io_start_buffering_out(void)
583 if (!(iobuf_out = new_array(char, IO_BUFFER_SIZE)))
584 out_of_memory("io_start_buffering_out");
589 static char *iobuf_in;
590 static size_t iobuf_in_siz;
592 void io_start_buffering_in(void)
596 iobuf_in_siz = 2 * IO_BUFFER_SIZE;
597 if (!(iobuf_in = new_array(char, iobuf_in_siz)))
598 out_of_memory("io_start_buffering_in");
602 void io_end_buffering(void)
604 io_flush(NORMAL_FLUSH);
605 if (!io_multiplexing_out) {
613 * Continue trying to read len bytes - don't return until len has been
616 static void read_loop(int fd, char *buf, size_t len)
619 int n = read_timeout(fd, buf, len);
628 * Read from the file descriptor handling multiplexing - return number
631 * Never returns <= 0.
633 static int readfd_unbuffered(int fd, char *buf, size_t len)
635 static size_t remaining;
636 static size_t iobuf_in_ndx;
640 if (!iobuf_in || fd != sock_f_in)
641 return read_timeout(fd, buf, len);
643 if (!io_multiplexing_in && remaining == 0) {
644 remaining = read_timeout(fd, iobuf_in, iobuf_in_siz);
650 len = MIN(len, remaining);
651 memcpy(buf, iobuf_in + iobuf_in_ndx, len);
658 read_loop(fd, line, 4);
661 remaining = tag & 0xFFFFFF;
662 tag = (tag >> 24) - MPLEX_BASE;
666 if (remaining > iobuf_in_siz) {
667 if (!(iobuf_in = realloc_array(iobuf_in, char,
669 out_of_memory("readfd_unbuffered");
670 iobuf_in_siz = remaining;
672 read_loop(fd, iobuf_in, remaining);
677 if (remaining >= sizeof line) {
678 rprintf(FERROR, "multiplexing overflow %d:%ld\n\n",
679 tag, (long)remaining);
680 exit_cleanup(RERR_STREAMIO);
682 read_loop(fd, line, remaining);
683 rwrite((enum logcode)tag, line, remaining);
687 rprintf(FERROR, "unexpected tag %d\n", tag);
688 exit_cleanup(RERR_STREAMIO);
693 io_flush(NORMAL_FLUSH);
701 * Do a buffered read from @p fd. Don't return until all @p n bytes
702 * have been read. If all @p n can't be read then exit with an
705 static void readfd(int fd, char *buffer, size_t N)
711 ret = readfd_unbuffered(fd, buffer + total, N-total);
715 if (fd == write_batch_monitor_in) {
716 if ((size_t)write(batch_fd, buffer, total) != total)
717 exit_cleanup(RERR_FILEIO);
721 stats.total_read += total;
725 int32 read_int(int f)
732 if (ret == (int32)0xffffffff)
737 int64 read_longint(int f)
743 if ((int32)ret != (int32)0xffffffff)
747 rprintf(FERROR,"Integer overflow - attempted 64 bit offset\n");
748 exit_cleanup(RERR_UNSUPPORTED);
751 ret = IVAL(b,0) | (((int64)IVAL(b,4))<<32);
757 void read_buf(int f,char *buf,size_t len)
762 void read_sbuf(int f,char *buf,size_t len)
768 unsigned char read_byte(int f)
771 read_buf(f, (char *)&c, 1);
777 * Sleep after writing to limit I/O bandwidth usage.
779 * @todo Rather than sleeping after each write, it might be better to
780 * use some kind of averaging. The current algorithm seems to always
781 * use a bit less bandwidth than specified, because it doesn't make up
782 * for slow periods. But arguably this is a feature. In addition, we
783 * ought to take the time used to write the data into account.
785 * During some phases of big transfers (file FOO is uptodate) this is
786 * called with a small bytes_written every time. As the kernel has to
787 * round small waits up to guarantee that we actually wait at least the
788 * requested number of microseconds, this can become grossly inaccurate.
789 * We therefore keep track of the bytes we've written over time and only
790 * sleep when the accumulated delay is at least 1 tenth of a second.
792 static void sleep_for_bwlimit(int bytes_written)
794 static struct timeval prior_tv;
795 static long total_written = 0;
796 struct timeval tv, start_tv;
797 long elapsed_usec, sleep_usec;
799 #define ONE_SEC 1000000L /* # of microseconds in a second */
804 total_written += bytes_written;
806 gettimeofday(&start_tv, NULL);
807 if (prior_tv.tv_sec) {
808 elapsed_usec = (start_tv.tv_sec - prior_tv.tv_sec) * ONE_SEC
809 + (start_tv.tv_usec - prior_tv.tv_usec);
810 total_written -= elapsed_usec * bwlimit / (ONE_SEC/1024);
811 if (total_written < 0)
815 sleep_usec = total_written * (ONE_SEC/1024) / bwlimit;
816 if (sleep_usec < ONE_SEC / 10) {
821 tv.tv_sec = sleep_usec / ONE_SEC;
822 tv.tv_usec = sleep_usec % ONE_SEC;
823 select(0, NULL, NULL, NULL, &tv);
825 gettimeofday(&prior_tv, NULL);
826 elapsed_usec = (prior_tv.tv_sec - start_tv.tv_sec) * ONE_SEC
827 + (prior_tv.tv_usec - start_tv.tv_usec);
828 total_written = (sleep_usec - elapsed_usec) * bwlimit / (ONE_SEC/1024);
832 /* Write len bytes to the file descriptor fd, looping as necessary to get
833 * the job done and also (in the generator) reading any data on msg_fd_in
834 * (to avoid deadlock).
836 * This function underlies the multiplexing system. The body of the
837 * application never calls this function directly. */
838 static void writefd_unbuffered(int fd,char *buf,size_t len)
842 int maxfd, count, ret;
847 while (total < len) {
852 if (msg_fd_in >= 0) {
854 FD_SET(msg_fd_in,&r_fds);
855 if (msg_fd_in > maxfd)
859 tv.tv_sec = select_timeout;
863 count = select(maxfd + 1, msg_fd_in >= 0 ? &r_fds : NULL,
867 if (count < 0 && errno == EBADF)
868 exit_cleanup(RERR_SOCKETIO);
873 if (msg_fd_in >= 0 && FD_ISSET(msg_fd_in, &r_fds))
876 if (!FD_ISSET(fd, &w_fds))
880 if (bwlimit && n > bwlimit_writemax)
881 n = bwlimit_writemax;
882 ret = write(fd, buf + total, n);
888 if (errno == EWOULDBLOCK || errno == EAGAIN) {
894 /* Don't try to write errors back across the stream. */
895 if (fd == sock_f_out)
896 io_multiplexing_close();
897 rsyserr(FERROR, errno,
898 "writefd_unbuffered failed to write %ld bytes: phase \"%s\"",
899 (long)len, io_write_phase);
900 exit_cleanup(RERR_STREAMIO);
905 if (fd == sock_f_out) {
907 last_io = time(NULL);
908 sleep_for_bwlimit(ret);
917 * Write an message to a multiplexed stream. If this fails then rsync
920 static void mplex_write(enum msgcode code, char *buf, size_t len)
925 SIVAL(buffer, 0, ((MPLEX_BASE + (int)code)<<24) + len);
927 if (n > sizeof buffer - 4)
928 n = sizeof buffer - 4;
930 memcpy(&buffer[4], buf, n);
931 writefd_unbuffered(sock_f_out, buffer, n+4);
937 writefd_unbuffered(sock_f_out, buf, len);
941 void io_flush(int flush_it_all)
943 msg_list_push(flush_it_all);
945 if (!iobuf_out_cnt || no_flush)
948 if (io_multiplexing_out)
949 mplex_write(MSG_DATA, iobuf_out, iobuf_out_cnt);
951 writefd_unbuffered(sock_f_out, iobuf_out, iobuf_out_cnt);
956 static void writefd(int fd,char *buf,size_t len)
958 if (fd == msg_fd_out) {
959 rprintf(FERROR, "Internal error: wrong write used in receiver.\n");
960 exit_cleanup(RERR_PROTOCOL);
963 if (fd == sock_f_out)
964 stats.total_written += len;
966 if (fd == write_batch_monitor_out) {
967 if ((size_t)write(batch_fd, buf, len) != len)
968 exit_cleanup(RERR_FILEIO);
971 if (!iobuf_out || fd != sock_f_out) {
972 writefd_unbuffered(fd, buf, len);
977 int n = MIN((int)len, IO_BUFFER_SIZE - iobuf_out_cnt);
979 memcpy(iobuf_out+iobuf_out_cnt, buf, n);
985 if (iobuf_out_cnt == IO_BUFFER_SIZE)
986 io_flush(NORMAL_FLUSH);
991 void write_int(int f,int32 x)
999 void write_int_named(int f, int32 x, const char *phase)
1001 io_write_phase = phase;
1003 io_write_phase = phase_unknown;
1008 * Note: int64 may actually be a 32-bit type if ./configure couldn't find any
1009 * 64-bit types on this platform.
1011 void write_longint(int f, int64 x)
1015 if (x <= 0x7FFFFFFF) {
1016 write_int(f, (int)x);
1021 rprintf(FERROR,"Integer overflow - attempted 64 bit offset\n");
1022 exit_cleanup(RERR_UNSUPPORTED);
1024 write_int(f, (int32)0xFFFFFFFF);
1025 SIVAL(b,0,(x&0xFFFFFFFF));
1026 SIVAL(b,4,((x>>32)&0xFFFFFFFF));
1032 void write_buf(int f,char *buf,size_t len)
1037 /** Write a string to the connection */
1038 static void write_sbuf(int f,char *buf)
1040 write_buf(f, buf, strlen(buf));
1044 void write_byte(int f,unsigned char c)
1046 write_buf(f,(char *)&c,1);
1052 * Read a line of up to @p maxlen characters into @p buf (not counting
1053 * the trailing null). Strips the (required) trailing newline and all
1056 * @return 1 for success; 0 for I/O error or truncation.
1058 int read_line(int f, char *buf, size_t maxlen)
1062 read_buf(f, buf, 1);
1067 if (buf[0] != '\r') {
1077 void io_printf(int fd, const char *format, ...)
1083 va_start(ap, format);
1084 len = vsnprintf(buf, sizeof buf, format, ap);
1088 exit_cleanup(RERR_STREAMIO);
1090 write_sbuf(fd, buf);
1094 /** Setup for multiplexing a MSG_* stream with the data stream. */
1095 void io_start_multiplex_out(void)
1097 io_flush(NORMAL_FLUSH);
1098 io_start_buffering_out();
1099 io_multiplexing_out = 1;
1102 /** Setup for multiplexing a MSG_* stream with the data stream. */
1103 void io_start_multiplex_in(void)
1105 io_flush(NORMAL_FLUSH);
1106 io_start_buffering_in();
1107 io_multiplexing_in = 1;
1110 /** Write an message to the multiplexed data stream. */
1111 int io_multiplex_write(enum msgcode code, char *buf, size_t len)
1113 if (!io_multiplexing_out)
1116 io_flush(NORMAL_FLUSH);
1117 stats.total_written += (len+4);
1118 mplex_write(code, buf, len);
1122 /** Stop output multiplexing. */
1123 void io_multiplexing_close(void)
1125 io_multiplexing_out = 0;
1128 void start_write_batch(int fd)
1130 /* Some communication has already taken place, but we don't
1131 * enable batch writing until here so that we can write a
1132 * canonical record of the communication even though the
1133 * actual communication so far depends on whether a daemon
1135 write_int(batch_fd, protocol_version);
1136 write_int(batch_fd, checksum_seed);
1139 write_batch_monitor_out = fd;
1141 write_batch_monitor_in = fd;
1144 void stop_write_batch(void)
1146 write_batch_monitor_out = -1;
1147 write_batch_monitor_in = -1;