zsh-workers
 help / color / mirror / code / Atom feed
* Mangement of fdtable[]
@ 2015-10-16  0:22 Bart Schaefer
  2015-10-16  9:56 ` Chi Hsuan Yen
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Bart Schaefer @ 2015-10-16  0:22 UTC (permalink / raw)
  To: zsh-workers

I was puzzling over Yen Chi Hsuan's bug report in 36866 so was looking
through tcp.c and noticed that it opens file descriptors with socket()
without marking them used in fdtable[].  The only time they're handled
"properly" is with "ztcp -l" which makes a movefd() call.

I think this means some fds may be closed in some cases they shouldn't,
or conversely left open in cases they shouldn't.  This may apply to fds
in other modules, e.g., the descriptor from gdbm_open() in db_gdbm.c.

This further led me to notice that when descriptors are manipulated in
utils.c, it carefully calls the static check_fd_table() function every
time to be sure the descriptor has a slot in the table before an FDT_*
value is poked for it.  Other parts of the code (mostly exec.c) simply
reference fdtable[N] without error checking.

I guess this is OK because fdtable[] is allocated zopenmax() slots in
zsh_main(), but it seems inconsistent if not actually wrong.

Comments?

-- 
Barton E. Schaefer


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

end of thread, other threads:[~2015-10-26  1:15 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-16  0:22 Mangement of fdtable[] Bart Schaefer
2015-10-16  9:56 ` Chi Hsuan Yen
2015-10-16 19:44 ` Peter Stephenson
2015-10-24 18:16 ` Peter Stephenson
2015-10-24 18:43   ` Bart Schaefer
2015-10-24 19:14     ` Peter Stephenson
2015-10-24 19:37       ` Bart Schaefer
2015-10-24 19:43       ` Peter Stephenson
2015-10-24 21:05         ` Bart Schaefer
2015-10-25 18:44           ` Peter Stephenson
2015-10-26  1:15             ` 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).