|
Tomáš Mráz |
c9833c |
diff -up openssh-4.7p1/sftp-client.c.drain-acks openssh-4.7p1/sftp-client.c
|
|
Tomáš Mráz |
c9833c |
--- openssh-4.7p1/sftp-client.c.drain-acks 2007-02-19 12:13:39.000000000 +0100
|
|
Tomáš Mráz |
c9833c |
+++ openssh-4.7p1/sftp-client.c 2007-09-06 17:54:41.000000000 +0200
|
|
Tomáš Mráz |
f37073 |
@@ -992,7 +992,8 @@ int
|
|
Tomáš Mráz |
f37073 |
do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
|
|
Tomáš Mráz |
f37073 |
int pflag)
|
|
Tomáš Mráz |
f37073 |
{
|
|
Tomáš Mráz |
f37073 |
- int local_fd, status;
|
|
Tomáš Mráz |
f37073 |
+ int local_fd;
|
|
Tomáš Mráz |
f37073 |
+ int status = SSH2_FX_OK;
|
|
Tomáš Mráz |
f37073 |
u_int handle_len, id, type;
|
|
Tomáš Mráz |
f37073 |
u_int64_t offset;
|
|
Tomáš Mráz |
f37073 |
char *handle, *data;
|
|
Tomáš Mráz |
f37073 |
@@ -1074,7 +1075,7 @@ do_upload(struct sftp_conn *conn, char *
|
|
Tomáš Mráz |
f37073 |
* Simulate an EOF on interrupt, allowing ACKs from the
|
|
Tomáš Mráz |
f37073 |
* server to drain.
|
|
Tomáš Mráz |
f37073 |
*/
|
|
Tomáš Mráz |
f37073 |
- if (interrupted)
|
|
Tomáš Mráz |
f37073 |
+ if (interrupted || status != SSH2_FX_OK)
|
|
Tomáš Mráz |
f37073 |
len = 0;
|
|
Tomáš Mráz |
f37073 |
else do
|
|
Tomáš Mráz |
f37073 |
len = read(local_fd, data, conn->transfer_buflen);
|
|
Tomáš Mráz |
c9833c |
@@ -1131,18 +1132,6 @@ do_upload(struct sftp_conn *conn, char *
|
|
Tomáš Mráz |
f37073 |
fatal("Can't find request for ID %u", r_id);
|
|
Tomáš Mráz |
f37073 |
TAILQ_REMOVE(&acks, ack, tq);
|
|
Tomáš Mráz |
f37073 |
|
|
Tomáš Mráz |
f37073 |
- if (status != SSH2_FX_OK) {
|
|
Tomáš Mráz |
f37073 |
- error("Couldn't write to remote file \"%s\": %s",
|
|
Tomáš Mráz |
f37073 |
- remote_path, fx2txt(status));
|
|
Tomáš Mráz |
f37073 |
- if (showprogress)
|
|
Tomáš Mráz |
f37073 |
- stop_progress_meter();
|
|
Tomáš Mráz |
f37073 |
- do_close(conn, handle, handle_len);
|
|
Tomáš Mráz |
f37073 |
- close(local_fd);
|
|
Tomáš Mráz |
f37073 |
- xfree(data);
|
|
Tomáš Mráz |
f37073 |
- xfree(ack);
|
|
Tomáš Mráz |
c9833c |
- status = -1;
|
|
Tomáš Mráz |
f37073 |
- goto done;
|
|
Tomáš Mráz |
f37073 |
- }
|
|
Tomáš Mráz |
f37073 |
debug3("In write loop, ack for %u %u bytes at %llu",
|
|
Tomáš Mráz |
f37073 |
ack->id, ack->len, (unsigned long long)ack->offset);
|
|
Tomáš Mráz |
f37073 |
++ackid;
|
|
Tomáš Mráz |
c9833c |
@@ -1154,21 +1143,25 @@ do_upload(struct sftp_conn *conn, char *
|
|
Tomáš Mráz |
f37073 |
stop_progress_meter();
|
|
Tomáš Mráz |
f37073 |
xfree(data);
|
|
Tomáš Mráz |
f37073 |
|
|
Tomáš Mráz |
f37073 |
+ if (status != SSH2_FX_OK) {
|
|
Tomáš Mráz |
f37073 |
+ error("Couldn't write to remote file \"%s\": %s",
|
|
Tomáš Mráz |
f37073 |
+ remote_path, fx2txt(status));
|
|
Tomáš Mráz |
f37073 |
+ status = -1;
|
|
Tomáš Mráz |
f37073 |
+ }
|
|
Tomáš Mráz |
f37073 |
+
|
|
Tomáš Mráz |
f37073 |
if (close(local_fd) == -1) {
|
|
Tomáš Mráz |
f37073 |
error("Couldn't close local file \"%s\": %s", local_path,
|
|
Tomáš Mráz |
f37073 |
strerror(errno));
|
|
Tomáš Mráz |
f37073 |
- do_close(conn, handle, handle_len);
|
|
Tomáš Mráz |
f37073 |
status = -1;
|
|
Tomáš Mráz |
f37073 |
- goto done;
|
|
Tomáš Mráz |
f37073 |
}
|
|
Tomáš Mráz |
f37073 |
|
|
Tomáš Mráz |
f37073 |
/* Override umask and utimes if asked */
|
|
Tomáš Mráz |
f37073 |
if (pflag)
|
|
Tomáš Mráz |
f37073 |
do_fsetstat(conn, handle, handle_len, &a);
|
|
Tomáš Mráz |
f37073 |
|
|
Tomáš Mráz |
f37073 |
- status = do_close(conn, handle, handle_len);
|
|
Tomáš Mráz |
f37073 |
+ if (do_close(conn, handle, handle_len) != SSH2_FX_OK)
|
|
Tomáš Mráz |
f37073 |
+ status = -1;
|
|
Tomáš Mráz |
f37073 |
|
|
Tomáš Mráz |
f37073 |
-done:
|
|
Tomáš Mráz |
f37073 |
xfree(handle);
|
|
Tomáš Mráz |
f37073 |
buffer_free(&msg;;
|
|
Tomáš Mráz |
f37073 |
return(status);
|