Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: Today's TCP Fix (TM) (3)



It's not useful to send the output to the zle file descriptor; it can't
be redirected and it causes a crash in a subshell.

I presume the most obvious thing is to send all expected messages to
stdout.  However, there's an argument for messages from the verbose
options to go to stderr (which is what I originally wrote before
realising it could be surprising).

Another problem I've noticed, not fixed here, is that at the moment it's
not possible to recover cleanly if someone else comes along and closes
your fd's.  They shouldn't, but it should be possible to remove the
sessions none the less.  Further, if you then attempt to unload
zsh/net/tcp, the shell gets left in an inconsistent state and another
`ztcp' causes a crash.

Index: Src/Modules/tcp.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/tcp.c,v
retrieving revision 1.29
diff -u -r1.29 tcp.c
--- Src/Modules/tcp.c	24 May 2002 13:02:01 -0000	1.29
+++ Src/Modules/tcp.c	29 May 2002 12:57:30 -0000
@@ -461,7 +461,7 @@
 	setiparam("REPLY", sess->fd);
 
 	if (verbose)
-	    fprintf(shout, "%d listener is on fd %d\n", ntohs(sess->sock.in.sin_port), sess->fd);
+	    printf("%d listener is on fd %d\n", ntohs(sess->sock.in.sin_port), sess->fd);
 
 	return 0;
 
@@ -553,7 +553,7 @@
 	setiparam("REPLY", sess->fd);
 
 	if (verbose)
-	    fprintf(shout, "%d is on fd %d\n", ntohs(sess->peer.in.sin_port), sess->fd);
+	    printf("%d is on fd %d\n", ntohs(sess->peer.in.sin_port), sess->fd);
     }
     else
     {
@@ -575,7 +575,7 @@
 			remotename = ztpeer->h_name;
 		    else
 			remotename = ztrdup(inet_ntoa(sess->peer.in.sin_addr));
-		    fprintf(shout, "%s:%d %s %s:%d is on fd %d%s\n",
+		    printf("%s:%d %s %s:%d is on fd %d%s\n",
 			    localname, ntohs(sess->sock.in.sin_port),
 			    ((sess->flags & ZTCP_LISTEN) ? "-<" :
 			     ((sess->flags & ZTCP_INBOUND) ? "<-" : "->")),
@@ -649,7 +649,7 @@
 	    setiparam("REPLY", sess->fd);
 
 	    if (verbose)
-		fprintf(shout, "%s:%d is now on fd %d\n",
+		printf("%s:%d is now on fd %d\n",
 			desthost, destport, sess->fd);
 	}
 	

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 392070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************



Messages sorted by: Reverse Date, Date, Thread, Author