mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-04 19:05:24 +00:00
remote: Consolidate remoteStream{Abort,Finish} functions
They do the same thing with only one difference. Let's put them together (like we already do with virFDStreamCloseInt) so that future changes don't miss one of the implementations. Also to clean up the code. Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
567f04808e
commit
8b151209ea
@ -5846,7 +5846,7 @@ remoteStreamEventRemoveCallback(virStreamPtr st)
|
||||
|
||||
|
||||
static int
|
||||
remoteStreamFinish(virStreamPtr st)
|
||||
remoteStreamCloseInt(virStreamPtr st, bool streamAbort)
|
||||
{
|
||||
struct private_data *priv = st->conn->privateData;
|
||||
virNetClientStreamPtr privst = st->privateData;
|
||||
@ -5862,7 +5862,7 @@ remoteStreamFinish(virStreamPtr st)
|
||||
|
||||
ret = virNetClientStreamSendPacket(privst,
|
||||
priv->client,
|
||||
VIR_NET_OK,
|
||||
streamAbort ? VIR_NET_ERROR : VIR_NET_OK,
|
||||
NULL,
|
||||
0);
|
||||
|
||||
@ -5880,38 +5880,17 @@ remoteStreamFinish(virStreamPtr st)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
remoteStreamFinish(virStreamPtr st)
|
||||
{
|
||||
return remoteStreamCloseInt(st, false);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
remoteStreamAbort(virStreamPtr st)
|
||||
{
|
||||
struct private_data *priv = st->conn->privateData;
|
||||
virNetClientStreamPtr privst = st->privateData;
|
||||
int ret = -1;
|
||||
|
||||
remoteDriverLock(priv);
|
||||
|
||||
if (virNetClientStreamRaiseError(privst))
|
||||
goto cleanup;
|
||||
|
||||
priv->localUses++;
|
||||
remoteDriverUnlock(priv);
|
||||
|
||||
ret = virNetClientStreamSendPacket(privst,
|
||||
priv->client,
|
||||
VIR_NET_ERROR,
|
||||
NULL,
|
||||
0);
|
||||
|
||||
remoteDriverLock(priv);
|
||||
priv->localUses--;
|
||||
|
||||
cleanup:
|
||||
virNetClientRemoveStream(priv->client, privst);
|
||||
virObjectUnref(privst);
|
||||
st->privateData = NULL;
|
||||
st->driver = NULL;
|
||||
|
||||
remoteDriverUnlock(priv);
|
||||
return ret;
|
||||
return remoteStreamCloseInt(st, true);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user