delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/01/28/20:07:39

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Date: Sun, 28 Jan 2001 20:06:02 -0500
From: Christopher Faylor <cgf AT redhat DOT com>
To: cygwin AT cygwin DOT com
Cc: bill AT troyxcd DOT com
Subject: Re: Serial I/O Multi-thread safe - FIX
Message-ID: <20010128200602.A27979@redhat.com>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com, bill AT troyxcd DOT com
References: <61279 DOT 216 DOT 103 DOT 53 DOT 111 DOT 980009783 DOT squirrel AT mail DOT troyxcd DOT com> <20010120120104 DOT B20693 AT redhat DOT com>
Mime-Version: 1.0
User-Agent: Mutt/1.3.11i
In-Reply-To: <20010120120104.B20693@redhat.com>; from cgf@redhat.com on Sat, Jan 20, 2001 at 12:01:04PM -0500

Any word on this?  It would be nice to get this into 1.1.8.

cgf

On Sat, Jan 20, 2001 at 12:01:04PM -0500, Christopher Faylor wrote:
>On Sat, Jan 20, 2001 at 08:56:23AM -0800, Bill Hegardt wrote:
>>Here is a fix for the problem I posted back on January 12th. The
>>problem lies in fhandler_serial.cc
>>
>>The problem is that both the raw_read() and raw_write() functions use
>>the same io_status structure. My fix below
>>creates a local structure called osWrite in the raw_write function. This
>>may not be the best way to solve the
>>problem, but it works. I have built cygwin1.dll, tested it, and the problem 
>>is solved. Serial I/O seems solid now.
>>
>>I have a document from Microsoft that explains: "A common mistake in
>>overlapped I/O is to reuse an OVERLAPPED structure
>>before the previous overlapped operation is completed". In my
>>application, one thread was blocked on a read while another
>>thread issued a write on the same handle.
>>
>>My hope is that this fix or something similar will find its
>>way into an upcoming release.
>
>I am willing to apply this, or something like it, but I'd appreciate a
>ChangeLog and a patch.  See the "Contributing" link at the Cygwin web
>page for more details.
>
>cgf
>
>>Thanks
>>
>>- Bill
>>
>>----- Cut here ------
>>
>>/* Cover function to WriteFile to provide Posix interface and semantics
>>   (as much as possible).  */
>>int
>>fhandler_serial::raw_write (const void *ptr, size_t len)
>>{
>>  DWORD bytes_written;
>>  OVERLAPPED osWrite;
>>
>>  memset (&osWrite, 0, sizeof (osWrite));
>>  osWrite.hEvent = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL);
>>  ProtectHandle (osWrite.hEvent);
>>
>>  if (overlapped_armed)
>>    PurgeComm (get_handle (), PURGE_TXABORT | PURGE_RXABORT);
>>
>>  for (;;)
>>    {
>>      overlapped_armed = TRUE;
>>      if (WriteFile (get_handle(), ptr, len, &bytes_written, &osWrite))
>>        break;
>>
>>      switch (GetLastError ())
>>        {
>>          case ERROR_OPERATION_ABORTED:
>>            continue;
>>          case ERROR_IO_PENDING:
>>            break;
>>          default:
>>            goto err;
>>        }
>>
>>      if (!GetOverlappedResult (get_handle (), &osWrite, &bytes_written,
>>TRUE))
>>        goto err;
>>
>>      break;
>>    }
>>
>>  CloseHandle(osWrite.hEvent);
>> 
>>  overlapped_armed = FALSE;
>>  return bytes_written;
>>
>>err:
>>  CloseHandle(osWrite.hEvent);
>>  __seterrno ();
>>  return -1;
>>}

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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