mirror of https://github.com/citusdata/citus.git
Remove fall back to select if poll is not available (#1466)
poll is supported on all relevant systems, there is no need to have a fall back mechanism to use select()pull/1465/merge
parent
294aeff2ed
commit
0c4bf2d943
|
@ -10,9 +10,7 @@
|
||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#ifdef HAVE_POLL_H
|
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "libpq-fe.h"
|
#include "libpq-fe.h"
|
||||||
|
|
||||||
|
|
|
@ -27,15 +27,10 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#ifdef HAVE_POLL_H
|
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_POLL_H
|
#ifdef HAVE_SYS_POLL_H
|
||||||
#include <sys/poll.h>
|
#include <sys/poll.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_SYS_SELECT_H
|
|
||||||
#include <sys/select.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* Local pool to track active connections */
|
/* Local pool to track active connections */
|
||||||
|
@ -886,9 +881,6 @@ ClientConnectionReady(MultiConnection *connection,
|
||||||
{
|
{
|
||||||
bool clientConnectionReady = false;
|
bool clientConnectionReady = false;
|
||||||
int pollResult = 0;
|
int pollResult = 0;
|
||||||
|
|
||||||
/* we use poll(2) if available, otherwise select(2) */
|
|
||||||
#ifdef HAVE_POLL
|
|
||||||
int fileDescriptorCount = 1;
|
int fileDescriptorCount = 1;
|
||||||
int immediateTimeout = 0;
|
int immediateTimeout = 0;
|
||||||
int pollEventMask = 0;
|
int pollEventMask = 0;
|
||||||
|
@ -908,33 +900,6 @@ ClientConnectionReady(MultiConnection *connection,
|
||||||
pollFileDescriptor.revents = 0;
|
pollFileDescriptor.revents = 0;
|
||||||
|
|
||||||
pollResult = poll(&pollFileDescriptor, fileDescriptorCount, immediateTimeout);
|
pollResult = poll(&pollFileDescriptor, fileDescriptorCount, immediateTimeout);
|
||||||
#else /* !HAVE_POLL */
|
|
||||||
|
|
||||||
fd_set readFileDescriptorSet;
|
|
||||||
fd_set writeFileDescriptorSet;
|
|
||||||
fd_set exceptionFileDescriptorSet;
|
|
||||||
struct timeval immediateTimeout = { 0, 0 };
|
|
||||||
int connectionFileDescriptor = PQsocket(connection);
|
|
||||||
|
|
||||||
FD_ZERO(&readFileDescriptorSet);
|
|
||||||
FD_ZERO(&writeFileDescriptorSet);
|
|
||||||
FD_ZERO(&exceptionFileDescriptorSet);
|
|
||||||
|
|
||||||
if (pollingStatus == PGRES_POLLING_READING)
|
|
||||||
{
|
|
||||||
FD_SET(connectionFileDescriptor, &exceptionFileDescriptorSet);
|
|
||||||
FD_SET(connectionFileDescriptor, &readFileDescriptorSet);
|
|
||||||
}
|
|
||||||
else if (pollingStatus == PGRES_POLLING_WRITING)
|
|
||||||
{
|
|
||||||
FD_SET(connectionFileDescriptor, &exceptionFileDescriptorSet);
|
|
||||||
FD_SET(connectionFileDescriptor, &writeFileDescriptorSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
pollResult = select(connectionFileDescriptor + 1, &readFileDescriptorSet,
|
|
||||||
&writeFileDescriptorSet, &exceptionFileDescriptorSet,
|
|
||||||
&immediateTimeout);
|
|
||||||
#endif /* HAVE_POLL */
|
|
||||||
|
|
||||||
if (pollResult > 0)
|
if (pollResult > 0)
|
||||||
{
|
{
|
||||||
|
@ -957,7 +922,7 @@ ClientConnectionReady(MultiConnection *connection,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* poll() or select() can set errno to EFAULT (when socket is not
|
* poll() can set errno to EFAULT (when socket is not
|
||||||
* contained in the calling program's address space), EBADF (invalid
|
* contained in the calling program's address space), EBADF (invalid
|
||||||
* file descriptor), EINVAL (invalid arguments to select or poll),
|
* file descriptor), EINVAL (invalid arguments to select or poll),
|
||||||
* and ENOMEM (no space to allocate file descriptor tables). Out of
|
* and ENOMEM (no space to allocate file descriptor tables). Out of
|
||||||
|
@ -966,7 +931,7 @@ ClientConnectionReady(MultiConnection *connection,
|
||||||
*/
|
*/
|
||||||
Assert(errno == ENOMEM);
|
Assert(errno == ENOMEM);
|
||||||
ereport(ERROR, (errcode_for_socket_access(),
|
ereport(ERROR, (errcode_for_socket_access(),
|
||||||
errmsg("select()/poll() failed: %m")));
|
errmsg("poll() failed: %m")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue