Hi, At Fri, 31 Jan 2003 07:09:32 +0900, Joel VanderWerf wrote: > >>>does anyone know how to specify SA_RESTART in the signal mask such that > >>>interupted system calls are automatically restarted on solaris, as they are on > >>>linux? > >> > >>If all of sigprocmask, sigaction and SA_RESTART are available, > >>ruby always sets it. > > if that is the case, then shouldn't it be impossible for system > > calls to fail > > with EINTR? (see thread regarding solaris/flock for history) > > I'm wondering too. I see this not only in Ara's test code, but in my > own, with heavy demand by threads and processes doing shared reads and > exclusive writes. After getting all(?) my concurrency bugs out, I > still had to put in a few "rescue Errno::EINTR; retry" statements, or > else there would be some (very infrequent) failures. Interestingly, it > only seems to happen during the shared reads, so it looks like > something one thread is doing causes a system call in another thread > to be interrupted. In Solaris, it apparently needs to handle EINTR at every I/O operations. Also fseek()?
Index: file.c =================================================================== RCS file: /cvs/ruby/src/ruby/file.c,v retrieving revision 1.130 diff -u -2 -p -r1.130 file.c --- file.c 29 Jan 2003 23:28:47 -0000 1.130 +++ file.c 30 Jan 2003 22:21:47 -0000 @@ -1990,4 +1990,5 @@ rb_file_flock(obj, operation) fflush(GetWriteFile(fptr)); } + retry: TRAP_BEG; ret = flock(fileno(fptr->f), NUM2INT(operation)); @@ -2001,4 +2002,9 @@ rb_file_flock(obj, operation) #endif return Qfalse; + case EINTR: +#if defined(ERESTART) + case ERESTART: +#endif + goto retry; } rb_sys_fail(fptr->path);
-- Nobu Nakada