From: Tanaka Akira Date: 2005-02-08T21:48:50+09:00 Subject: Re: Serialport problems in multi-threaded application In article <33120.192.168.2.102.1107793208.squirrel@192.168.2.102>, "Caleb Tennis" writes: > The program hangs on the read() call - if I run the same program above and > perform the "SerialPort.new.write()" call without making a new thread, the > code works fine. I performed an strace, with some interesting results - > namely, that for the multithreaded application I don't ever see a call to > the system's read/write, just select. The above code works fine for > regular files - it just seems to have trouble with device files. > > Is this a bug or am I just missing something? It seems that write buffer should be flushed before select for reading. Index: io.c =================================================================== RCS file: /src/ruby/io.c,v retrieving revision 1.246.2.71 diff -u -p -r1.246.2.71 io.c --- io.c 25 Jan 2005 04:02:27 -0000 1.246.2.71 +++ io.c 8 Feb 2005 12:46:54 -0000 @@ -236,14 +236,12 @@ rb_io_check_readable(fptr) if (!(fptr->mode & FMODE_READABLE)) { rb_raise(rb_eIOError, "not opened for reading"); } -#if NEED_IO_SEEK_BETWEEN_RW if (((fptr->mode & FMODE_WBUF) || (fptr->mode & (FMODE_SYNCWRITE|FMODE_RBUF)) == FMODE_SYNCWRITE) && !feof(fptr->f) && !fptr->f2) { io_seek(fptr, 0, SEEK_CUR); } -#endif fptr->mode |= FMODE_RBUF; } -- Tanaka Akira