bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CVS Feature Branch - version - cannot write to stdout


From: Mark D. Baushke
Subject: Re: CVS Feature Branch - version - cannot write to stdout
Date: Wed, 20 Oct 2004 16:47:11 -0700

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Folks,

I have not heard any response concerning the problem that Conrad
reported and my proposed fix.

Original problem statement:

  Conrad T. Pino <address@hidden> writes:
  
  > Hi All,
  > 
  > I'd appreciate interpretations and opinions about following message:
  > 
  >     H:\cvs-1.12\WinDebug>cvs version
  >     Client: Concurrent Versions System (CVS) 1.12.9.1 (client)
  >     Server: cannot write to stdout: No such file or directory
  >     Concurrent Versions System (CVS) 1.11.17 (client/server)
  > 
  >     H:\cvs-1.12\WinDebug>
  > 
  > Thanks in advance,
  > 
  > Conrad Pino

  In a later message with some debugging output we see:

  > H:\cvs-1.12>cd WinDebug
  > ==================================
  > Attempt with local LAN server:
  > 
  > H:\cvs-1.12\WinDebug>cvs version
  > Client: Concurrent Versions System (CVS) 1.12.9.1 (client)
  > Server: WSAGetLastError test, s = -1
  > cannot write to stdout: No such file or directory
  > WSAGetLastError = 10038
  > Concurrent Versions System (CVS) 1.11.17 (client/server)
  > 
  > H:\cvs-1.12\WinDebug>
  > ==================================
  > Error code explanation:
  > 
  > WSAENOTSOCK = 10038, Socket operation on nonsocket. 
  > 
  > An operation was attempted on something that is not a socket.
  > Either the socket handle parameter did not reference a valid
  > socket, or for select, a member of an fd_set was not valid.  
  > ==================================
  > Conrad


It seems that under normal circumstances, a select() for stdout on a
windows client will see select() return s == -1 and errno == 0 and
SOCK_ERRNO == WSAENOTSOCK.

As it is, in theory, possible for the output of cvs to be something that
is a socket, it would probably make sense to just ignore printing output
in the case where SOCK_ERRNO == WSAENOTSOCK rather than to avoid calling
select() in the first place.

What do folks think of my patch? Is there a better way to do what is
needful on Windows?

        Thanks,
        -- Mark

ChangeLog entry:

2004-10-20  Mark D. Baushke  <address@hidden>
  
        * client.c (handle_m, handle_e): Handle winsock problems with
        non-socket fds.

 Index: src/client.c
 ===================================================================
 RCS file: /cvs/ccvs/src/client.c,v
 retrieving revision 1.401
 diff -u -p -r1.401 client.c
 --- src/client.c       19 Oct 2004 19:34:26 -0000      1.401
 +++ src/client.c       20 Oct 2004 23:33:09 -0000
 @@ -2672,7 +2672,15 @@ handle_m (char *args, size_t len)
      FD_SET (STDOUT_FILENO, &wfds);
      s = select (STDOUT_FILENO+1, NULL, &wfds, NULL, NULL);
      if (s < 1)
 +    {
 +#if defined(HAVE_WINSOCK_H) && defined(WSAENOTSOCK)
 +      if (SOCK_ERRNO != WSAENOTSOCK)
 +          error (1, 0, "cannot write to stdout: %s",
 +                 SOCK_STRERROR (SOCK_ERRNO));
 +#else
          perror ("cannot write to stdout");
 +#endif
 +    }
      fwrite (args, len, sizeof (*args), stdout);
      putc ('\n', stdout);
  }
 @@ -2734,7 +2742,15 @@ handle_e (char *args, size_t len)
       * terminate cvs.
       */
      if (s < 1)
 +    {
 +#if defined(HAVE_WINSOCK_H) && defined(WSAENOTSOCK)
 +      if (SOCK_ERRNO != WSAENOTSOCK)
 +          fperrmsg (stdout, 1, 0, "cannot write to stderr: %s",
 +                    SOCK_STRERROR (SOCK_ERRNO));
 +#else
          fperrmsg (stdout, 1, errno, "cannot write to stderr");
 +#endif
 +    }
      fwrite (args, len, sizeof (*args), stderr);
      putc ('\n', stderr);
  }
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)

iD8DBQFBdvj/3x41pRYZE/gRAppmAKCElCjCG8DtApCJsTPcET5z6yQ/UwCfWJb8
BSMP9gkAvWhHy5F9MMSdPWo=
=Qwlt
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]