changeset 443:6b1e4bd20ae4

2004-3-21 Brian Masney <masneyb@gftp.org> * src/uicommon/gftpuicallbacks.c (gftpui_common_run_ls) - if there is an error, make sure that the exact error code is returned * lib/protocols.c (gftp_transfer_files) - if the connection timed out, reconnect immediately * lib/rfc959.c - if the connection timed out to the server, make sure GFTP_ETIMEDOUT is returned
author masneyb
date Sun, 21 Mar 2004 12:26:18 +0000
parents 9d03253b00d0
children d469882002d9
files ChangeLog lib/protocols.c lib/rfc959.c src/uicommon/gftpuicallbacks.c
diffstat 4 files changed, 73 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Mar 20 19:36:05 2004 +0000
+++ b/ChangeLog	Sun Mar 21 12:26:18 2004 +0000
@@ -1,3 +1,13 @@
+2004-3-21 Brian Masney <masneyb@gftp.org>
+	* src/uicommon/gftpuicallbacks.c (gftpui_common_run_ls) - if there
+	is an error, make sure that the exact error code is returned
+
+	* lib/protocols.c (gftp_transfer_files) - if the connection timed
+	out, reconnect immediately
+
+	* lib/rfc959.c - if the connection timed out to the server, make
+	sure GFTP_ETIMEDOUT is returned
+
 2004-3-20 Brian Masney <masneyb@gftp.org>
 	* lib/gftp.h src/uicommon/gftpui.c lib/rfc959.c - if the connection
 	timed out to the server, return GFTP_ETIMEDOUT. In the UI, if this
@@ -2351,7 +2361,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.247 2004/03/20 19:36:03 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.248 2004/03/21 12:26:15 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/lib/protocols.c	Sat Mar 20 19:36:05 2004 +0000
+++ b/lib/protocols.c	Sun Mar 21 12:26:18 2004 +0000
@@ -229,11 +229,36 @@
 
   fromreq->cached = 0;
   toreq->cached = 0;
-  if ((size = gftp_get_file (fromreq, fromfile, fromfd, tosize)) < 0)
-    return (size);
-
-  if ((ret = gftp_put_file (toreq, tofile, tofd, tosize, size)) != 0)
+
+get_file:
+  size = gftp_get_file (fromreq, fromfile, fromfd, tosize);
+  if (size < 0)
     {
+      if (size == GFTP_ETIMEDOUT)
+        {
+          ret = gftp_connect (fromreq);
+          if (ret < 0)
+            return (ret);
+
+          goto get_file;
+        }
+
+      return (size);
+    }
+
+put_file:
+  ret = gftp_put_file (toreq, tofile, tofd, tosize, size);
+  if (ret != 0)
+    {
+      if (size == GFTP_ETIMEDOUT)
+        {
+          ret = gftp_connect (fromreq);
+          if (ret < 0)
+            return (ret);
+
+          goto put_file;
+        }
+
       if (gftp_abort_transfer (fromreq) != 0)
         gftp_end_transfer (fromreq);
 
--- a/lib/rfc959.c	Sat Mar 20 19:36:05 2004 +0000
+++ b/lib/rfc959.c	Sun Mar 21 12:26:18 2004 +0000
@@ -504,7 +504,7 @@
       resp = rfc959_send_command (request, tempstr, 1);
       g_free (tempstr);
       if (resp < 0)
-        return (GFTP_ERETRYABLE);
+        return (resp);
 
       if (resp == '3')
 	{
@@ -520,7 +520,7 @@
 	  resp = rfc959_send_command (request, tempstr, 1);
 	  g_free (tempstr);
           if (resp < 0)
-            return (GFTP_ERETRYABLE);
+            return (resp);
         }
 
       if (resp == '3' && request->account)
@@ -529,7 +529,7 @@
 	  resp = rfc959_send_command (request, tempstr, 1);
 	  g_free (tempstr);
           if (resp < 0)
-            return (GFTP_ERETRYABLE);
+            return (resp);
 	}
     }
 
