Serial blocking read

Christopher Faylor cgf@redhat.com
Fri Dec 15 18:58:00 GMT 2000


Ok.  Can you provide a little bit of an explanation on why this
solves your problem.  It doesn't make any sense to me that it would
by reading the code.

cgf

On Fri, Dec 15, 2000 at 06:53:31PM -0800, Dan Morris wrote:
>My bad... I totally spaced on even giving a filename.  Here's a better diff :
>
>--- fhandler_serial.cc-orig     Fri Dec 15 18:45:26 2000
>+++ fhandler_serial.cc  Fri Dec 15 00:28:04 2000
>@@ -119,6 +119,13 @@ fhandler_serial::raw_read (void *ptr, si
>            }
>        }
>
>+      if (overlapped_armed) {
>+          if (!ClearCommError (get_handle (), &ev, &st))
>+           goto err;
>+         else if (st.cbInQue)
>+           inq = st.cbInQue;
>+      }
>+
>       overlapped_armed = 0;
>       ResetEvent (io_status.hEvent);
>       if (inq > ulen)
>
>-Dan
>
>On Fri, 15 Dec 2000, Christopher Faylor wrote:
>
>> I think this is coming from fhandler_serial.cc but I don't know for
>> sure.  Can you provide a unified diff?  A complete unified diff will
>> show the filename and give a little more context.
>> 
>> The contributing link on http://cygwin.com should give you some pointers on how
>> to do this and how to provide a patch.
>> 
>> cgf
>> 
>> On Fri, Dec 15, 2000 at 05:38:09PM -0800, Dan Morris wrote:
>> >Has anyone else had problems with serial port reads blocking even when
>> >O_NONBLOCK is passed to _read in the 1.1.6-1 DLL?
>> >
>> >I noticed that my reads were appropriately non-blocking most of the time, but
>> >blocked whenever "overlapped_armed" was set, because in this case raw_read
>> >never finds out how many bytes are in the serial port's buffer.  This patch
>> >seems to fix the problem for me :
>> >
>> >121a122,128
>> >>       if (overlapped_armed) {
>> >>           if (!ClearCommError (get_handle (), &ev, &st))
>> >> 	          goto err;
>> >>           else if (st.cbInQue)
>> >>             inq = st.cbInQue;
>> >>       }
>> >> 
>> >
>> >If anyone else has found a better solution to this problem, let me know...
>> >otherwise perhaps this patch will fix things.


More information about the Cygwin-developers mailing list