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

Commit6efe182

Browse files
committed
Do not use PGINVALID_SOCKET_EXTENDED, use only PgSocketData
1 parentf7741da commit6efe182

File tree

13 files changed

+98
-178
lines changed

13 files changed

+98
-178
lines changed

‎configure

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,6 @@ with_perl
722722
with_tcl
723723
enable_thread_safety
724724
INCLUDES
725-
with_rsocket
726725
autodepend
727726
TAS
728727
GCC

‎configure.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,6 @@ PGAC_ARG_BOOL(with, rsocket, no, [replace socket with rsocket (RDMA socket API)]
582582
[AC_DEFINE([WITH_RSOCKET], 1,
583583
[Define to 1 to build with rsocket instead socket. (--with-rsocket)])])
584584
AC_MSG_RESULT([$with_rsocket])
585-
AC_SUBST(with_rsocket)
586585

587586
#
588587
# Include directories

‎src/Makefile.global.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ with_uuid= @with_uuid@
206206
with_zlib= @with_zlib@
207207
with_zstd = @with_zstd@
208208
with_icu= @with_icu@
209-
with_rsocket= @with_rsocket@
210209
enable_rpath= @enable_rpath@
211210
enable_nls= @enable_nls@
212211
enable_debug= @enable_debug@

‎src/backend/libpq/pqcomm.c

Lines changed: 47 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -197,18 +197,18 @@ pq_init(void)
197197
* infinite recursion.
198198
*/
199199
#ifndefWIN32
200-
if (!pg_set_noblock(MyProcPort->sock,MyProcPort->isRsocket))
200+
if (!pg_set_noblock_extended(MyProcPort->sock))
201201
ereport(COMMERROR,
202202
(errmsg("could not set socket to nonblocking mode: %m")));
203203
#endif
204204

205205
#ifdefWITH_RSOCKET
206-
if (MyProcPort->isRsocket)
206+
if (PG_ISRSOCKET(MyProcPort->sock))
207207
FeBeWaitSet=CreateWaitEventSetForRsocket(TopMemoryContext,3);
208208
else
209209
#endif
210210
FeBeWaitSet=CreateWaitEventSet(TopMemoryContext,3);
211-
AddWaitEventToSet(FeBeWaitSet,WL_SOCKET_WRITEABLE,MyProcPort->sock,
211+
AddWaitEventToSet(FeBeWaitSet,WL_SOCKET_WRITEABLE,PG_SOCK(MyProcPort->sock),
212212
NULL,NULL);
213213
AddWaitEventToSet(FeBeWaitSet,WL_LATCH_SET,-1,MyLatch,NULL);
214214
AddWaitEventToSet(FeBeWaitSet,WL_POSTMASTER_DEATH,-1,NULL,NULL);
@@ -235,18 +235,18 @@ pq_reinit(void)
235235
* infinite recursion.
236236
*/
237237
#ifndefWIN32
238-
if (!pg_set_noblock(MyProcPort->sock,MyProcPort->isRsocket))
238+
if (!pg_set_noblock_extended(MyProcPort->sock))
239239
ereport(COMMERROR,
240240
(errmsg("could not set socket to nonblocking mode: %m")));
241241
#endif
242242

243243
#ifdefWITH_RSOCKET
244-
if (MyProcPort->isRsocket)
244+
if (PG_ISRSOCKET(MyProcPort->sock))
245245
FeBeWaitSet=CreateWaitEventSetForRsocket(TopMemoryContext,3);
246246
else
247247
#endif
248248
FeBeWaitSet=CreateWaitEventSet(TopMemoryContext,3);
249-
AddWaitEventToSet(FeBeWaitSet,WL_SOCKET_WRITEABLE,MyProcPort->sock,
249+
AddWaitEventToSet(FeBeWaitSet,WL_SOCKET_WRITEABLE,PG_SOCK(MyProcPort->sock),
250250
NULL,NULL);
251251
AddWaitEventToSet(FeBeWaitSet,WL_LATCH_SET,-1,MyLatch,NULL);
252252
AddWaitEventToSet(FeBeWaitSet,WL_POSTMASTER_DEATH,-1,NULL,NULL);
@@ -323,8 +323,9 @@ socket_close(int code, Datum arg)
323323
* We do set sock to PGINVALID_SOCKET to prevent any further I/O,
324324
* though.
325325
*/
326-
MyProcPort->sock=PGINVALID_SOCKET;
327-
MyProcPort->isRsocket= false;
326+
Assert(MyProcPort->sock);
327+
free(MyProcPort->sock);
328+
MyProcPort->sock=NULL;
328329
}
329330
}
330331

