]> andersk Git - openssh.git/blobdiff - sftp-client.c
- (tim) [configure.ac] Autoconf didn't define HAVE_LIBIAF because we
[openssh.git] / sftp-client.c
index c71c66f330bda891990332f33b00af49e11bf460..2746f32457a992db712476ad8966d11ab67ee64a 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp-client.c,v 1.64 2006/03/30 09:58:16 djm Exp $ */
+/* $OpenBSD: sftp-client.c,v 1.76 2007/01/22 11:32:50 djm Exp $ */
 /*
  * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
  *
 #include "includes.h"
 
 #include <sys/types.h>
+#include <sys/param.h>
+#include "openbsd-compat/sys-queue.h"
 #ifdef HAVE_SYS_STAT_H
 # include <sys/stat.h>
 #endif
-# include <signal.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#include <sys/uio.h>
 
-#include "openbsd-compat/sys-queue.h"
+#include <errno.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
 
-#include "buffer.h"
-#include "bufaux.h"
 #include "xmalloc.h"
+#include "buffer.h"
 #include "log.h"
 #include "atomicio.h"
 #include "progressmeter.h"
@@ -61,16 +71,19 @@ static void
 send_msg(int fd, Buffer *m)
 {
        u_char mlen[4];
+       struct iovec iov[2];
 
        if (buffer_len(m) > SFTP_MAX_MSG_LENGTH)
                fatal("Outbound message too long %u", buffer_len(m));
 
        /* Send length first */
        put_u32(mlen, buffer_len(m));
-       if (atomicio(vwrite, fd, mlen, sizeof(mlen)) != sizeof(mlen))
-               fatal("Couldn't send packet: %s", strerror(errno));
+       iov[0].iov_base = mlen;
+       iov[0].iov_len = sizeof(mlen);
+       iov[1].iov_base = buffer_ptr(m);
+       iov[1].iov_len = buffer_len(m);
 
-       if (atomicio(vwrite, fd, buffer_ptr(m), buffer_len(m)) != buffer_len(m))
+       if (atomiciov(writev, fd, iov, 2) != buffer_len(m) + sizeof(mlen))
                fatal("Couldn't send packet: %s", strerror(errno));
 
        buffer_clear(m);
@@ -1121,10 +1134,13 @@ do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
                        if (status != SSH2_FX_OK) {
                                error("Couldn't write to remote file \"%s\": %s",
                                    remote_path, fx2txt(status));
+                               if (showprogress)
+                                       stop_progress_meter();
                                do_close(conn, handle, handle_len);
                                close(local_fd);
                                xfree(data);
                                xfree(ack);
+                               status = -1;
                                goto done;
                        }
                        debug3("In write loop, ack for %u %u bytes at %llu",
This page took 0.03476 seconds and 4 git commands to generate.