gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r22620 - gnunet/src/gns


From: gnunet
Subject: [GNUnet-SVN] r22620 - gnunet/src/gns
Date: Thu, 12 Jul 2012 18:10:25 +0200

Author: schanzen
Date: 2012-07-12 18:10:25 +0200 (Thu, 12 Jul 2012)
New Revision: 22620

Modified:
   gnunet/src/gns/gnunet-gns-proxy.c
Log:
-broken

Modified: gnunet/src/gns/gnunet-gns-proxy.c
===================================================================
--- gnunet/src/gns/gnunet-gns-proxy.c   2012-07-12 16:09:06 UTC (rev 22619)
+++ gnunet/src/gns/gnunet-gns-proxy.c   2012-07-12 16:10:25 UTC (rev 22620)
@@ -765,17 +765,19 @@
   struct ProxyCurlTask *ctask = cls;
   struct ProxyREMatch *re_match = ctask->pp_match_head;
   ssize_t copied = 0;
-  size_t bytes_to_copy = ctask->buffer_write_ptr - ctask->buffer_read_ptr;
+  long long int bytes_to_copy = ctask->buffer_write_ptr - 
ctask->buffer_read_ptr;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "MHD: content cb for %s\n", ctask->url);
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "MHD: content cb for %s. To copy: %lld\n",
+              ctask->url, bytes_to_copy);
+  GNUNET_assert (bytes_to_copy >= 0);
 
   if ((GNUNET_YES == ctask->download_is_finished) &&
       (GNUNET_NO == ctask->download_error) &&
       (0 == bytes_to_copy) &&
       (BUF_WAIT_FOR_CURL == ctask->buf_status))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 "MHD: sending response for %s\n", ctask->url);
     ctask->download_in_progress = GNUNET_NO;
     run_mhd_now (ctask->mhd);
@@ -789,7 +791,7 @@
       (0 == bytes_to_copy) &&
       (BUF_WAIT_FOR_CURL == ctask->buf_status))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 "MHD: sending error response\n");
     ctask->download_in_progress = GNUNET_NO;
     run_mhd_now (ctask->mhd);
@@ -807,14 +809,12 @@
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 "MHD: Processing PP %s\n",
                 re_match->hostname);
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                "re start %d\n",
-                re_match->start);
     bytes_to_copy = re_match->start - ctask->buffer_read_ptr;
+    GNUNET_assert (bytes_to_copy >= 0);
 
     if (bytes_to_copy+copied > max)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
              "MHD: buffer in response too small for %d. Using available space 
(%d). (%s)\n",
              bytes_to_copy,
              max,
@@ -822,12 +822,12 @@
       memcpy (buf+copied, ctask->buffer_read_ptr, max-copied);
       ctask->buffer_read_ptr += max-copied;
       copied = max;
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "MHD: copied %d bytes\n", copied);
       return copied;
     }
 
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 "MHD: copying %d bytes to mhd response at offset %d\n",
                 bytes_to_copy, ctask->buffer_read_ptr);
     memcpy (buf+copied, ctask->buffer_read_ptr, bytes_to_copy);
@@ -835,9 +835,9 @@
 
     if (GNUNET_NO == re_match->done)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                   "MHD: Waiting for PP of %s\n", re_match->hostname);
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "MHD: copied %d bytes\n", copied);
       ctask->buffer_read_ptr += bytes_to_copy;
       return copied;
@@ -845,6 +845,7 @@
     
     if (strlen (re_match->result) > (max - copied))
     {
+      //FIXME partially copy domain here
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "MHD: buffer in response too small for %s! (%s)\n",
                   re_match->result,
@@ -861,9 +862,6 @@
     memcpy (buf+copied, re_match->result, strlen (re_match->result));
     copied += strlen (re_match->result);
     ctask->buffer_read_ptr = re_match->end;
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                "Setting buffer ptr to re end %d\n",
-                re_match->end);
     GNUNET_CONTAINER_DLL_remove (ctask->pp_match_head,
                                  ctask->pp_match_tail,
                                  re_match);
@@ -871,7 +869,14 @@
   }
 
   bytes_to_copy = ctask->buffer_write_ptr - ctask->buffer_read_ptr;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "MHD: copied: %d left: %d, space left in buf: %d\n",
+              copied,
+              bytes_to_copy, max-copied);
   
+  GNUNET_assert (0 <= bytes_to_copy);
+
   if (GNUNET_NO == ctask->download_is_finished)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -893,9 +898,10 @@
   ctask->buf_status = BUF_WAIT_FOR_CURL;
   
   if ((NULL != ctask->curl) &&
-      (GNUNET_NO == ctask->download_is_finished))
+      (GNUNET_NO == ctask->download_is_finished) &&
+      ((ctask->buffer_write_ptr - ctask->buffer_read_ptr) <= 0))
     curl_easy_pause (ctask->curl, CURLPAUSE_CONT);
-  
+
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "MHD: copied %d bytes\n", copied);
   run_mhd_now (ctask->mhd);
@@ -912,6 +918,7 @@
 process_shorten (void* cls, const char* short_name)
 {
   struct ProxyREMatch *re_match = cls;
+  char result[sizeof (re_match->result)];
   
   if (NULL == short_name)
   {
@@ -925,15 +932,20 @@
     return;
   }
 
+  if (0 == strcmp (short_name, re_match->ctask->leho))
+    strcpy (result, re_match->ctask->host);
+  else
+    strcpy (result, short_name);
+
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "PP: Shorten %s -> %s\n",
               re_match->hostname,
-              short_name);
+              result);
   //this is evil.. what about https
   if (re_match->ctask->mhd->is_ssl)
-    sprintf (re_match->result, "href=\"https://%s";, short_name);
+    sprintf (re_match->result, "href=\"https://%s";, result);
   else
-    sprintf (re_match->result, "href=\"http://%s";, short_name);
+    sprintf (re_match->result, "href=\"http://%s";, result);
 
   re_match->done = GNUNET_YES;
   run_mhd_now (re_match->ctask->mhd);
@@ -986,6 +998,8 @@
     re_match->done = GNUNET_NO;
     re_match->ctask = ctask;
     strcpy (re_match->hostname, re_hostname);
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Got hostname %s\n", re_hostname);
     re_ptr += m[3].rm_eo;
 
     if (GNUNET_YES == is_tld (re_match->hostname, GNUNET_GNS_TLD_PLUS))
@@ -1027,11 +1041,15 @@
   size_t buf_space = sizeof (ctask->buffer) -
     (ctask->buffer_write_ptr-ctask->buffer);
 
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "CURL: Got %d. %d free in buffer\n",
+              total, buf_space);
+
   if (total > (buf_space - CURL_BUF_PADDING))
   {
     if (ctask->buf_status == BUF_WAIT_FOR_CURL)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                   "CURL: Buffer full starting postprocessing\n");
       ctask->buf_status = BUF_WAIT_FOR_PP;
       ctask->pp_task = GNUNET_SCHEDULER_add_now (&postprocess_buffer,
@@ -1254,9 +1272,12 @@
 
              GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                          "CURL: Completed ctask!\n");
-             ctask->buf_status = BUF_WAIT_FOR_PP;
-             ctask->pp_task = GNUNET_SCHEDULER_add_now (&postprocess_buffer,
-                                                        ctask);
+             if (GNUNET_SCHEDULER_NO_TASK == ctask->pp_task)
+             {
+              ctask->buf_status = BUF_WAIT_FOR_PP;
+              ctask->pp_task = GNUNET_SCHEDULER_add_now (&postprocess_buffer,
+                                                          ctask);
+             }
 
              //ctask->ready_to_queue = MHD_YES;
              ctask->download_is_finished = GNUNET_YES;
@@ -1535,6 +1556,7 @@
     ctask->curl_response_code = MHD_HTTP_OK;
     ctask->buffer_read_ptr = ctask->buffer;
     ctask->buffer_write_ptr = ctask->buffer;
+    ctask->pp_task = GNUNET_SCHEDULER_NO_TASK;
 
     MHD_get_connection_values (con,
                                MHD_HEADER_KIND,
@@ -1577,12 +1599,16 @@
   }
 
   ctask = (struct ProxyCurlTask *) *con_cls;
-  GNUNET_break (GNUNET_YES != ctask->fin);
+  
   if (GNUNET_YES != ctask->ready_to_queue)
     return MHD_YES; /* wait longer */
+  
+  if (GNUNET_YES == ctask->fin)
+    return MHD_YES;
+
   ctask->fin = GNUNET_YES;
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "MHD: Queueing response\n");
+              "MHD: Queueing response for %s\n", ctask->url);
   ret = MHD_queue_response (con, ctask->curl_response_code, ctask->response);
   run_mhd_now (ctask->mhd);
   return ret;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]