@@ -477,7 +478,7 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber,
477478
break;
478479
}
479480

480-
if ((fd=pg_socket(addr->ai_family,SOCK_STREAM,0, false))
481+
if ((fd=socket(addr->ai_family,SOCK_STREAM,0))
481482
==PGINVALID_SOCKET)
482483
{
483484
ereport(LOG,
@@ -503,13 +504,13 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber,
503504
*/
504505
if (!IS_AF_UNIX(addr->ai_family))
505506
{
506-
if ((pg_setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,
507-
(char*)&one,sizeof(one), false))==-1)
507+
if ((setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,
508+
(char*)&one,sizeof(one)))==-1)
508509
{
509510
ereport(LOG,
510511
(errcode_for_socket_access(),
511512
errmsg("setsockopt(SO_REUSEADDR) failed: %m")));
512-
pg_closesocket(fd, false);
513+
closesocket(fd);
513514
continue;
514515
}
515516
}
@@ -518,13 +519,13 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber,
518519
#ifdefIPV6_V6ONLY
519520
if (addr->ai_family==AF_INET6)
520521
{
521-
if (pg_setsockopt(fd,IPPROTO_IPV6,IPV6_V6ONLY,
522-
(char*)&one,sizeof(one), false)==-1)
522+
if (setsockopt(fd,IPPROTO_IPV6,IPV6_V6ONLY,
523+
(char*)&one,sizeof(one))==-1)
523524
{
524525
ereport(LOG,
525526
(errcode_for_socket_access(),
526527
errmsg("setsockopt(IPV6_V6ONLY) failed: %m")));
527-
pg_closesocket(fd, false);
528+
closesocket(fd);
528529
continue;
529530
}
530531
}
@@ -536,7 +537,7 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber,
536537
* ipv4 addresses to ipv6. It will show ::ffff:ipv4 for all ipv4
537538
* connections.
538539
*/
539-
err=pg_bind(fd,addr->ai_addr,addr->ai_addrlen, false);
540+
err=bind(fd,addr->ai_addr,addr->ai_addrlen);
540541
if (err<0)
541542
{
542543
ereport(LOG,
@@ -551,7 +552,7 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber,
551552
errhint("Is another postmaster already running on port %d?"
552553
" If not, wait a few seconds and retry.",
553554
(int)portNumber)));
554-
pg_closesocket(fd, false);
555+
closesocket(fd);
555556
continue;
556557
}
557558

@@ -560,7 +561,7 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber,
560561
{
561562
if (Setup_AF_UNIX(service)!=STATUS_OK)
562563
{
563-
pg_closesocket(fd, false);
564+
closesocket(fd);
564565
break;
565566
}
566567
}
@@ -575,15 +576,15 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber,
575576
if (maxconn>PG_SOMAXCONN)
576577
maxconn=PG_SOMAXCONN;
577578

