Re: io_write()/fwrite() and EINTR on Solaris
From:
Jos Backus <jos@...>
Date:
2002-11-07 05:08:24 UTC
List:
ruby-core #567
On Thu, Nov 07, 2002 at 01:43:03PM +0900, nobu.nokada@softhome.net wrote:
> At Wed, 6 Nov 2002 13:50:08 +0900,
> Jos Backus wrote:
> > Meanwhile I intend to use the following patch (against today's HEAD). An
> > earlier version saved the original mask, blocked SIGVTALRM, called fwrite(),
> > then restored the original mask, but this seems to be safe enough. Can
> > anybody see anything wrong with it?
>
> Well, your patch makes thread switch impossible while writing
> to non-blocking IO, doesn't it? I suspect it's an acceptable
> restriction, however, cannot decide it.
Yes; if the fwrite() blocks, no thread switch will be possible because the
thread-switch signal (VTALRM) is being blocked. This is the lesser of two
evils, as the alternative means garbled output.
Do you think that perhaps using the approach used on __human68k__ is better,
i.e. use the patch below patch instead? This incurs some overhead but for my
application that would be no problem. I still worry about dropping single
characters this way though.
Index: io.c
===================================================================
RCS file: /src/ruby/io.c,v
retrieving revision 1.167
diff -u -r1.167 io.c
--- io.c 29 Oct 2002 21:35:28 -0000 1.167
+++ io.c 7 Nov 2002 04:57:53 -0000
@@ -376,7 +376,7 @@
ptr = RSTRING(str)->ptr;
n = RSTRING(str)->len;
-#ifdef __human68k__
+#if defined(__human68k__) || defined(sun)
do {
if (fputc(*ptr++, f) == EOF) {
if (ferror(f)) rb_sys_fail(fptr->path);
Thanks for your feedback, Nobu.
--
Jos Backus _/ _/_/_/ Sunnyvale, CA
_/ _/ _/
_/ _/_/_/
_/ _/ _/ _/
jos at catnook.com _/_/ _/_/_/ require 'std/disclaimer'