Re: Bogus error listing modules

2001-06-14 Thread Wayne Davison

On Thu, 14 Jun 2001, Martin Pool wrote:
 I'm slightly concerned that this may cause some other failure modes to
 falsely cause the client to return 0.

I was thinking about this myself.  The code sets eof_error = 0 for any
user of read_line(), and (judging from my quick inspection) this doesn't
seem right to me.  Perhaps read_line() should take an extra parameter
that indicates whether and EOF is OK or not.  We could then change the
calling code to normally pass that EOF is not OK except when we're doing
a module listing.  Here's a patch.

..wayne..

---8--8--8--8---cut here---8--8--8--8---
Index: authenticate.c
--- authenticate.c  26 Oct 2000 07:31:29 -  1.16
+++ authenticate.c  14 Jun 2001 17:38:26 -
@@ -224,7 +224,7 @@

io_printf(fd,%s%s\n, leader, b64_challenge);

-   if (!read_line(fd, line, sizeof(line)-1)) {
+   if (!read_line(fd, line, sizeof(line)-1, 0)) {
return NULL;
}

Index: clientserver.c
--- clientserver.c  7 May 2001 06:59:37 -   1.67
+++ clientserver.c  14 Jun 2001 17:38:26 -
@@ -44,9 +44,9 @@
extern int am_sender;
extern struct in_addr socket_address;
extern char *shell_cmd;
+   extern int list_only;

if (argc == 0  !am_sender) {
-   extern int list_only;
list_only = 1;
}

@@ -93,7 +93,7 @@

io_printf(fd,@RSYNCD: %d\n, PROTOCOL_VERSION);

-   if (!read_line(fd, line, sizeof(line)-1)) {
+   if (!read_line(fd, line, sizeof(line)-1, 0)) {
return -1;
}

@@ -107,7 +107,7 @@
if (p) *p = '/';

while (1) {
-   if (!read_line(fd, line, sizeof(line)-1)) {
+   if (!read_line(fd, line, sizeof(line)-1, list_only)) {
return -1;
}

@@ -277,7 +277,7 @@
argv[argc++] = rsyncd;

while (1) {
-   if (!read_line(fd, line, sizeof(line)-1)) {
+   if (!read_line(fd, line, sizeof(line)-1, 0)) {
return -1;
}

@@ -418,7 +418,7 @@
io_printf(fd,\n);
}

-   if (!read_line(fd, line, sizeof(line)-1)) {
+   if (!read_line(fd, line, sizeof(line)-1, 0)) {
return -1;
}

@@ -429,7 +429,7 @@

while (i == -1) {
line[0] = 0;
-   if (!read_line(fd, line, sizeof(line)-1)) {
+   if (!read_line(fd, line, sizeof(line)-1, 0)) {
return -1;
}

Index: io.c
--- io.c7 May 2001 06:59:37 -   1.85
+++ io.c14 Jun 2001 17:38:28 -
@@ -560,9 +636,9 @@
write_buf(f,(char *)c,1);
 }

-int read_line(int f, char *buf, int maxlen)
+int read_line(int f, char *buf, int maxlen, int eof_ok)
 {
-   eof_error = 0;
+   eof_error = !eof_ok;

while (maxlen) {
buf[0] = 0;
---8--8--8--8---cut here---8--8--8--8---





Re: Bogus error listing modules

2001-06-14 Thread Wayne Davison

On Thu, 14 Jun 2001, Wayne Davison wrote:
 Here's a patch.

I forgot to mention that you should run make proto after applying that
patch.

..wayne..





Bogus error listing modules

2001-06-13 Thread Wayne Davison

The CVS version of rsync outputs an error on exit after listing the
modules from an rsync daemon (running rsync host::).  The following
patch fixes this.  (If you haven't applied my nohang patch, you'll see
an offset for this patch hunk.)

..wayne..

---8--8--8--8---cut here---8--8--8--8---
--- new/io.cWed Jun 13 18:45:12 2001
+++ io.cWed Jun 13 18:40:46 2001
@@ -246,12 +246,12 @@


if (n == 0) {
-   if (eof_error) {
-   rprintf(FERROR,
-%s: connection to server unexpectedly closed
- (%.0f bytes read so far)\n,
-RSYNC_NAME, (double)stats.total_read);
-   }
+   if (!eof_error)
+   exit_cleanup(0);
+   rprintf(FERROR,
+   %s: connection to server unexpectedly closed
+(%.0f bytes read so far)\n,
+   RSYNC_NAME, (double)stats.total_read);
exit_cleanup(RERR_STREAMIO);
}

---8--8--8--8---cut here---8--8--8--8---