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@xxxxxxxxxx> --- src/remote/remote_driver.c | 39 +++++++++------------------------------ 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 968fdfba191c..49909bf69747 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -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); @@ -5881,37 +5881,16 @@ remoteStreamFinish(virStreamPtr st) static int -remoteStreamAbort(virStreamPtr st) +remoteStreamFinish(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--; + return remoteStreamCloseInt(st, false); +} - cleanup: - virNetClientRemoveStream(priv->client, privst); - virObjectUnref(privst); - st->privateData = NULL; - st->driver = NULL; - remoteDriverUnlock(priv); - return ret; +static int +remoteStreamAbort(virStreamPtr st) +{ + return remoteStreamCloseInt(st, true); } -- 2.13.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list