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

Commitceda17d

Browse files
committed
Remove PG_SOCK and PG_ISRSOCKET
1 parent6efe182 commitceda17d

File tree

16 files changed

+37
-75
lines changed

16 files changed

+37
-75
lines changed

‎contrib/postgres_fdw/connection.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,10 +495,7 @@ pgfdw_get_result(PGconn *conn, const char *query)
495495
/* Sleep until there's something to do */
496496
wc=WaitLatchOrSocket(MyLatch,
497497
WL_LATCH_SET |WL_SOCKET_READABLE,
498-
PQsocket(conn),
499-
#ifdefWITH_RSOCKET
500-
PQisRsocket(conn),
501-
#endif
498+
PQsocket(conn),PQisRsocket(conn),
502499
-1L);
503500
ResetLatch(MyLatch);
504501

‎src/backend/libpq/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ include $(top_builddir)/src/Makefile.global
1515
# be-fsstubs is here for historical reasons, probably belongs elsewhere
1616

1717
OBJS = be-fsstubs.o be-secure.o auth.o crypt.o hba.o ip.o md5.o pqcomm.o\
18-
pqformat.o pqmq.o pqsignal.o auth-scram.o
18+
pqformat.o pqmq.o pqsignal.o auth-scram.o
1919

2020
ifeq ($(with_openssl),yes)
2121
OBJS += be-secure-openssl.o

‎src/backend/libpq/auth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1834,7 +1834,7 @@ auth_peer(hbaPort *port)
18341834
gid_tgid;
18351835
structpasswd*pw;
18361836

1837-
if (getpeereid(PG_SOCK(port->sock),&uid,&gid)!=0)
1837+
if (getpeereid(port->sock->fd,&uid,&gid)!=0)
18381838
{
18391839
/* Provide special error message if getpeereid is a stub */
18401840
if (errno==ENOSYS)

‎src/backend/libpq/be-secure-openssl.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -423,11 +423,8 @@ be_tls_open_server(Port *port)
423423
else
424424
waitfor=WL_SOCKET_WRITEABLE;
425425

426-
WaitLatchOrSocket(MyLatch,waitfor,PG_SOCK(port->sock),
427-
#ifdefWITH_RSOCKET
428-
PG_ISRSOCKET(port->isRsocket),
429-
#endif
430-
0);
426+
WaitLatchOrSocket(MyLatch,waitfor,
427+
port->sock->fd,port->sock->isRsocket,0);
431428
gotoaloop;
432429
caseSSL_ERROR_SYSCALL:
433430
if (r<0)

‎src/backend/libpq/pqcomm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,12 @@ pq_init(void)
203203
#endif
204204

205205
#ifdefWITH_RSOCKET
206-
if (PG_ISRSOCKET(MyProcPort->sock))
206+
if (MyProcPort->sock->isRsocket)
207207
FeBeWaitSet=CreateWaitEventSetForRsocket(TopMemoryContext,3);
208208
else
209209
#endif
210210
FeBeWaitSet=CreateWaitEventSet(TopMemoryContext,3);
211-
AddWaitEventToSet(FeBeWaitSet,WL_SOCKET_WRITEABLE,PG_SOCK(MyProcPort->sock),
211+
AddWaitEventToSet(FeBeWaitSet,WL_SOCKET_WRITEABLE,MyProcPort->sock->fd,
212212
NULL,NULL);
213213
AddWaitEventToSet(FeBeWaitSet,WL_LATCH_SET,-1,MyLatch,NULL);
214214
AddWaitEventToSet(FeBeWaitSet,WL_POSTMASTER_DEATH,-1,NULL,NULL);
@@ -241,12 +241,12 @@ pq_reinit(void)
241241
#endif
242242

243243
#ifdefWITH_RSOCKET
244-
if (PG_ISRSOCKET(MyProcPort->sock))
244+
if (MyProcPort->sock->isRsocket)
245245
FeBeWaitSet=CreateWaitEventSetForRsocket(TopMemoryContext,3);
246246
else
247247
#endif
248248
FeBeWaitSet=CreateWaitEventSet(TopMemoryContext,3);
249-
AddWaitEventToSet(FeBeWaitSet,WL_SOCKET_WRITEABLE,PG_SOCK(MyProcPort->sock),
249+
AddWaitEventToSet(FeBeWaitSet,WL_SOCKET_WRITEABLE,MyProcPort->sock->fd,
250250
NULL,NULL);
251251
AddWaitEventToSet(FeBeWaitSet,WL_LATCH_SET,-1,MyLatch,NULL);
252252
AddWaitEventToSet(FeBeWaitSet,WL_POSTMASTER_DEATH,-1,NULL,NULL);

‎src/backend/postmaster/pgstat.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3736,11 +3736,7 @@ PgstatCollectorMain(int argc, char *argv[])
37363736
#ifndefWIN32
37373737
wr=WaitLatchOrSocket(MyLatch,
37383738
WL_LATCH_SET |WL_POSTMASTER_DEATH |WL_SOCKET_READABLE,
3739-
pgStatSock,
3740-
#ifdefWITH_RSOCKET
3741-
false,
3742-
#endif
3743-
-1L);
3739+
pgStatSock, false,-1L);
37443740
#else
37453741

37463742
/*
@@ -3755,7 +3751,7 @@ PgstatCollectorMain(int argc, char *argv[])
37553751
*/
37563752
wr=WaitLatchOrSocket(MyLatch,
37573753
WL_LATCH_SET |WL_POSTMASTER_DEATH |WL_SOCKET_READABLE |WL_TIMEOUT,
3758-
pgStatSock,
3754+
pgStatSock, false,
37593755
2*1000L/* msec */ );
37603756
#endif
37613757

‎src/backend/postmaster/postmaster.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4067,7 +4067,7 @@ BackendStartup(Port *port)
40674067
/* in parent, successful fork */
40684068
ereport(DEBUG2,
40694069
(errmsg_internal("forked new backend, pid=%d socket=%d",
4070-
(int)pid, (int)PG_SOCK(port->sock))));
4070+
(int)pid, (int)port->sock->fd)));
40714071

