[patch] Fix ftpfs uploading behavior -rc1
- From: "Andrew V. Samoilov" <kai cmail ru>
- To: Pavel Roskin <proski gnu org>
- Cc: Walery Studennikov <despair sama ru>, mc-devel gnome org, Pavel Machek <pavel ucw cz>
- Subject: [patch] Fix ftpfs uploading behavior -rc1
- Date: Fri, 15 Mar 2002 17:14:58 +0200
Hello,
I reworked ftpfs uploading patch and now I invite you to test it
hardly. There are 3 changed files and one new field (linear) in
vfs_s_super structure. This flag inform ftpfs_fh_open about ordered
linear transfer in this ftp connection. Now temporary file is used
only if file is copied over ftpfs from ftp server to the same ftp
server. I think it is not good idea to open new control connection.
Also this version will be uploaded to
http://www.linux.zp.ua/mc/ftpfs.upload.patch
soon.
In final version I think add some more comments.
Your comments and suggestions are greatly appreshiated.
Regards,
Andrew.
Index: xdirentry.h
===================================================================
RCS file: /cvs/gnome/mc/vfs/xdirentry.h,v
retrieving revision 1.15
diff -u -p -u -p -r1.15 xdirentry.h
--- xdirentry.h 3 Aug 2001 10:15:17 -0000 1.15
+++ xdirentry.h 15 Mar 2002 14:51:13 -0000
@@ -81,6 +81,7 @@ typedef struct vfs_s_super {
int fd_usage; /* Number of open files */
int ino_usage; /* Usage count of this superblock */
int want_stale; /* If set, we do not flush cache properly */
+ int linear; /* linear transfer is processed now */
union {
struct {
Index: direntry.c
===================================================================
RCS file: /cvs/gnome/mc/vfs/direntry.c,v
retrieving revision 1.40
diff -u -p -u -p -r1.40 direntry.c
--- direntry.c 6 Mar 2002 08:46:35 -0000 1.40
+++ direntry.c 15 Mar 2002 14:51:18 -0000
@@ -788,6 +788,7 @@ vfs_s_open (vfs *me, char *file, int fla
if (IS_LINEAR(flags)) {
fh->linear = LS_LINEAR_CLOSED;
+ FH_SUPER->linear = 1;
} else if ((MEDATA->fh_open) && (MEDATA->fh_open (me, fh, flags, mode))){
g_free(fh);
return NULL;
@@ -816,8 +817,10 @@ vfs_s_read (void *fh, char *buffer, int
if (FH->linear == LS_LINEAR_CLOSED){
print_vfs_message (_("Starting linear transfer..."));
- if (!MEDATA->linear_start (me, FH, 0))
+ if (!MEDATA->linear_start (me, FH, 0)){
+ FH_SUPER->linear = 0;
return -1;
+ }
}
if (FH->linear == LS_LINEAR_CLOSED)
@@ -906,8 +909,10 @@ vfs_s_close (void *fh)
vfs_add_noncurrent_stamps (me, (vfsid) (FH_SUPER), parent);
vfs_rm_parents (parent);
}
- if (FH->linear == LS_LINEAR_OPEN)
+ if (FH->linear == LS_LINEAR_OPEN){
MEDATA->linear_close (me, fh);
+ FH_SUPER->linear = 0;
+ }
if (MEDATA->fh_close)
res = MEDATA->fh_close (me, fh);
if (FH->changed && MEDATA->file_store){
Index: ftpfs.c
===================================================================
RCS file: /cvs/gnome/mc/vfs/ftpfs.c,v
retrieving revision 1.89
diff -u -p -u -p -r1.89 ftpfs.c
--- ftpfs.c 8 Feb 2002 09:42:38 -0000 1.89
+++ ftpfs.c 15 Mar 2002 14:51:54 -0000
@@ -1683,6 +1685,38 @@ static void my_forget (char *file)
static int ftpfs_fh_open (vfs *me, vfs_s_fh *fh, int flags, int mode)
{
+ if (((flags & O_WRONLY) == O_WRONLY) && !(flags & (O_RDONLY|O_RDWR))){
+#ifdef HAVE_STRUCT_LINGER
+ struct linger li;
+#else
+ int li = 1;
+#endif
+ char * name;
+
+ if (FH_SUPER->linear)
+ return 0;
+ name = vfs_s_fullpath (me, fh->ino);
+ if (!name)
+ return -1;
+ fh->handle = open_data_connection(me, fh->ino->super,
+ (flags & O_APPEND) ? "APPE" : "STOR", name, TYPE_BINARY, 0);
+ g_free (name);
+
+ if (fh->handle < 0)
+ return -1;
+#ifdef HAVE_STRUCT_LINGER
+ li.l_onoff = 1;
+ li.l_linger = 120;
+#endif
+ setsockopt(fh->handle, SOL_SOCKET, SO_LINGER, &li, sizeof(li));
+
+ if (fh->ino->localname){
+ unlink (fh->ino->localname);
+ g_free (fh->ino->localname);
+ fh->ino->localname = NULL;
+ }
+ return 0;
+ }
if (!fh->ino->localname)
if (vfs_s_retrieve_file (me, fh->ino)==-1)
return -1;
@@ -1691,6 +1725,18 @@ static int ftpfs_fh_open (vfs *me, vfs_s
return 0;
}
+static int ftpfs_fh_close (vfs *me, vfs_s_fh *fh)
+{
+ if (fh->handle != -1 && !fh->ino->localname){
+ close (fh->handle);
+ fh->handle = -1;
+ fh->changed = 0;
+ if (get_reply (me, fh->ino->SUP.sock, NULL, 0) != COMPLETE)
+ ERRNOR (EIO, -1);
+ }
+ return 0;
+}
+
static struct vfs_s_data ftp_data = {
NULL,
0,
@@ -1707,7 +1753,7 @@ static struct vfs_s_data ftp_data = {
free_archive,
ftpfs_fh_open, /* fh_open */
- NULL, /* fh_close */
+ ftpfs_fh_close, /* fh_close */
vfs_s_find_entry_linear,
dir_load,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]