From 9f477073bca5ba9c12071c77bd198a84ab89f244 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 13 Apr 2011 10:30:30 +0200 Subject: [PATCH] sftp_write: flush the packetlist on error When an error occurs during write, flush the entire list of pending outgoing SFTP packets. --- src/sftp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sftp.c b/src/sftp.c index 82daa4b9..a3af6afe 100644 --- a/src/sftp.c +++ b/src/sftp.c @@ -1,6 +1,6 @@ /* Copyright (c) 2004-2008, Sara Golemon * Copyright (c) 2007 Eli Fant - * Copyright (c) 2009-2010 by Daniel Stenberg + * Copyright (c) 2009-2011 by Daniel Stenberg * All rights reserved. * * Redistribution and use in source and binary forms, @@ -1677,11 +1677,15 @@ static ssize_t sftp_write(LIBSSH2_SFTP_HANDLE *handle, const char *buffer, chunk = next; } - else + else { + /* flush all pending packets from the outgoing list */ + sftp_packetlist_flush(handle); + /* the server returned an error for that written chunk, propagate this back to our parent function */ return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL, "FXP write failed"); + } } /* if there were acked data in a previous call that wasn't returned then,