Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcd6bc85

Browse files
committed
Remove uses of MSG_WAITALL temporarily, since it doesn't
seem to be portable (HPUX doesn't like it, anyway). Also, clean upStreamConnection(), which was mis-coded to assume that the addressfamily field is already set when it's called.
1 parent21badba commitcd6bc85

File tree

2 files changed

+15
-26
lines changed

2 files changed

+15
-26
lines changed

‎src/backend/libpq/pqcomm.c

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright (c) 1994, Regents of the University of California
77
*
8-
* $Id: pqcomm.c,v 1.61 1999/01/12 12:49:51 scrappy Exp $
8+
* $Id: pqcomm.c,v 1.62 1999/01/17 03:10:23 tgl Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -102,16 +102,11 @@ int
102102
pq_getchar(void)
103103
{
104104
charc;
105-
charisDone=0;
106105

107-
do {
108-
if (recv(MyProcPort->sock,&c,1,MSG_WAITALL)!=1) {
106+
while (recv(MyProcPort->sock,&c,1,0)!=1) {
109107
if (errno!=EINTR)
110-
returnEOF;/* Not interrupted, so something went wrong */
111-
}
112-
else
113-
isDone=1;
114-
}while (!isDone);
108+
returnEOF;/* Not interrupted, so something went wrong */
109+
}
115110

116111
returnc;
117112
}
@@ -123,17 +118,12 @@ pq_getchar(void)
123118
int
124119
pq_peekchar(void) {
125120
charc;
126-
charisDone=0;
127121

128-
do {
129-
if (recv(MyProcPort->sock,&c,1,MSG_WAITALL |MSG_PEEK)!=1) {
122+
while (recv(MyProcPort->sock,&c,1,MSG_PEEK)!=1) {
130123
if (errno!=EINTR)
131-
returnEOF;/* Not interrupted, so something went wrong */
132-
}
133-
else
134-
isDone=1;
135-
}while (!isDone);
136-
124+
returnEOF;/* Not interrupted, so something went wrong */
125+
}
126+
137127
returnc;
138128
}
139129

@@ -568,14 +558,10 @@ StreamServerPort(char *hostName, short portName, int *fdP)
568558
int
569559
StreamConnection(intserver_fd,Port*port)
570560
{
571-
intlen;
572561
SOCKET_SIZE_TYPEaddrlen;
573-
intfamily=port->raddr.sa.sa_family;
574562

575563
/* accept connection (and fill in the client (remote) address) */
576-
len=family==AF_INET ?
577-
sizeof(structsockaddr_in) :sizeof(structsockaddr_un);
578-
addrlen=len;
564+
addrlen=sizeof(port->raddr);
579565
if ((port->sock=accept(server_fd,
580566
(structsockaddr*)&port->raddr,
581567
&addrlen))<0)
@@ -585,14 +571,16 @@ StreamConnection(int server_fd, Port *port)
585571
}
586572

587573
/* fill in the server (local) address */
588-
addrlen=len;
574+
addrlen=sizeof(port->laddr);
589575
if (getsockname(port->sock, (structsockaddr*)&port->laddr,
590576
&addrlen)<0)
591577
{
592578
elog(ERROR,"postmaster: StreamConnection: getsockname: %m");
593579
returnSTATUS_ERROR;
594580
}
595-
if (family==AF_INET)
581+
582+
/* select TCP_NODELAY option if it's a TCP connection */
583+
if (port->laddr.sa.sa_family==AF_INET)
596584
{
597585
structprotoent*pe;
598586
inton=1;

‎src/backend/libpq/pqcomprim.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include<stdlib.h>
22
#include<stdio.h>
33
#include<sys/types.h>
4+
#include<sys/socket.h>
45
#include<netinet/in.h>
56

67
#include"postgres.h"
@@ -146,7 +147,7 @@ pqGetNBytes(char *s, size_t len)
146147
intbytesDone=0;
147148

148149
do {
149-
intr=recv(MyProcPort->sock,s+bytesDone,len-bytesDone,MSG_WAITALL);
150+
intr=recv(MyProcPort->sock,s+bytesDone,len-bytesDone,0);
150151
if (r==0||r==-1) {
151152
if (errno!=EINTR)
152153
returnEOF;/* All other than signal-interrupted is error */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp