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

More tcp problems



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@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