gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r12126 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r12126 - gnunet/src/transport
Date: Fri, 2 Jul 2010 16:29:34 +0200

Author: wachs
Date: 2010-07-02 16:29:34 +0200 (Fri, 02 Jul 2010)
New Revision: 12126

Modified:
   gnunet/src/transport/plugin_transport_http.c
Log:


Modified: gnunet/src/transport/plugin_transport_http.c
===================================================================
--- gnunet/src/transport/plugin_transport_http.c        2010-07-02 14:21:43 UTC 
(rev 12125)
+++ gnunet/src/transport/plugin_transport_http.c        2010-07-02 14:29:34 UTC 
(rev 12126)
@@ -42,7 +42,7 @@
 
 
 #define DEBUG_CURL GNUNET_YES
-#define DEBUG_HTTP GNUNET_YES
+#define DEBUG_HTTP GNUNET_NO
 
 /**
  * Text of the response sent back after the last bytes of a PUT
@@ -448,6 +448,20 @@
 }
 
 /**
+ * Removes a message from the linked list of messages
+ * @param con connection to remove message from
+ * @param msg message to remove
+ * @return GNUNET_SYSERR if msg not found, GNUNET_OK on success
+ */
+
+static int remove_http_message(struct HTTP_Connection * con, struct 
HTTP_Message * msg)
+{
+  
GNUNET_CONTAINER_DLL_remove(con->pending_msgs_head,con->pending_msgs_tail,msg);
+  GNUNET_free(msg);
+  return GNUNET_OK;
+}
+
+/**
  * Check if session already knows this address for a outbound connection to 
this peer
  * If address not in session, add it to the session
  * @param cls the plugin used
@@ -597,16 +611,32 @@
 
 int server_read_callback (void *cls, uint64_t pos, char *buf, int max)
 {
-  static int i = 0;
+  int bytes_read = 0;
 
-  char * test ="Hello World!";
-  int bytes_read = -1;
-  if (i<10)
+  struct HTTP_Connection * con = cls;
+  struct HTTP_Message * msg;
+  int res;
+
+  if (con->pending_msgs_tail!=NULL)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "server_read_callback\n");
-    memcpy(buf,test,strlen(test));
-    bytes_read = strlen(test);
-    i++;
+      msg=con->pending_msgs_tail;
+      /*
+      if ((msg->size-msg->pos) <= max)
+      {
+        memcpy(buf,&msg->buf[pos],(msg->size-msg->pos));
+        pos+=(msg->size-msg->pos);
+      }
+      else
+      {
+        memcpy(buf,&msg->buf[pos],max);
+        pos+=max;
+      }*/
+      if (msg->pos==msg->size)
+      {
+        if (NULL != con->pending_msgs_tail->transmit_cont)
+          msg->transmit_cont 
(msg->transmit_cont_cls,&con->session->identity,GNUNET_SYSERR);
+        res = remove_http_message(con,msg);
+      }
   }
   return bytes_read;
 }
@@ -736,7 +766,7 @@
   }
   if ( 0 == strcmp (MHD_HTTP_METHOD_GET, method) )
   {
-    response = MHD_create_response_from_callback(-1,32 * 1024, 
&server_read_callback, cs, NULL);
+    response = MHD_create_response_from_callback(-1,32 * 1024, 
&server_read_callback, con, NULL);
     res = MHD_queue_response (mhd_connection, MHD_HTTP_OK, response);
     MHD_destroy_response (response);
 
@@ -878,21 +908,7 @@
   return;
 }
 
-/**
- * Removes a message from the linked list of messages
- * @param con connection to remove message from
- * @param msg message to remove
- * @return GNUNET_SYSERR if msg not found, GNUNET_OK on success
- */
 
-static int remove_http_message(struct HTTP_Connection * con, struct 
HTTP_Message * msg)
-{
-  
GNUNET_CONTAINER_DLL_remove(con->pending_msgs_head,con->pending_msgs_tail,msg);
-  GNUNET_free(msg);
-  return GNUNET_OK;
-}
-
-
 static size_t curl_header_function( void *ptr, size_t size, size_t nmemb, void 
*stream)
 {
   struct HTTP_Connection * con = stream;
@@ -903,21 +919,18 @@
   int res;
 
   /* Getting last http result code */
-  GNUNET_assert(NULL!=con);
-  res = curl_easy_getinfo(con->get_curl_handle, CURLINFO_RESPONSE_CODE, 
&http_result);
-
-  if ((CURLE_OK == res) && (con->get_connected==GNUNET_NO))
+  if (con->get_connected==GNUNET_NO)
   {
-    if (http_result == 200)
+    GNUNET_assert(NULL!=con);
+    res = curl_easy_getinfo(con->get_curl_handle, CURLINFO_RESPONSE_CODE, 
&http_result);
+    if (CURLE_OK == res)
     {
-      con->get_connected = GNUNET_YES;
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: inbound 
connected\n",con);
+      if (http_result == 200)
+      {
+        con->get_connected = GNUNET_YES;
+        GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: inbound 
connected\n",con);
+      }
     }
-    else
-    {
-      con->get_connected = GNUNET_NO;
-      //GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: inbound 
connected\n",con);
-    }
   }
 
   tmp = NULL;




reply via email to

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