@@ -647,12 +647,13 @@
   gftp_lookup_request_option (request, "passive_transfer", &passive_transfer);
   if (passive_transfer)
     {
-      if ((resp = rfc959_send_command (request, "PASV\r\n", 1)) != '2')
+      resp = rfc959_send_command (request, "PASV\r\n", 1);
+      if (resp < 0)
+        return (resp);
+      else if (resp != '2')
 	{
-          if (request->datafd < 0)
-            return (GFTP_ERETRYABLE);
-
-          gftp_set_request_option (request, "passive_transfer", GINT_TO_POINTER(0));
+          gftp_set_request_option (request, "passive_transfer",
+                                   GINT_TO_POINTER(0));
 	  return (rfc959_ipv4_data_connection_new (request));
 	}
 
@@ -745,7 +746,10 @@
 				 pos1[1] & 0xff);
       resp = rfc959_send_command (request, command, 1);
       g_free (command);
-      if (resp != '2')
+
+      if (resp < 0)
+        return (resp);
+      else if (resp != '2')
 	{
           request->logging_function (gftp_logging_error, request,
                                      _("Invalid response '%c' received from server.\n"),
@@ -806,11 +810,11 @@
   gftp_lookup_request_option (request, "passive_transfer", &passive_transfer);
   if (passive_transfer)
     {
-      if ((resp = rfc959_send_command (request, "EPSV\r\n", 1)) != '2')
+      resp = rfc959_send_command (request, "EPSV\r\n", 1);
+      if (resp < 0)
+        return (resp);
+      else if (resp != '2')
 	{
-          if (request->datafd < 0)
-            return (GFTP_ERETRYABLE);
-
           gftp_set_request_option (request, "passive_transfer", 
                                    GINT_TO_POINTER(0));
 	  return (rfc959_ipv6_data_connection_new (request));
@@ -901,7 +905,10 @@
 
       resp = rfc959_send_command (request, command, 1);
       g_free (command);
-      if (resp != '2')
+
+      if (resp < 0)
+        return (resp);
+      else if (resp != '2')
 	{
           gftp_disconnect (request);
 	  return (GFTP_ERETRYABLE);
@@ -1230,21 +1237,19 @@
     return (GFTP_ERETRYABLE);
 
   tempstr = g_strconcat ("RETR ", fromfile, "\r\n", NULL);
-  if ((ret = rfc959_send_command (fromreq, tempstr, 0)) < 0)
-    {
-      g_free (tempstr);
-      return (ret);
-    }
+  ret = rfc959_send_command (fromreq, tempstr, 0);
   g_free (tempstr);
 
+  if (ret < 0)
+    return (ret);
+
   tempstr = g_strconcat ("STOR ", tofile, "\r\n", NULL);
-  if ((ret = rfc959_send_command (toreq, tempstr, 0)) < 0)
-    {
-      g_free (tempstr);
-      return (ret);
-    }
+  ret = rfc959_send_command (toreq, tempstr, 0);
   g_free (tempstr);
 
+  if (ret < 0)
+    return (ret);
+
   if ((ret = rfc959_read_response (fromreq, 1)) < 0)
     return (ret);
 
--- a/src/uicommon/gftpuicallbacks.c	Sat Mar 20 19:36:05 2004 +0000
+++ b/src/uicommon/gftpuicallbacks.c	Sun Mar 21 12:26:18 2004 +0000
@@ -61,13 +61,14 @@
 int
 gftpui_common_run_ls (gftpui_callback_data * cdata)
 {
-  int got, matched_filespec, have_dotdot;
+  int got, matched_filespec, have_dotdot, ret;
   char *sortcol_var, *sortasds_var;
   intptr_t sortcol, sortasds;
   gftp_file * fle;
 
-  if (gftp_list_files (cdata->request) != 0)
-    return (0);
+  ret = gftp_list_files (cdata->request);
+  if (ret < 0)
+    return (ret);
 
   have_dotdot = 0;
   cdata->request->gotbytes = 0;