40724072
#ifdefWITH_RSOCKET
40734073
/* Increment rsocket port number for next connection */

‎src/backend/postmaster/syslogger.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -423,11 +423,7 @@ SysLoggerMain(int argc, char *argv[])
423423
#ifndefWIN32
424424
rc=WaitLatchOrSocket(MyLatch,
425425
WL_LATCH_SET |WL_SOCKET_READABLE |cur_flags,
426-
syslogPipe[0],
427-
#ifdefWITH_RSOCKET
428-
false,
429-
#endif
430-
cur_timeout);
426+
syslogPipe[0], false,cur_timeout);
431427

432428
if (rc&WL_SOCKET_READABLE)
433429
{

‎src/backend/replication/walreceiver.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,7 @@ WalReceiverMain(void)
486486
rc=WaitLatchOrSocket(&walrcv->latch,
487487
WL_POSTMASTER_DEATH |WL_SOCKET_READABLE |
488488
WL_TIMEOUT |WL_LATCH_SET,
489-
wait_fd,
490-
#ifdefWITH_RSOCKET
491-
isRsocket,
492-
#endif
489+
wait_fd,isRsocket,
493490
NAPTIME_PER_CYCLE);
494491
if (rc&WL_LATCH_SET)
495492
{

‎src/backend/replication/walsender.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,10 +1145,7 @@ WalSndWriteData(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId xid,
11451145

11461146
/* Sleep until something happens or we time out */
11471147
WaitLatchOrSocket(MyLatch,wakeEvents,
1148-
PG_SOCK(MyProcPort->sock),
1149-
#ifdefWITH_RSOCKET
1150-
PG_ISRSOCKET(MyProcPort->sock),
1151-
#endif
1148+
MyProcPort->sock->fd,MyProcPort->sock->isRsocket,
11521149
sleeptime);
11531150
}
11541151

@@ -1278,10 +1275,7 @@ WalSndWaitForWal(XLogRecPtr loc)
12781275

12791276
/* Sleep until something happens or we time out */
12801277
WaitLatchOrSocket(MyLatch,wakeEvents,
1281-
PG_SOCK(MyProcPort->sock),
1282-
#ifdefWITH_RSOCKET
1283-
PG_ISRSOCKET(MyProcPort->sock),
1284-
#endif
1278+
MyProcPort->sock->fd,MyProcPort->sock->isRsocket,
12851279
sleeptime);
12861280
}
12871281

@@ -1903,10 +1897,7 @@ WalSndLoop(WalSndSendDataCallback send_data)
19031897

19041898
/* Sleep until something happens or we time out */
19051899
WaitLatchOrSocket(MyLatch,wakeEvents,
1906-
PG_SOCK(MyProcPort->sock),
1907-
#ifdefWITH_RSOCKET
1908-
PG_ISRSOCKET(MyProcPort->sock),
1909-
#endif
1900+
MyProcPort->sock->fd,MyProcPort->sock->isRsocket,
19101901
sleeptime);
19111902
}
19121903
}

