mirror of https://gitee.com/bigwinds/arangodb
create timeout before the actual call
This commit is contained in:
parent
7933fe5d4b
commit
1e7d970a8d
|
@ -228,12 +228,10 @@ bool ClientConnection::prepare (double timeout, bool isWrite) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct timeval tv;
|
|
||||||
tv.tv_sec = (long) timeout;
|
|
||||||
tv.tv_usec = (long) ((timeout - (double) tv.tv_sec) * 1000000.0);
|
|
||||||
|
|
||||||
fd_set fdset;
|
fd_set fdset;
|
||||||
do {
|
|
||||||
|
// handle interrupt
|
||||||
|
do {
|
||||||
FD_ZERO(&fdset);
|
FD_ZERO(&fdset);
|
||||||
FD_SET(fd, &fdset);
|
FD_SET(fd, &fdset);
|
||||||
|
|
||||||
|
@ -248,15 +246,19 @@ bool ClientConnection::prepare (double timeout, bool isWrite) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
int sockn = (int) (fd + 1);
|
int sockn = (int) (fd + 1);
|
||||||
res = select(sockn, readFds, writeFds, nullptr, &tv);
|
|
||||||
|
struct timeval t;
|
||||||
|
t.tv_sec = (long) timeout;
|
||||||
|
t.tv_usec = (long) ((timeout - TV_SEC) * 1000000.0);
|
||||||
|
|
||||||
|
res = select(sockn, readFds, writeFds, nullptr, &t);
|
||||||
|
|
||||||
if ((res == -1 && errno == EINTR)) {
|
if ((res == -1 && errno == EINTR)) {
|
||||||
int myerrno = errno;
|
int myerrno = errno;
|
||||||
double end = TRI_microtime();
|
double end = TRI_microtime();
|
||||||
errno = myerrno;
|
errno = myerrno;
|
||||||
timeout = timeout - (end - start);
|
timeout = timeout - (end - start);
|
||||||
start = end;
|
start = end;
|
||||||
tv.tv_sec = (long) timeout;
|
|
||||||
tv.tv_usec = (long) ((timeout - (double) tv.tv_sec) * 1000000.0);
|
|
||||||
}
|
}
|
||||||
} while (res == -1 && errno == EINTR && timeout > 0.0);
|
} while (res == -1 && errno == EINTR && timeout > 0.0);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -322,12 +322,10 @@ bool SslClientConnection::prepare (double timeout, bool isWrite) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct timeval tv;
|
|
||||||
tv.tv_sec = (long) timeout;
|
|
||||||
tv.tv_usec = (long) ((timeout - (double) tv.tv_sec) * 1000000.0);
|
|
||||||
|
|
||||||
fd_set fdset;
|
fd_set fdset;
|
||||||
do {
|
|
||||||
|
// handle interrupt
|
||||||
|
do {
|
||||||
|
|
||||||
FD_ZERO(&fdset);
|
FD_ZERO(&fdset);
|
||||||
FD_SET(fd, &fdset);
|
FD_SET(fd, &fdset);
|
||||||
|
@ -343,7 +341,12 @@ bool SslClientConnection::prepare (double timeout, bool isWrite) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
int sockn = (int) (fd + 1);
|
int sockn = (int) (fd + 1);
|
||||||
res = select(sockn, readFds, writeFds, nullptr, &tv);
|
|
||||||
|
struct timeval t;
|
||||||
|
t.tv_sec = (long) timeout;
|
||||||
|
t.tv_usec = (long) ((timeout - TV_SEC) * 1000000.0);
|
||||||
|
|
||||||
|
res = select(sockn, readFds, writeFds, nullptr, &t);
|
||||||
|
|
||||||
if ((res == -1 && errno == EINTR)) {
|
if ((res == -1 && errno == EINTR)) {
|
||||||
int myerrno = errno;
|
int myerrno = errno;
|
||||||
|
@ -351,8 +354,6 @@ bool SslClientConnection::prepare (double timeout, bool isWrite) const {
|
||||||
errno = myerrno;
|
errno = myerrno;
|
||||||
timeout = timeout - (end - start);
|
timeout = timeout - (end - start);
|
||||||
start = end;
|
start = end;
|
||||||
tv.tv_sec = (long) timeout;
|
|
||||||
tv.tv_usec = (long) ((timeout - (double) tv.tv_sec) * 1000000.0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ((res == -1) && (errno == EINTR) && (timeout > 0.0));
|
while ((res == -1) && (errno == EINTR) && (timeout > 0.0));
|
||||||
|
|
Loading…
Reference in New Issue