1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-06-13 16:01:32 +03:00

MCOL-529 Pool DBRM connections

DBRM connections are reused so that we don't have a huge amount of
TIME_WAIT sockets when there are large amounts of DML. Also applied to
i_s.columnstore_files
This commit is contained in:
Andrew Hutchings
2017-04-14 14:13:15 +01:00
parent 3e85b6ef07
commit 830b24c1fa
11 changed files with 349 additions and 56 deletions

View File

@ -70,6 +70,7 @@ either expressed or implied, of the FreeBSD Project.
#include <arpa/inet.h>
#include <netinet/tcp.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#endif
#include <sys/types.h>
#include <sys/time.h>
@ -1070,5 +1071,44 @@ int InetStreamSocket::ping(const std::string& ipaddr, const struct timespec* tim
return 0;
}
bool InetStreamSocket::isConnected() const
{
int error = 0;
socklen_t len = sizeof(error);
int retval = getsockopt(fSocketParms.sd(), SOL_SOCKET, SO_ERROR, &error, &len);
if (error || retval)
return false;
struct pollfd pfd[1];
pfd[0].fd = fSocketParms.sd();
pfd[0].events = POLLIN;
pfd[0].revents = 0;
error = poll(pfd, 1, 0);
if ((error < 0) || (pfd[0].revents & (POLLHUP | POLLNVAL | POLLERR))) {
return false;
}
return true;
}
bool InetStreamSocket::hasData() const
{
int count;
char buf[1];
ssize_t retval;
ioctl(fSocketParms.sd(), FIONREAD, &count);
if (count)
return true;
// EAGAIN | EWOULDBLOCK means the socket is clear. Anything else is data or error
retval = recv(fSocketParms.sd(), buf, 1, MSG_DONTWAIT);
if (retval & (EAGAIN | EWOULDBLOCK))
return false;
return true;
}
} //namespace messageqcpp