mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
client rpc: Report proper error for keepalive disconnections
Whenever a connection was closed due to keepalive timeout, we would log a warning but the interrupted API would return rather useless generic error: internal error: received hangup / error event on socket Let's report a proper keepalive timeout error and make sure it is propagated to all pending APIs. The error should be better now: internal error: connection closed due to keepalive timeout Based on an old patch from Martin Kletzander. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
363995b029
commit
c91776d5ff
@ -136,11 +136,11 @@ virKeepAliveTimerInternal(virKeepAlivePtr ka,
|
|||||||
ka, ka->client, ka->countToDeath, timeval);
|
ka, ka->client, ka->countToDeath, timeval);
|
||||||
|
|
||||||
if (ka->countToDeath == 0) {
|
if (ka->countToDeath == 0) {
|
||||||
VIR_WARN("No response from client %p after %d keepalive messages in"
|
VIR_DEBUG("No response from client %p after %d keepalive messages "
|
||||||
" %d seconds",
|
"in %d seconds",
|
||||||
ka->client,
|
ka->client, ka->count, timeval);
|
||||||
ka->count,
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
timeval);
|
_("connection closed due to keepalive timeout"));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
ka->countToDeath--;
|
ka->countToDeath--;
|
||||||
|
@ -107,6 +107,7 @@ struct _virNetClient {
|
|||||||
virKeepAlivePtr keepalive;
|
virKeepAlivePtr keepalive;
|
||||||
bool wantClose;
|
bool wantClose;
|
||||||
int closeReason;
|
int closeReason;
|
||||||
|
virErrorPtr error;
|
||||||
|
|
||||||
virNetClientCloseFunc closeCb;
|
virNetClientCloseFunc closeCb;
|
||||||
void *closeOpaque;
|
void *closeOpaque;
|
||||||
@ -636,10 +637,14 @@ virNetClientMarkClose(virNetClientPtr client,
|
|||||||
int reason)
|
int reason)
|
||||||
{
|
{
|
||||||
VIR_DEBUG("client=%p, reason=%d", client, reason);
|
VIR_DEBUG("client=%p, reason=%d", client, reason);
|
||||||
|
|
||||||
if (client->sock)
|
if (client->sock)
|
||||||
virNetSocketRemoveIOCallback(client->sock);
|
virNetSocketRemoveIOCallback(client->sock);
|
||||||
|
|
||||||
/* Don't override reason that's already set. */
|
/* Don't override reason that's already set. */
|
||||||
if (!client->wantClose) {
|
if (!client->wantClose) {
|
||||||
|
if (!client->error)
|
||||||
|
client->error = virSaveLastError();
|
||||||
client->wantClose = true;
|
client->wantClose = true;
|
||||||
client->closeReason = reason;
|
client->closeReason = reason;
|
||||||
}
|
}
|
||||||
@ -670,6 +675,9 @@ virNetClientCloseLocked(virNetClientPtr client)
|
|||||||
client->keepalive = NULL;
|
client->keepalive = NULL;
|
||||||
client->wantClose = false;
|
client->wantClose = false;
|
||||||
|
|
||||||
|
virFreeError(client->error);
|
||||||
|
client->error = NULL;
|
||||||
|
|
||||||
if (ka || client->closeCb) {
|
if (ka || client->closeCb) {
|
||||||
virNetClientCloseFunc closeCb = client->closeCb;
|
virNetClientCloseFunc closeCb = client->closeCb;
|
||||||
void *closeOpaque = client->closeOpaque;
|
void *closeOpaque = client->closeOpaque;
|
||||||
@ -1602,6 +1610,10 @@ static int virNetClientIOEventLoop(virNetClientPtr client,
|
|||||||
}
|
}
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
if (client->error) {
|
||||||
|
VIR_DEBUG("error on socket: %s", client->error->message);
|
||||||
|
virSetError(client->error);
|
||||||
|
}
|
||||||
virNetClientCallRemove(&client->waitDispatch, thiscall);
|
virNetClientCallRemove(&client->waitDispatch, thiscall);
|
||||||
virNetClientIOEventLoopPassTheBuck(client, thiscall);
|
virNetClientIOEventLoopPassTheBuck(client, thiscall);
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user