changeset 442:9d03253b00d0

2004-3-20 Brian Masney <masneyb@gftp.org> * Officially release 2.0.17pre0 * 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 error code is returned, immediately reconnect to the server and retry the operation * lib/rfc959.c - if the return value from rfc959_send_command() is < 0, then make sure the exact value is returned instead of GFTP_ERETRYABLE
author masneyb
date Sat, 20 Mar 2004 19:36:05 +0000
parents f8a0c22af707
children 6b1e4bd20ae4
files ChangeLog lib/gftp.h lib/rfc959.c src/uicommon/gftpui.c
diffstat 4 files changed, 51 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Mar 20 19:17:48 2004 +0000
+++ b/ChangeLog	Sat Mar 20 19:36:05 2004 +0000
@@ -1,4 +1,13 @@
 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
+	error code is returned, immediately reconnect to the server and retry
+	the operation
+
+	* lib/rfc959.c - if the return value from rfc959_send_command() is
+	< 0, then make sure the exact value is returned instead of
+	GFTP_ERETRYABLE
+
 	* src/gtk/chmod_dialog.c - use gftpui_common_run_callback_function()
 	to do the chmod operation. This will spawn a thread if necessary
 
@@ -2342,7 +2351,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.246 2004/03/20 19:17:47 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.247 2004/03/20 19:36:03 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/lib/gftp.h	Sat Mar 20 19:17:48 2004 +0000
+++ b/lib/gftp.h	Sat Mar 20 19:36:05 2004 +0000
@@ -173,6 +173,7 @@
 #define GFTP_ENOTRANS		-4		/* Custom error. This is
 						   returned when a FXP transfer
 						   is requested */
+#define GFTP_ETIMEDOUT		-5		/* Connected timed out */
 
 /* Some general settings */
 #define BASE_CONF_DIR		"~/.gftp"
--- a/lib/rfc959.c	Sat Mar 20 19:17:48 2004 +0000
+++ b/lib/rfc959.c	Sat Mar 20 19:36:05 2004 +0000
@@ -130,7 +130,10 @@
   if (request->last_ftp_response[0] == '4' &&
       request->last_ftp_response[1] == '2' &&
       disconnect_on_42x)
-    gftp_disconnect (request);
+    {
+      gftp_disconnect (request);
+      return (GFTP_ETIMEDOUT);
+    }
 
   return (*request->last_ftp_response);
 }
@@ -365,7 +368,9 @@
       g_free (tempstr);
     }
 
-  if (ret != '2')
+  if (ret < 0)
+    return (ret);
+  else if (ret != '2')
     return (GFTP_ERETRYABLE);
 
   if (directory != request->directory)
@@ -1074,7 +1079,9 @@
       resp = rfc959_send_command (request, command, 1);
       g_free (command);
 
-      if (resp != '3')
+      if (resp < 0)
+        return (resp);
+      else if (resp != '3')
         {
           close (parms->data_connection);
           parms->data_connection = -1;
@@ -1086,7 +1093,9 @@
   ret = rfc959_send_command (request, tempstr, 1);
   g_free (tempstr);
 
-  if (ret != '1')
+  if (ret < 0)
+    return (ret);
+  else if (ret != '1')
     {
       close (parms->data_connection);
       parms->data_connection = -1;
@@ -1147,7 +1156,9 @@
 #endif
       resp = rfc959_send_command (request, command, 1);
       g_free (command);
-      if (resp != '3')
+      if (resp < 0)
+        return (resp);
+      else if (resp != '3')
         {
           close (parms->data_connection);
           parms->data_connection = -1;
@@ -1158,7 +1169,9 @@
   tempstr = g_strconcat ("STOR ", filename, "\r\n", NULL);
   ret = rfc959_send_command (request, tempstr, 1);
   g_free (tempstr);
-  if (ret != '1')
+  if (ret < 0)
+    return (ret);
+  else if (ret != '1')
     {
       close (parms->data_connection);
       parms->data_connection = -1;
@@ -1190,8 +1203,10 @@
   g_return_val_if_fail (fromreq->datafd > 0, GFTP_EFATAL);
   g_return_val_if_fail (toreq->datafd > 0, GFTP_EFATAL);
 
-  if ((ret = rfc959_send_command (fromreq, "PASV\r\n", 1)) != '2')
+  if ((ret = rfc959_send_command (fromreq, "PASV\r\n", 1)) < 0)
     return (ret);
+  else if (ret != '2')
+    return (GFTP_ERETRYABLE);
 
   pos = fromreq->last_ftp_response + 4;
   while (!isdigit ((int) *pos) && *pos != '\0') 
@@ -1206,13 +1221,14 @@
     *endpos = '\0';
 
   tempstr = g_strconcat ("PORT ", pos, "\r\n", NULL);
-  if ((ret = rfc959_send_command (toreq, tempstr, 1)) != '2')
-     {
-       g_free (tempstr);
-       return (ret);
-     }
+  ret = rfc959_send_command (toreq, tempstr, 1);
   g_free (tempstr);
 
+  if (ret < 0)
+    return (ret);
+  else if (ret != '2')
+    return (GFTP_ERETRYABLE);
+
   tempstr = g_strconcat ("RETR ", fromfile, "\r\n", NULL);
   if ((ret = rfc959_send_command (fromreq, tempstr, 0)) < 0)
     {
@@ -1330,7 +1346,9 @@
   ret = rfc959_send_command (request, tempstr, 1);
   g_free (tempstr);
 
-  if (ret != '1')
+  if (ret < 0)
+    return (ret);
+  else if (ret != '1')
     {
       request->logging_function (gftp_logging_error, request,
                                  _("Invalid response '%c' received from server.\n"),
--- a/src/uicommon/gftpui.c	Sat Mar 20 19:17:48 2004 +0000
+++ b/src/uicommon/gftpui.c	Sat Mar 20 19:36:05 2004 +0000
@@ -33,7 +33,7 @@
 { 
   intptr_t network_timeout, sleep_time;
   gftpui_callback_data * cdata;
-  int success, sj;
+  int success, sj, num_timeouts;
 
   cdata = data;
   gftp_lookup_request_option (cdata->request, "network_timeout",
@@ -44,6 +44,7 @@
   sj = sigsetjmp (gftpui_common_jmp_environment, 1);
   gftpui_common_use_jmp_environment = 1;
 
+  num_timeouts = 0;
   success = GFTP_ERETRYABLE;
   if (sj != 1)
     {
@@ -54,6 +55,13 @@
           success = cdata->run_function (cdata);
           alarm (0);
 
+          if (success == GFTP_ETIMEDOUT && num_timeouts == 0)
+            {
+              num_timeouts++;
+              if (gftp_connect (cdata->request) == 0)
+                continue;
+            }
+
           if (success == GFTP_EFATAL || success == 0 || cdata->retries == 0)
             break;