zsh-workers
 help / color / mirror / code / Atom feed
* More tcp problems
@ 2001-09-27 11:30 Peter Stephenson
  2001-09-28 17:23 ` PATCH (partial): " Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Stephenson @ 2001-09-27 11:30 UTC (permalink / raw)
  To: Zsh hackers list

There are a few more problems with the tcp module and its interaction with
zftp.  I was hoping to fix the first one before releasing a new development
version, but it seems it goes beyond that.

- Closing a zftp connection doesn't set the session pointer to NULL.  This
  results (in my case) in a segmentation violation when opening a second
  connection.  This is because the tcp_close() frees the session, so it
  can't be re-used or even tested again.  (Simply setting the pointer to
  NULL caused other problems I didn't understand, maybe related to the rest
  of this list.)
- Don't know if this is related, but I get
  BUG: attempt to free storage at invalid address
  when opening zftp connections, in particular the first (since I
  don't get as far as a second).
- In general, it seems a little bit difficult to tell whether tcp_close()
  has actually freed the session or not.  And if it hasn't, because it
  encountered an error with close(), it's hard to see how the session
  should be freed. I think another call to tcp_close() would do it --- but
  it's hard to know when you need that.  If you do it when the session has
  already been freed, you're in big trouble.
- There's a similiar problem with tests for (sess->fd == -1) in zftp.
  If they're true, the session is never freed; opening a new one will
  simply assign a different TCP session to the same pointer, so that
  the memory leaks.
- With a failed zfopen, I now get
    zfopen:42: connection close failed: bad file number
  (plus a segmentation violation which I guess is something to do with the
  previous stuff).  I don't get that message with 4.0.1.  The function tests
  at that point to see if $ZFTP_HOST is set, and if it is, attempts to
  close the file.  I *think* that all that's changed is the zfclose
  was silent before and isn't now, because of tcp_close().  This may be a
  knock-on effect of the things above, though, i.e. it goes away if
  the session pointers are handled properly.

I hope it's possible to make tcp only return a session pointer if the fd is
valid, and to free the session unconditionally on an attempt to close it.

-- 
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.
**********************************************************************


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-09-28 17:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-27 11:30 More tcp problems Peter Stephenson
2001-09-28 17:23 ` PATCH (partial): " Bart Schaefer

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).