delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/09/07/19:55:55

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <n2m-g.chlod0.3vvdk95.1@buzzy-box.bavag>
From: Bas van Gompel <cygwin DOT buzz AT bavag DOT tmfweb DOT nl>
Subject: win95 pipe problems -- report + testcase + patch (was: Re: [ANNOUNCEMENT] Updated: cygwin-1.5.11-1)
References: <200409050451 DOT i854pPi21887 AT esds DOT vss DOT fsi DOT com>
Reply-To: cygwin mailing-list <cygwin AT cygwin DOT com>
Organisation: Ehm...
User-Agent: slrn/0.9.8.0 (Win32) Hamster/2.0.5.5
To: cygwin AT cygwin DOT com
Lines: 103
Date: Wed, 8 Sep 2004 01:55:29 +0200 (MET DST)
X-IsSubscribed: yes

Op Sat, 4 Sep 2004 23:51:25 -0500 (CDT) schreef Christopher Faylor
in <200409050451 DOT i854pPi21887 AT esds DOT vss DOT fsi DOT com>:

[...]

:  - Fix some problems with rsync hangs on Windows NT class systems.  (Bob Byrnes)

This fix trips on a bug in (my) windows 95 (OSR2):
It's CreateNamedPipe returns 0 instead of -1 (INVALID_HANDLE_VALUE),
causing all operations on pipes to fail.

Testcase: (Read on below.)
(Somebody else with windows 95, please confirm this reports
'Handle 0, Error 120'.)

==== Begin mktpipe.sh ====
#!/bin/bash

cd /tmp
cat -<<'EOP' >tpipe.c
#include <windows.h>
#include <stdio.h>

main(){
  HANDLE read_pipe;
  DWORD errnum;

  SetLastError(0);
  read_pipe = CreateNamedPipe ("\\\\.\\pipe\\testpipe-1",
                               PIPE_ACCESS_INBOUND,
                               PIPE_TYPE_BYTE | PIPE_READMODE_BYTE,
                               1,       /* max instances */
                               16384,   /* output buffer size */
                               14384,   /* input buffer size */
                               NMPWAIT_USE_DEFAULT_WAIT,
                               NULL);

  if (read_pipe == INVALID_HANDLE_VALUE || !read_pipe) {
	printf("Handle %d, Error %d\n", read_pipe, GetLastError());
  } else {
	printf("No error, read handle: %d\n", read_pipe);
	CloseHandle(read_pipe);
  }
}
EOP
gcc -o tpipe.exe tpipe.c
./tpipe
rm tpipe.c tpipe.exe

===== End mktpipe.sh =====

A patch to work around this in cygwin could be: (WFM)

==== Begin pipe-w95.diff ====
--- src/winsup/cygwin/pipe.cc	3 Sep 2004 01:32:02 -0000	1.62
+++ src/winsup/cygwin/pipe.cc	7 Sep 2004 19:09:55 -0000
@@ -259,6 +259,7 @@ create_selectable_pipe (PHANDLE read_pip
          the pipe was not created earlier by some other process, even if
          the pid has been reused.  We avoid FILE_FLAG_FIRST_PIPE_INSTANCE
          because that is only available for Win2k SP2 and WinXP.  */
+      SetLastError(0);
       read_pipe = CreateNamedPipe (pipename,
                                    PIPE_ACCESS_INBOUND,
                                    PIPE_TYPE_BYTE | PIPE_READMODE_BYTE,
@@ -268,13 +269,13 @@ create_selectable_pipe (PHANDLE read_pip
                                    NMPWAIT_USE_DEFAULT_WAIT,
                                    sa_ptr);
 
-      if (read_pipe != INVALID_HANDLE_VALUE)
+      DWORD err = GetLastError ();
+      if ((read_pipe || !err) && read_pipe != INVALID_HANDLE_VALUE)
         {
           debug_printf ("pipe read handle %p", read_pipe);
           break;
         }
 
-      DWORD err = GetLastError ();
       switch (err)
         {
         case ERROR_PIPE_BUSY:

===== End pipe-w95.diff =====

I hope this patch is small enough to qualify as `trivial', as I
haven't received any reply to my legal query (yet). (Did the reply
get blocked from the list?)

ChangeLog-entry:

08-09-2004  Bas van Gompel  <cygwin-patch DOT buzz AT bavag DOT tmfweb DOT nl>

	* pipe.cc: (create_selectable_pipe) Work around bug in windows 95
	where CreateNamedPipe returns zero.

[...]

HTH,

Buzz.
-- 
  ) |  | ---/ ---/  Yes, this | This message consists of true | I do not
--  |  |   /    /   really is |   and false bits entirely.    | mail for
  ) |  |  /    /    a 72 by 4 +-------------------------------+ any1 but
--  \--| /--- /---  .sigfile. |   |perl -pe "s.u(z)\1.as."    | me. 4^re

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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