提交 e9c00cbc 编写于 作者: J Jiri Denemark 提交者: Cole Robinson

client rpc: Send keepalive requests from IO event loop

In addition to keepalive responses, we also need to send keepalive
requests from client IO loop to properly detect dead connection in case
a libvirt API is called from the main loop, which prevents any timers to
be called.
(cherry picked from commit 4d971dc7)
上级 f8e65111
...@@ -1272,6 +1272,7 @@ static int virNetClientIOEventLoop(virNetClientPtr client, ...@@ -1272,6 +1272,7 @@ static int virNetClientIOEventLoop(virNetClientPtr client,
char ignore; char ignore;
sigset_t oldmask, blockedsigs; sigset_t oldmask, blockedsigs;
int timeout = -1; int timeout = -1;
virNetMessagePtr msg = NULL;
/* If we have existing SASL decoded data we don't want to sleep in /* If we have existing SASL decoded data we don't want to sleep in
* the poll(), just check if any other FDs are also ready. * the poll(), just check if any other FDs are also ready.
...@@ -1285,6 +1286,10 @@ static int virNetClientIOEventLoop(virNetClientPtr client, ...@@ -1285,6 +1286,10 @@ static int virNetClientIOEventLoop(virNetClientPtr client,
if (thiscall->nonBlock) if (thiscall->nonBlock)
timeout = 0; timeout = 0;
/* Limit timeout so that we can send keepalive request in time */
if (timeout == -1)
timeout = virKeepAliveTimeout(client->keepalive);
fds[0].events = fds[0].revents = 0; fds[0].events = fds[0].revents = 0;
fds[1].events = fds[1].revents = 0; fds[1].events = fds[1].revents = 0;
...@@ -1330,6 +1335,13 @@ static int virNetClientIOEventLoop(virNetClientPtr client, ...@@ -1330,6 +1335,13 @@ static int virNetClientIOEventLoop(virNetClientPtr client,
virNetClientLock(client); virNetClientLock(client);
if (virKeepAliveTrigger(client->keepalive, &msg)) {
client->wantClose = true;
} else if (msg && virNetClientQueueNonBlocking(client, msg) < 0) {
VIR_WARN("Could not queue keepalive request");
virNetMessageFree(msg);
}
/* If we have existing SASL decoded data, pretend /* If we have existing SASL decoded data, pretend
* the socket became readable so we consume it * the socket became readable so we consume it
*/ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册