From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: <063412cb21a6433d959274d7db87d242@ladd.quanstro.net> <92606a17ce255a2e74049e4090d948b3@proxima.alt.za> Date: Mon, 19 May 2014 20:44:41 +0100 Message-ID: From: Charles Forsyth To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=089e010d8a068da4c304f9c5fe57 Subject: Re: [9fans] syscall 53 Topicbox-Message-UUID: e8aa5e1e-ead8-11e9-9d60-3106f5b1d025 --089e010d8a068da4c304f9c5fe57 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 19 May 2014 20:15, Aram H=C4=83v=C4=83rneanu wrote: > Some people claimed > that using it leaked file descriptors in multithreaded programs. I > don't understand why this problem can't be solved by opening it > close-on-exec. > The optimisation was a static int file descriptor. That was troublesome in the context of processes that shared memory but not file descriptor groups, or somehow rearranged descriptors and then called time/nsec again. A fork and syslog might be enough. The improved version cached file descriptors per-process, but using a table with an entry per-process (but only up to 64, when it reverted to earlier behaviour) and using a process ID in _tos. Since a library function has no idea what's happening in rfork(), or In case file descriptors had been closed meanwhile, it would retry once(!). In some cases, that might lead it to read from a file descriptor that was open, but not on the time, causing much confusion. Further elaboration of the mechanism had been proposed to deal with that. I prefer one or other Gordian Knot technique, myself. --089e010d8a068da4c304f9c5fe57 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

= On 19 May 2014 20:15, Aram H=C4=83v=C4=83rneanu <aram.h@mgk.ro> = wrote:
Some people claime= d
that using it leaked file descriptors in multithreaded programs. I
don't understand why this problem can't be solved by opening it
close-on-exec.

The optimisation was a static int file descriptor.
That was troublesom= e in the context of
processes that shared m= emory but not file descriptor groups,
or somehow rearranged descriptors and then calle= d time/nsec again.
A fork and syslog might = be enough.
The improved version cached file= descriptors per-process,
but using a table with an entry per-process (but= only up to 64,
when it reverted to earlier= behaviour) and using a process ID in _tos.
Since a library function has no idea what's happening in rfork(), or
In case file descriptors had been closed meanwhi= le, it would retry once(!).
In some cases, = that might lead it to read from a file descriptor that was open,
but not on the time, causing much confusion.
Further elaboration of the mechanism had been proposed to deal with that.=
I prefer one or other Gordian Knot techniq= ue, myself.
--089e010d8a068da4c304f9c5fe57--