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

Commit38edca7

Browse files
committed
Fix forgot select() uses. Use rselect().
1 parent3ffc181 commit38edca7

File tree

5 files changed

+23
-24
lines changed

5 files changed

+23
-24
lines changed

‎src/bin/pg_basebackup/pg_recvlogical.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@
1515
#include<dirent.h>
1616
#include<sys/stat.h>
1717
#include<unistd.h>
18-
#ifdefHAVE_SYS_SELECT_H
19-
#include<sys/select.h>
20-
#endif
2118

2219
/* local includes */
20+
#include"pg_socket.h"
2321
#include"streamutil.h"
2422

2523
#include"access/xlog_internal.h"
@@ -408,7 +406,8 @@ StreamLogicalLog(void)
408406
timeoutptr=&timeout;
409407
}
410408

411-
r=select(PQsocket(conn)+1,&input_mask,NULL,NULL,timeoutptr);
409+
r=pg_select(PQsocket(conn)+1,&input_mask,NULL,NULL,timeoutptr,
410+
PQisRsocket(conn));
412411
if (r==0|| (r<0&&errno==EINTR))
413412
{
414413
/*

‎src/bin/pg_basebackup/receivelog.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616

1717
#include<sys/stat.h>
1818
#include<unistd.h>
19-
#ifdefHAVE_SYS_SELECT_H
20-
#include<sys/select.h>
21-
#endif
2219

2320
/* local includes */
21+
#include"pg_socket.h"
2422
#include"receivelog.h"
2523
#include"streamutil.h"
2624

@@ -952,7 +950,8 @@ CopyStreamPoll(PGconn *conn, long timeout_ms)
952950
timeoutptr=&timeout;
953951
}
954952

955-
ret=select(PQsocket(conn)+1,&input_mask,NULL,NULL,timeoutptr);
953+
ret=pg_select(PQsocket(conn)+1,&input_mask,NULL,NULL,timeoutptr,
954+
PQisRsocket(conn));
956955
if (ret==0|| (ret<0&&errno==EINTR))
957956
return0;/* Got a timeout or signal */
958957
elseif (ret<0)

‎src/bin/scripts/vacuumdb.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@
1212

1313
#include"postgres_fe.h"
1414

15-
#ifdefHAVE_SYS_SELECT_H
16-
#include<sys/select.h>
17-
#endif
18-
1915
#include"common.h"
2016
#include"fe_utils/simple_list.h"
2117
#include"fe_utils/string_utils.h"
18+
#include"pg_socket.h"
2219

2320

2421
#defineERRCODE_UNDEFINED_TABLE "42P01"
@@ -71,7 +68,8 @@ static bool GetQueryResult(PGconn *conn, const char *progname);
7168

7269
staticvoidDisconnectDatabase(ParallelSlot*slot);
7370

74-
staticintselect_loop(intmaxFd,fd_set*workerset,bool*aborting);
71+
staticintselect_loop(intmaxFd,fd_set*workerset,bool*aborting,
72+
boolisRsocket);
7573

7674
staticvoidinit_slot(ParallelSlot*slot,PGconn*conn,constchar*progname);
7775

@@ -736,6 +734,7 @@ GetIdleSlot(ParallelSlot slots[], int numslots,
736734
intfirstFree=-1;
737735
fd_setslotset;
738736
pgsocketmaxFd;
737+
boolisRsocket= false;
739738

740739
for (i=0;i<numslots;i++)
741740
if ((slots+i)->isFree)
@@ -749,6 +748,10 @@ GetIdleSlot(ParallelSlot slots[], int numslots,
749748
FD_SET((slots+i)->sock,&slotset);
750749
if ((slots+i)->sock>maxFd)
751750
maxFd= (slots+i)->sock;
751+
#ifdefWITH_RSOCKET
752+
if (PQisRsocket((slots+i)->connection))
753+
isRsocket= true;
754+
#endif
752755
}
753756

754757
/*
@@ -760,7 +763,7 @@ GetIdleSlot(ParallelSlot slots[], int numslots,
760763
boolaborting;
761764

762765
SetCancelConn(slots->connection);
763-
i=select_loop(maxFd,&slotset,&aborting);
766+
i=select_loop(maxFd,&slotset,&aborting,isRsocket);
764767
ResetCancelConn();
765768

766769
if (aborting)
@@ -871,7 +874,7 @@ DisconnectDatabase(ParallelSlot *slot)
871874
* ignored in this case. Otherwise, *aborting is set to false.
872875
*/
873876
staticint
874-
select_loop(intmaxFd,fd_set*workerset,bool*aborting)
877+
select_loop(intmaxFd,fd_set*workerset,bool*aborting,boolisRsocket)
875878
{
876879
inti;
877880
fd_setsaveSet=*workerset;
@@ -900,7 +903,7 @@ select_loop(int maxFd, fd_set *workerset, bool *aborting)
900903
#endif
901904

902905
*workerset=saveSet;
903-
i=select(maxFd+1,workerset,NULL,NULL,tvp);
906+
i=pg_select(maxFd+1,workerset,NULL,NULL,tvp,isRsocket);
904907

905908
#ifdefWIN32
906909
if (i==SOCKET_ERROR)

‎src/test/examples/testlibpq2.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,9 @@
3434
#include<errno.h>
3535
#include<sys/time.h>
3636
#include<sys/types.h>
37-
#ifdefHAVE_SYS_SELECT_H
38-
#include<sys/select.h>
39-
#endif
4037

4138
#include"libpq-fe.h"
39+
#include"pg_socket.h"
4240

4341
staticvoid
4442
exit_nicely(PGconn*conn)
@@ -114,7 +112,8 @@ main(int argc, char **argv)
114112
FD_ZERO(&input_mask);
115113
FD_SET(sock,&input_mask);
116114

117-
if (select(sock+1,&input_mask,NULL,NULL,NULL)<0)
115+
if (pg_select(sock+1,&input_mask,NULL,NULL,NULL,
116+
PQisRsocket(conn))<0)
118117
{
119118
fprintf(stderr,"select() failed: %s\n",strerror(errno));
120119
exit_nicely(conn);

‎src/test/isolation/isolationtester.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@
1111
#include<windows.h>
1212
#endif
1313
#include<sys/time.h>
14-
#ifdefHAVE_SYS_SELECT_H
15-
#include<sys/select.h>
16-
#endif
1714

1815
#include"datatype/timestamp.h"
1916
#include"libpq-fe.h"
2017
#include"pqexpbuffer.h"
2118
#include"pg_getopt.h"
19+
#include"pg_socket.h"
2220

2321
#include"isolationtester.h"
2422

@@ -720,7 +718,8 @@ try_complete_step(Step *step, int flags)
720718
timeout.tv_sec=0;
721719
timeout.tv_usec=10000;/* Check for lock waits every 10ms. */
722720

723-
ret=select(sock+1,&read_set,NULL,NULL,&timeout);
721+
ret=pg_select(sock+1,&read_set,NULL,NULL,&timeout,
722+
PQisRsocket(conn));
724723
if (ret<0)/* error in select() */
725724
{
726725
if (errno==EINTR)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp