handle OSes where you can't rename a open file in the cleanup code.
authorAndrew Tridgell <tridge@samba.org>
Wed, 9 Sep 1998 06:23:27 +0000 (06:23 +0000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 9 Sep 1998 06:23:27 +0000 (06:23 +0000)
cleanup.c
receiver.c

index 05f3452..57fce18 100644 (file)
--- a/cleanup.c
+++ b/cleanup.c
@@ -27,6 +27,8 @@ int cleanup_got_literal=0;
 static char *cleanup_fname;
 static char *cleanup_new_fname;
 static struct file_struct *cleanup_file;
+static int cleanup_fd1, cleanup_fd2;
+static struct map_struct *cleanup_buf;
 
 void exit_cleanup(int code)
 {
@@ -37,6 +39,9 @@ void exit_cleanup(int code)
        if (cleanup_got_literal && cleanup_fname && keep_partial) {
                char *fname = cleanup_fname;
                cleanup_fname = NULL;
+               if (cleanup_buf) unmap_file(cleanup_buf);
+               if (cleanup_fd1 != -1) close(cleanup_fd1);
+               if (cleanup_fd2 != -1) close(cleanup_fd2);
                finish_transfer(cleanup_new_fname, fname, cleanup_file);
        }
        io_flush();
@@ -55,9 +60,13 @@ void cleanup_disable(void)
 }
 
 
-void cleanup_set(char *fnametmp, char *fname, struct file_struct *file)
+void cleanup_set(char *fnametmp, char *fname, struct file_struct *file,
+                struct map_struct *buf, int fd1, int fd2)
 {
        cleanup_fname = fnametmp;
        cleanup_new_fname = fname;
        cleanup_file = file;
+       cleanup_buf = buf;
+       cleanup_fd1 = fd1;
+       cleanup_fd2 = fd2;
 }
index 03912ad..c565a6f 100644 (file)
@@ -398,7 +398,7 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
                        continue;
                }
       
-               cleanup_set(fnametmp, fname, file);
+               cleanup_set(fnametmp, fname, file, buf, fd1, fd2);
 
                if (!am_server && verbose)
                        rprintf(FINFO,"%s\n",fname);
@@ -416,9 +416,9 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
                        rprintf(FINFO,"renaming %s to %s\n",fnametmp,fname);
 
                finish_transfer(fname, fnametmp, file);
-               
+
                cleanup_disable();
-               
+                               
                if (!recv_ok) {
                        if (csum_length == SUM_LENGTH) {
                                rprintf(FERROR,"ERROR: file corruption in %s. File changed during transfer?\n",