‎src/backend/storage/ipc/latch.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,7 @@ int
352352
WaitLatch(volatileLatch*latch,intwakeEvents,longtimeout)
353353
{
354354
returnWaitLatchOrSocket(latch,wakeEvents,PGINVALID_SOCKET,
355-
#if defined (WITH_RSOCKET)
356-
false,
357-
#endif
358-
timeout);
355+
false,timeout);
359356
}
360357

361358
/*
@@ -372,10 +369,7 @@ WaitLatch(volatile Latch *latch, int wakeEvents, long timeout)
372369
*/
373370
int
374371
WaitLatchOrSocket(volatileLatch*latch,intwakeEvents,pgsocketsock,
375-
#if defined (WITH_RSOCKET)
376-
boolisRsocket,
377-
#endif
378-
longtimeout)
372+
boolisRsocket,longtimeout)
379373
{
380374
intret=0;
381375
intrc;

‎src/backend/tcop/postgres.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3644,7 +3644,7 @@ RsocketInitialize(Port *port)
36443644
}
36453645

36463646
rsock=pg_socket(addr->ai_family,SOCK_STREAM,0, true);
3647-
if (PG_SOCK(rsock)==PGINVALID_SOCKET)
3647+
if (!PG_SOCKET_ISVALID(rsock))
36483648
{
36493649
pg_freeaddrinfo_all(hint.ai_family,addr);
36503650
ereport(FATAL,

‎src/include/pg_socket.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,8 @@ typedef PgSocketData *PgSocket;
7979
externPgSocketpg_socket(intdomain,inttype,intprotocol,boolisRsocket);
8080
externintpg_closesocket(PgSocketsocket);
8181

82-
#definePG_SOCK(socket) \
83-
(socket)->fd
84-
#definePG_ISRSOCKET(socket) \
85-
(socket)->isRsocket
82+
#definePG_SOCKET_ISVALID(socket) \
83+
((socket != NULL) && (socket)->fd != PGINVALID_SOCKET)
8684

8785
/*
8886
* Wrappers to function pointers of PgSocketData struct

‎src/include/storage/latch.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,7 @@ extern void ModifyWaitEvent(WaitEventSet *set, int pos, uint32 events, Latch *la
165165
externintWaitEventSetWait(WaitEventSet*set,longtimeout,WaitEvent*occurred_events,intnevents);
166166
externintWaitLatch(volatileLatch*latch,intwakeEvents,longtimeout);
167167
externintWaitLatchOrSocket(volatileLatch*latch,intwakeEvents,
168-
pgsocketsock,
169-
#if defined (WITH_RSOCKET)
170-
boolisRsocket,
171-
#endif
172-
longtimeout);
168+
pgsocketsock,boolisRsocket,longtimeout);
173169

174170
/*
175171
* Unix implementation uses SIGUSR1 for inter-process signaling.

‎src/interfaces/libpq/fe-connect.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,7 +2294,7 @@ PQconnectPoll(PGconn *conn)
22942294
}
22952295
}
22962296
/* Set noblock mode for rsocket connection after connect() */
2297-
if (!PG_ISRSOCKET(conn->sock)&&
2297+
if (!conn->sock->isRsocket&&
22982298
!pg_set_noblock_extended(conn->sock))
22992299
{
23002300
appendPQExpBuffer(&conn->errorMessage,
@@ -2306,7 +2306,7 @@ PQconnectPoll(PGconn *conn)
23062306
}
23072307

23082308
#ifdefF_SETFD
2309-
if (!PG_ISRSOCKET(conn->sock)&&
2309+
if (!conn->sock->isRsocket&&
23102310
pg_fcntl(conn->sock,F_SETFD,FD_CLOEXEC)==-1)
23112311
{
23122312
appendPQExpBuffer(&conn->errorMessage,
@@ -2436,7 +2436,7 @@ PQconnectPoll(PGconn *conn)
24362436
* Skip them if we got here after
24372437
* CONNECTION_RSOCKET_STARTUP step.
24382438
*/
2439-
if (PG_ISRSOCKET(conn->sock))
2439+
if (conn->sock->isRsocket)
24402440
{
24412441
/* Set nonblock mode for rsocket connection */
24422442
if (!pg_set_noblock_extended(conn->sock))
@@ -2579,7 +2579,7 @@ PQconnectPoll(PGconn *conn)
25792579
gid_tgid;
25802580

25812581
errno=0;
2582-
if (getpeereid(PG_SOCK(conn->sock),&uid,&gid)!=0)
2582+
if (getpeereid(conn->sock->fd,&uid,&gid)!=0)
25832583
{
25842584
/*
25852585
* Provide special error message if getpeereid is a
@@ -6573,7 +6573,7 @@ PQsocket(const PGconn *conn)
65736573
{
65746574
if (!conn)
65756575
return-1;
6576-
return (conn->sock!=NULL) ?PG_SOCK(conn->sock) :-1;
6576+
return (PG_SOCKET_ISVALID(conn->sock)) ?conn->sock->fd :-1;
65776577
}
65786578

65796579
int
@@ -6582,8 +6582,8 @@ PQisRsocket(const PGconn *conn)
65826582
#ifdefWITH_RSOCKET
65836583
if (!conn)
65846584
return (int) false;
6585-
return (int)((conn->sock!=NULL) ?
6586-
PG_ISRSOCKET(conn->sock) : false);
6585+
return (int)((PG_SOCKET_ISVALID(conn->sock)) ?
6586+
conn->sock->isRsocket : false);
65876587
#else
65886588
return (int) false;
65896589
#endif

‎src/interfaces/libpq/fe-misc.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ pqSocketPoll(PgSocket sock, int forRead, int forWrite, time_t end_time)
11101110
if (!forRead&& !forWrite)
11111111
return0;
11121112

1113-
input_fd.fd=PG_SOCK(sock);
1113+
input_fd.fd=sock->fd;
11141114
input_fd.events=POLLERR;
11151115
input_fd.revents=0;
11161116

@@ -1132,7 +1132,7 @@ pqSocketPoll(PgSocket sock, int forRead, int forWrite, time_t end_time)
11321132
timeout_ms=0;
11331133
}
11341134

1135-
returnpg_poll(&input_fd,1,timeout_ms,PG_ISRSOCKET(sock));
1135+
returnpg_poll(&input_fd,1,timeout_ms,sock->isRsocket);
11361136
#else/* !HAVE_POLL */
11371137

11381138
fd_setinput_mask;
@@ -1148,11 +1148,11 @@ pqSocketPoll(PgSocket sock, int forRead, int forWrite, time_t end_time)
11481148
FD_ZERO(&output_mask);
11491149
FD_ZERO(&except_mask);
11501150
if (forRead)
1151-
FD_SET(PG_SOCK(sock),&input_mask);
1151+
FD_SET(sock->fd,&input_mask);
11521152

11531153
if (forWrite)
1154-
FD_SET(PG_SOCK(sock),&output_mask);
1155-
FD_SET(PG_SOCK(sock),&except_mask);
1154+
FD_SET(sock->fd,&output_mask);
1155+
FD_SET(sock->fd,&except_mask);
11561156

11571157
/* Compute appropriate timeout interval */
11581158
if (end_time== ((time_t)-1))
@@ -1169,8 +1169,8 @@ pqSocketPoll(PgSocket sock, int forRead, int forWrite, time_t end_time)
11691169
ptr_timeout=&timeout;
11701170
}
11711171

1172-
returnpg_select(PG_SOCK(sock)+1,&input_mask,&output_mask,
1173-
&except_mask,ptr_timeout,PG_ISRSOCKET(sock));
1172+
returnpg_select(sock->fd+1,&input_mask,&output_mask,
1173+
&except_mask,ptr_timeout,sock->isRsocket);
11741174
#endif/* HAVE_POLL */
11751175
}
11761176

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp