changeset 469:2ad1916dc611

2004-5-16 Brian Masney <masneyb@gftp.org> * src/uicommon/gftpui.c lib/gftp.h - added gftpui_protocol_update_timeout() * lib/protocols.c - 64 bit fixes. Check to see if the remote site disconnected
author masneyb
date Sun, 16 May 2004 12:52:12 +0000
parents f4354425e88d
children a68273d9725a
files ChangeLog lib/gftp.h lib/protocols.c src/uicommon/gftpui.c
diffstat 4 files changed, 59 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri May 14 11:08:55 2004 +0000
+++ b/ChangeLog	Sun May 16 12:52:12 2004 +0000
@@ -1,3 +1,10 @@
+2004-5-16 Brian Masney <masneyb@gftp.org>
+	* src/uicommon/gftpui.c lib/gftp.h - added
+	gftpui_protocol_update_timeout()
+
+	* lib/protocols.c - 64 bit fixes. Check to see if the remote site
+	disconnected 
+
 2004-4-14 Brian Masney <masneyb@gftp.org>
 	* lib/protocols.c lib/rfc959.c src/gtk/transfer.c - AMD64 fixes
 
@@ -2448,7 +2455,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.260 2004/04/16 02:11:22 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.261 2004/05/16 12:52:12 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/lib/gftp.h	Fri May 14 11:08:55 2004 +0000
+++ b/lib/gftp.h	Sun May 16 12:52:12 2004 +0000
@@ -1040,5 +1040,7 @@
 					  char *title,
 					  char *question );
 
+void gftpui_protocol_update_timeout 	( gftp_request * request );
+
 #endif
 
--- a/lib/protocols.c	Fri May 14 11:08:55 2004 +0000
+++ b/lib/protocols.c	Sun May 16 12:52:12 2004 +0000
@@ -204,7 +204,8 @@
                     gftp_request * toreq, const char *tofile,
                     int tofd, off_t tosize)
 {
-  float maxkbs;
+  /* Needed for systems that size(float) < size(void *) */
+  union { intptr_t i; float f; } maxkbs;
   off_t size;
   int ret;
 
@@ -213,13 +214,13 @@
   g_return_val_if_fail (toreq != NULL, GFTP_EFATAL);
   g_return_val_if_fail (tofile != NULL, GFTP_EFATAL);
 
-  gftp_lookup_request_option (toreq, "maxkbs", &maxkbs);
-
-  if (maxkbs > 0)
+  gftp_lookup_request_option (toreq, "maxkbs", &maxkbs.f);
+
+  if (maxkbs.f > 0)
     {
       toreq->logging_function (gftp_logging_misc, toreq,
                     _("File transfer will be throttled to %.2f KB/s\n"), 
-                    maxkbs);
+                    maxkbs.f);
     }
 
   if (fromreq->protonum == toreq->protonum &&
@@ -1685,16 +1686,16 @@
 
 
 static GHashTable *
-gftp_gen_dir_hash (gftp_request * request)
+gftp_gen_dir_hash (gftp_request * request, int *ret)
 {
   unsigned long *newsize;
   GHashTable * dirhash;
   gftp_file * fle;
   char * newname;
 
-
   dirhash = g_hash_table_new (string_hash_function, string_hash_compare);
-  if (gftp_list_files (request) == 0)
+  *ret = gftp_list_files (request);
+  if (*ret == 0)
     {
       fle = g_malloc0 (sizeof (*fle));
       while (gftp_get_next_file (request, NULL, fle) > 0)
@@ -1736,7 +1737,7 @@
 
 
 static GList *
-gftp_get_dir_listing (gftp_transfer * transfer, int getothdir)
+gftp_get_dir_listing (gftp_transfer * transfer, int getothdir, int *ret)
 {
   unsigned long *newsize;
   GHashTable * dirhash;
@@ -1745,7 +1746,11 @@
   char *newname;
 
   if (getothdir && transfer->toreq)
-    dirhash = gftp_gen_dir_hash (transfer->toreq);
+    {
+      dirhash = gftp_gen_dir_hash (transfer->toreq, ret);
+      if (*ret < 0)
+        return (NULL);
+    }
   else 
     dirhash = NULL; 
 
@@ -1803,8 +1808,8 @@
                       void (*update_func) (gftp_transfer * transfer))
 {
   char *oldfromdir, *oldtodir, *newname, *pos;
+  int forcecd, remotechanged, ret;
   GList * templist, * lastlist;
-  int forcecd, remotechanged;
   unsigned long *newsize;
   GHashTable * dirhash;
   gftp_file * curfle;
@@ -1814,7 +1819,12 @@
   g_return_val_if_fail (transfer->files != NULL, GFTP_EFATAL);
 
   if (transfer->toreq != NULL)
-    dirhash = gftp_gen_dir_hash (transfer->toreq);
+    {
+      ret = 0;
+      dirhash = gftp_gen_dir_hash (transfer->toreq, &ret);
+      if (ret < 0)
+        return (ret);
+    }
   else
     dirhash = NULL;
 
@@ -1884,8 +1894,17 @@
                     curfle->startsize = 0;
                 } 
 
+              ret = 0;
               lastlist->next = gftp_get_dir_listing (transfer, 
-                                                     curfle->startsize > 0);
+                                                     curfle->startsize > 0,
+                                                     &ret);
+              if (ret < 0)
+                {
+                  if (!GFTP_IS_CONNECTED (transfer->fromreq) ||
+                      !GFTP_IS_CONNECTED (transfer->toreq))
+                    return (ret);
+                }
+
               if (lastlist->next != NULL)
                 {
                   lastlist->next->prev = lastlist;
@@ -2570,14 +2589,15 @@
 void
 gftp_calc_kbs (gftp_transfer * tdata, ssize_t num_read)
 {
+  /* Needed for systems that size(float) < size(void *) */
+  union { intptr_t i; float f; } maxkbs;
   unsigned long waitusecs;
   double start_difftime;
   gftp_file * tempfle;
   struct timeval tv;
-  float maxkbs;
   int waited;
 
-  gftp_lookup_request_option (tdata->fromreq, "maxkbs", &maxkbs);
+  gftp_lookup_request_option (tdata->fromreq, "maxkbs", &maxkbs.f);
 
   if (g_thread_supported ())
     g_static_mutex_lock (&tdata->statmutex);
@@ -2597,9 +2617,9 @@
     tdata->kbs = tdata->trans_bytes / 1024.0 / start_difftime;
 
   waited = 0;
-  if (maxkbs > 0 && tdata->kbs > maxkbs)
+  if (maxkbs.f > 0 && tdata->kbs > maxkbs.f)
     {
-      waitusecs = num_read / 1024.0 / maxkbs * 1000000.0 - start_difftime;
+      waitusecs = num_read / 1024.0 / maxkbs.f * 1000000.0 - start_difftime;
 
       if (waitusecs > 0)
         {
--- a/src/uicommon/gftpui.c	Fri May 14 11:08:55 2004 +0000
+++ b/src/uicommon/gftpui.c	Sun May 16 12:52:12 2004 +0000
@@ -1465,3 +1465,15 @@
   return (1);
 }
 
+
+void
+gftpui_protocol_update_timeout (gftp_request * request)
+{
+  intptr_t network_timeout;
+
+  gftp_lookup_request_option (request, "network_timeout", &network_timeout);
+
+  if (network_timeout > 0)
+    alarm (network_timeout);
+}
+