578-
err=pg_listen(fd,maxconn, false);
579+
err=listen(fd,maxconn);
579580
if (err<0)
580581
{
581582
ereport(LOG,
582583
(errcode_for_socket_access(),
583584
/* translator: %s is IPv4, IPv6, or Unix */
584585
errmsg("could not listen on %s socket: %m",
585586
familyDesc)));
586-
pg_closesocket(fd, false);
587+
closesocket(fd);
587588
continue;
588589
}
589590
ListenSocket[listen_index]=fd;
@@ -711,11 +712,13 @@ Setup_AF_UNIX(char *sock_path)
711712
int
712713
StreamConnection(pgsocketserver_fd,Port*port)
713714
{
715+
pgsocketfd;
716+
714717
/* accept connection and fill in the client (remote) address */
715718
port->raddr.salen=sizeof(port->raddr.addr);
716-
if ((port->sock=pg_accept(server_fd,
717-
(structsockaddr*)&port->raddr.addr,
718-
&port->raddr.salen,port->isRsocket))==PGINVALID_SOCKET)
719+
if ((fd=accept(server_fd,
720+
(structsockaddr*)&port->raddr.addr,
721+
&port->raddr.salen))==PGINVALID_SOCKET)
719722
{
720723
ereport(LOG,
721724
(errcode_for_socket_access(),
@@ -732,6 +735,9 @@ StreamConnection(pgsocket server_fd, Port *port)
732735
returnSTATUS_ERROR;
733736
}
734737

738+
port->sock=initialize_socket();
739+
port->sock->fd=fd;
740+
735741
#ifdefSCO_ACCEPT_BUG
736742

737743
/*
@@ -746,7 +752,7 @@ StreamConnection(pgsocket server_fd, Port *port)
746752
port->laddr.salen=sizeof(port->laddr.addr);
747753
if (pg_getsockname(port->sock,
748754
(structsockaddr*)&port->laddr.addr,
749-
&port->laddr.salen,port->isRsocket)<0)
755+
&port->laddr.salen)<0)
750756
{
751757
elog(LOG,"getsockname() failed: %m");
752758
returnSTATUS_ERROR;
@@ -765,15 +771,15 @@ StreamConnection(pgsocket server_fd, Port *port)
765771
#ifdefTCP_NODELAY
766772
on=1;
767773
if (pg_setsockopt(port->sock,IPPROTO_TCP,TCP_NODELAY,
768-
(char*)&on,sizeof(on),port->isRsocket)<0)
774+
(char*)&on,sizeof(on))<0)
769775
{
770776
elog(LOG,"setsockopt(TCP_NODELAY) failed: %m");
771777
returnSTATUS_ERROR;
772778
}
773779
#endif
774780
on=1;
775781
if (pg_setsockopt(port->sock,SOL_SOCKET,SO_KEEPALIVE,
776-
(char*)&on,sizeof(on),port->isRsocket)<0)
782+
(char*)&on,sizeof(on))<0)
777783
{
778784
elog(LOG,"setsockopt(SO_KEEPALIVE) failed: %m");
779785
returnSTATUS_ERROR;
@@ -803,17 +809,17 @@ StreamConnection(pgsocket server_fd, Port *port)
803809
* https://msdn.microsoft.com/en-us/library/bb736549%28v=vs.85%29.aspx
804810
*/
805811
optlen=sizeof(oldopt);
806-
if (pg_getsockopt(port->sock,SOL_SOCKET,SO_SNDBUF, (char*)&oldopt,
807-
&optlen,port->isRsocket)<0)
812+
if (pg_getsockopt(port->sock,SOL_SOCKET,SO_SNDBUF,
813+
(char*)&oldopt,&optlen)<0)
808814
{
809815
elog(LOG,"getsockopt(SO_SNDBUF) failed: %m");
810816
returnSTATUS_ERROR;
811817
}
812818
newopt=PQ_SEND_BUFFER_SIZE*4;
813819
if (oldopt<newopt)
814820
{
815-
if (pg_setsockopt(port->sock,SOL_SOCKET,SO_SNDBUF, (char*)&newopt,
816-
sizeof(newopt),port->isRsocket)<0)
821+
if (pg_setsockopt(port->sock,SOL_SOCKET,SO_SNDBUF,
822+
(char*)&newopt,sizeof(newopt))<0)
817823
{
818824
elog(LOG,"setsockopt(SO_SNDBUF) failed: %m");
819825
returnSTATUS_ERROR;
@@ -847,9 +853,9 @@ StreamConnection(pgsocket server_fd, Port *port)
847853
* we do NOT want to send anything to the far end.
848854
*/
849855
void
850-
StreamClose(pgsocketsock,boolisRsocket)
856+
StreamClose(pgsocketsock)
851857
{
852-
pg_closesocket(sock,isRsocket);
858+
closesocket(sock);
853859
}
854860

855861
/*
@@ -1675,7 +1681,7 @@ pq_setkeepaliveswin32(Port *port, int idle, int interval)
16751681
ka.keepalivetime=idle*1000;
16761682
ka.keepaliveinterval=interval*1000;
16771683

1678-
if (WSAIoctl(port->sock,
1684+
if (WSAIoctl(port->sock->fd,
16791685
SIO_KEEPALIVE_VALS,
16801686
(LPVOID)&ka,
16811687
sizeof(ka),
@@ -1716,15 +1722,15 @@ pq_getkeepalivesidle(Port *port)
17161722
#ifdefTCP_KEEPIDLE
17171723
if (pg_getsockopt(port->sock,IPPROTO_TCP,TCP_KEEPIDLE,
17181724
(char*)&port->default_keepalives_idle,
1719-
&size,port->isRsocket)<0)
1725+
&size)<0)
17201726
{
17211727
elog(LOG,"getsockopt(TCP_KEEPIDLE) failed: %m");
17221728
port->default_keepalives_idle=-1;/* don't know */
17231729
}
17241730
#else
17251731
if (pg_getsockopt(port->sock,IPPROTO_TCP,TCP_KEEPALIVE,
17261732
(char*)&port->default_keepalives_idle,
1727-
&size,port->isRsocket)<0)
1733+
&size)<0)
17281734
{
17291735
elog(LOG,"getsockopt(TCP_KEEPALIVE) failed: %m");
17301736
port->default_keepalives_idle=-1;/* don't know */
@@ -1769,14 +1775,14 @@ pq_setkeepalivesidle(int idle, Port *port)
17691775

17701776
#ifdefTCP_KEEPIDLE
17711777
if (pg_setsockopt(port->sock,IPPROTO_TCP,TCP_KEEPIDLE,
1772-
(char*)&idle,sizeof(idle),port->isRsocket)<0)
1778+
(char*)&idle,sizeof(idle))<0)
17731779
{
17741780
elog(LOG,"setsockopt(TCP_KEEPIDLE) failed: %m");
17751781
returnSTATUS_ERROR;
17761782
}
17771783
#else
17781784
if (pg_setsockopt(port->sock,IPPROTO_TCP,TCP_KEEPALIVE,
1779-
(char*)&idle,sizeof(idle),port->isRsocket)<0)
1785+
(char*)&idle,sizeof(idle))<0)
17801786
{
17811787
elog(LOG,"setsockopt(TCP_KEEPALIVE) failed: %m");
17821788
returnSTATUS_ERROR;
@@ -1814,7 +1820,7 @@ pq_getkeepalivesinterval(Port *port)
18141820

18151821
if (pg_getsockopt(port->sock,IPPROTO_TCP,TCP_KEEPINTVL,
18161822
(char*)&port->default_keepalives_interval,
1817-
&size,port->isRsocket)<0)
1823+
&size)<0)
18181824
{
18191825
elog(LOG,"getsockopt(TCP_KEEPINTVL) failed: %m");
18201826
port->default_keepalives_interval=-1;/* don't know */
@@ -1857,7 +1863,7 @@ pq_setkeepalivesinterval(int interval, Port *port)
18571863
interval=port->default_keepalives_interval;
18581864

18591865
if (pg_setsockopt(port->sock,IPPROTO_TCP,TCP_KEEPINTVL,
1860-
(char*)&interval,sizeof(interval),port->isRsocket)<0)
1866+
(char*)&interval,sizeof(interval))<0)
18611867
{
18621868
elog(LOG,"setsockopt(TCP_KEEPINTVL) failed: %m");
18631869
returnSTATUS_ERROR;
@@ -1894,7 +1900,7 @@ pq_getkeepalivescount(Port *port)
18941900

18951901
if (pg_getsockopt(port->sock,IPPROTO_TCP,TCP_KEEPCNT,
18961902
(char*)&port->default_keepalives_count,
1897-
&size,port->isRsocket)<0)
1903+
&size)<0)
18981904
{
18991905
elog(LOG,"getsockopt(TCP_KEEPCNT) failed: %m");
19001906
port->default_keepalives_count=-1;/* don't know */
@@ -1932,7 +1938,7 @@ pq_setkeepalivescount(int count, Port *port)
19321938
count=port->default_keepalives_count;
19331939

19341940
if (pg_setsockopt(port->sock,IPPROTO_TCP,TCP_KEEPCNT,
1935-
(char*)&count,sizeof(count),port->isRsocket)<0)
1941+
(char*)&count,sizeof(count))<0)
19361942
{
19371943
elog(LOG,"setsockopt(TCP_KEEPCNT) failed: %m");
19381944
returnSTATUS_ERROR;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp