zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: PATCH: Today's TCP Fix (TM) (3)
Date: Wed, 29 May 2002 14:01:58 +0100	[thread overview]
Message-ID: <24542.1022677318@csr.com> (raw)

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@csr.com>                  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.
**********************************************************************


                 reply	other threads:[~2002-05-29 13:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=24542.1022677318@csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).