From a944bfd1e9c51a2b12be71666f4b7891f9ec3bec Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 7 Feb 2001 08:09:57 +0000 Subject: Copy loop has monitoring and termination now. svn path=/trunk/; revision=3030 --- odmr.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'odmr.c') diff --git a/odmr.c b/odmr.c index d0623c0f..95da2469 100644 --- a/odmr.c +++ b/odmr.c @@ -125,7 +125,7 @@ static int odmr_getrange(int sock, struct query *ctl, const char *id, * throw their data at each other. */ smtp_sock = SockOpen(ctl->smtphost, SMTP_PORT, NULL, NULL); - if (smtp_sock) + if (smtp_sock == -1) return(PS_SOCKET); else { @@ -150,14 +150,25 @@ static int odmr_getrange(int sock, struct query *ctl, const char *id, if (FD_ISSET(sock, &readfds)) { int n = SockRead(sock, buf, sizeof(buf)); + if (n <= 0) + break; + SockWrite(smtp_sock, buf, n); + if (outlevel >= O_MONITOR) + report(stdout, "ODMR< %s\n", buf); } if (FD_ISSET(smtp_sock, &readfds)) { int n = SockRead(smtp_sock, buf, sizeof(buf)); + if (n <= 0) + break; + SockWrite(sock, buf, n); + if (outlevel >= O_MONITOR) + report(stdout, "ODMR> %s\n", buf); } } + SockClose(smtp_sock); } return(0); -- cgit v1.2.3