Commit cd6bc85a authored by Tom Lane's avatar Tom Lane

Remove uses of MSG_WAITALL temporarily, since it doesn't

seem to be portable (HPUX doesn't like it, anyway).  Also, clean up
StreamConnection(), which was mis-coded to assume that the address
family field is already set when it's called.
parent 21badba1
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: pqcomm.c,v 1.61 1999/01/12 12:49:51 scrappy Exp $ * $Id: pqcomm.c,v 1.62 1999/01/17 03:10:23 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -102,16 +102,11 @@ int ...@@ -102,16 +102,11 @@ int
pq_getchar(void) pq_getchar(void)
{ {
char c; char c;
char isDone = 0;
do { while (recv(MyProcPort->sock, &c, 1, 0) != 1) {
if (recv(MyProcPort->sock,&c,1,MSG_WAITALL) != 1) {
if (errno != EINTR) if (errno != EINTR)
return EOF; /* Not interrupted, so something went wrong */ return EOF; /* Not interrupted, so something went wrong */
} }
else
isDone = 1;
} while (!isDone);
return c; return c;
} }
...@@ -123,17 +118,12 @@ pq_getchar(void) ...@@ -123,17 +118,12 @@ pq_getchar(void)
int int
pq_peekchar(void) { pq_peekchar(void) {
char c; char c;
char isDone = 0;
do { while (recv(MyProcPort->sock, &c, 1, MSG_PEEK) != 1) {
if (recv(MyProcPort->sock,&c,1,MSG_WAITALL | MSG_PEEK) != 1) {
if (errno != EINTR) if (errno != EINTR)
return EOF; /* Not interrupted, so something went wrong */ return EOF; /* Not interrupted, so something went wrong */
} }
else
isDone = 1;
} while (!isDone);
return c; return c;
} }
...@@ -568,14 +558,10 @@ StreamServerPort(char *hostName, short portName, int *fdP) ...@@ -568,14 +558,10 @@ StreamServerPort(char *hostName, short portName, int *fdP)
int int
StreamConnection(int server_fd, Port *port) StreamConnection(int server_fd, Port *port)
{ {
int len;
SOCKET_SIZE_TYPE addrlen; SOCKET_SIZE_TYPE addrlen;
int family = port->raddr.sa.sa_family;
/* accept connection (and fill in the client (remote) address) */ /* accept connection (and fill in the client (remote) address) */
len = family == AF_INET ? addrlen = sizeof(port->raddr);
sizeof(struct sockaddr_in) : sizeof(struct sockaddr_un);
addrlen = len;
if ((port->sock = accept(server_fd, if ((port->sock = accept(server_fd,
(struct sockaddr *) & port->raddr, (struct sockaddr *) & port->raddr,
&addrlen)) < 0) &addrlen)) < 0)
...@@ -585,14 +571,16 @@ StreamConnection(int server_fd, Port *port) ...@@ -585,14 +571,16 @@ StreamConnection(int server_fd, Port *port)
} }
/* fill in the server (local) address */ /* fill in the server (local) address */
addrlen = len; addrlen = sizeof(port->laddr);
if (getsockname(port->sock, (struct sockaddr *) & port->laddr, if (getsockname(port->sock, (struct sockaddr *) & port->laddr,
&addrlen) < 0) &addrlen) < 0)
{ {
elog(ERROR, "postmaster: StreamConnection: getsockname: %m"); elog(ERROR, "postmaster: StreamConnection: getsockname: %m");
return STATUS_ERROR; return STATUS_ERROR;
} }
if (family == AF_INET)
/* select TCP_NODELAY option if it's a TCP connection */
if (port->laddr.sa.sa_family == AF_INET)
{ {
struct protoent *pe; struct protoent *pe;
int on = 1; int on = 1;
......
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include "postgres.h" #include "postgres.h"
...@@ -146,7 +147,7 @@ pqGetNBytes(char *s, size_t len) ...@@ -146,7 +147,7 @@ pqGetNBytes(char *s, size_t len)
int bytesDone = 0; int bytesDone = 0;
do { do {
int r = recv(MyProcPort->sock, s+bytesDone, len-bytesDone, MSG_WAITALL); int r = recv(MyProcPort->sock, s+bytesDone, len-bytesDone, 0);
if (r == 0 || r == -1) { if (r == 0 || r == -1) {
if (errno != EINTR) if (errno != EINTR)
return EOF; /* All other than signal-interrupted is error */ return EOF; /* All other than signal-interrupted is error */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment