Remove pointless error-code checking in pg_dump/parallel.c.
authorTom Lane <[email protected]>
Sat, 10 Oct 2020 19:33:54 +0000 (15:33 -0400)
committerTom Lane <[email protected]>
Sat, 10 Oct 2020 19:33:54 +0000 (15:33 -0400)
Commit fe27009cb tried to make parallel.c's Windows implementation of
piperead() translate Windows socket errors to Unix, but that didn't
actually work because TranslateSocketError() is backend-internal code
(and not even public there).  But on closer inspection, the sole
caller of this function doesn't actually care whether the result is
zero or negative, much less inspect the errno.  So the whole exercise
is totally useless, and has been since this code was introduced.
Rip it out and just call recv() directly.

Per buildfarm.

Discussion: https://postgr.es/m/2621622.1602184554@sss.pgh.pa.us

src/bin/pg_dump/parallel.c

index 4b38ed6c5a911614791c1900ccc5f028b881baeb..a967e113782458860ed59086707d9811692b4c6b 100644 (file)
@@ -130,7 +130,7 @@ typedef struct
 
 /* Windows implementation of pipe access */
 static int pgpipe(int handles[2]);
-static int piperead(int s, char *buf, int len);
+#define piperead(a,b,c)        recv(a,b,c,0)
 #define pipewrite(a,b,c)   send(a,b,c,0)
 
 #else                          /* !WIN32 */
@@ -1817,25 +1817,4 @@ pgpipe(int handles[2])
    return 0;
 }
 
-/*
- * Windows implementation of reading from a pipe.
- */
-static int
-piperead(int s, char *buf, int len)
-{
-   int         ret = recv(s, buf, len, 0);
-
-   if (ret < 0)
-   {
-       switch (TranslateSocketError())
-       {
-           case ALL_CONNECTION_FAILURE_ERRNOS:
-               /* Treat connection loss as EOF on the pipe */
-               ret = 0;
-               break;
-       }
-   }
-   return ret;
-}
-
 #endif                         /* WIN32 */