delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/2000/12/22/17:17:02

Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-developers-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin-developers/>
List-Post: <mailto:cygwin-developers AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-developers-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-developers-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin-developers AT sources DOT redhat DOT com
Date: Fri, 22 Dec 2000 17:16:18 -0500
From: Christopher Faylor <cgf AT redhat DOT com>
To: cygwin-developers AT cygwin DOT com
Subject: Re: Serial blocking read
Message-ID: <20001222171618.B12837@redhat.com>
Reply-To: cygwin-developers AT cygwin DOT com
Mail-Followup-To: cygwin-developers AT cygwin DOT com
References: <20001215210940 DOT A12596 AT redhat DOT com> <Pine DOT GSO DOT 4 DOT 21 DOT 0012151851070 DOT 28122-100000 AT myth9 DOT Stanford DOT EDU> <20001215215842 DOT A11915 AT redhat DOT com> <20001217190701 DOT A24481 AT redhat DOT com>
Mime-Version: 1.0
User-Agent: Mutt/1.3.11i
In-Reply-To: <20001217190701.A24481@redhat.com>; from cgf@redhat.com on Sun, Dec 17, 2000 at 07:07:01PM -0500

Well, I've checked this in.  I would appreciate if someone could actually
verify that my patch does the right thing.  I'm not set up to verify the
serial code anymore.

cgf

On Sun, Dec 17, 2000 at 07:07:01PM -0500, Christopher Faylor wrote:
>Nevermind.  I understand now.  I was confused by the fact that this code
>should not have been triggered unless the 'ready_for_read' had indicated that
>there was stuff to read.
>
>Does the below patch work for you?  It avoids code duplication.
>
>cgf
>
>On Fri, Dec 15, 2000 at 09:58:42PM -0500, Christopher Faylor wrote:
>>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.
>
>Sun Dec 17 19:03:52 2000  Christopher Faylor <cgf AT cygnus DOT com>
>
>	* fhandler_serial.cc (fhandler_serial::raw_read): Always find number of 
>	bytes ready to be read whether overlapped_armed or not.
>
>Index: fhandler_serial.cc
>===================================================================
>RCS file: /cvs/uberbaum/winsup/cygwin/fhandler_serial.cc,v
>retrieving revision 1.9
>diff -u -p -r1.9 fhandler_serial.cc
>--- fhandler_serial.cc	2000/09/08 02:56:54	1.9
>+++ fhandler_serial.cc	2000/12/18 00:07:05
>@@ -79,15 +79,16 @@ fhandler_serial::raw_read (void *ptr, si
> 			// if vmin > ulen then things won't work right.
> 	  overlapped_armed = -1;
> 	}
>-      if (!overlapped_armed)
>+
>+      if (!ClearCommError (get_handle (), &ev, &st))
>+	goto err;
>+      else if (ev)
>+	termios_printf ("error detected %x", ev);
>+      else if (st.cbInQue)
>+	inq = st.cbInQue;
>+      else if (!overlapped_armed)
> 	{
>-	  if (!ClearCommError (get_handle (), &ev, &st))
>-	    goto err;
>-	  else if (ev)
>-	    termios_printf ("error detected %x", ev);
>-	  else if (st.cbInQue)
>-	    inq = st.cbInQue;
>-	  else if ((size_t)tot >= minchars)
>+	  if ((size_t)tot >= minchars)
> 	    break;
> 	  else if (WaitCommEvent (get_handle (), &ev, &io_status))
> 	    {

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019