gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r33114 - in gnunet-dbus: . src/lib/common src/lib/include s


From: gnunet
Subject: [GNUnet-SVN] r33114 - in gnunet-dbus: . src/lib/common src/lib/include src/services
Date: Sat, 19 Apr 2014 04:09:39 +0200

Author: canndrew
Date: 2014-04-19 04:09:39 +0200 (Sat, 19 Apr 2014)
New Revision: 33114

Modified:
   gnunet-dbus/.gitignore
   gnunet-dbus/src/lib/common/gnunet_dbus_lib_client.c
   gnunet-dbus/src/lib/common/gnunet_dbus_lib_object.c
   gnunet-dbus/src/lib/include/gnunet_dbus_lib_object.h
   gnunet-dbus/src/services/gnunet-service-dht-dbus.c
Log:
Added stop function for get requests. Bug fixes

Modified: gnunet-dbus/.gitignore
===================================================================
--- gnunet-dbus/.gitignore      2014-04-18 22:12:22 UTC (rev 33113)
+++ gnunet-dbus/.gitignore      2014-04-19 02:09:39 UTC (rev 33114)
@@ -4,6 +4,9 @@
 *.o
 *.la
 *.lo
+*.swp
+*.swo
+
 .deps
 .libs
 /aclocal.m4

Modified: gnunet-dbus/src/lib/common/gnunet_dbus_lib_client.c
===================================================================
--- gnunet-dbus/src/lib/common/gnunet_dbus_lib_client.c 2014-04-18 22:12:22 UTC 
(rev 33113)
+++ gnunet-dbus/src/lib/common/gnunet_dbus_lib_client.c 2014-04-19 02:09:39 UTC 
(rev 33114)
@@ -25,6 +25,7 @@
   client->unique_name = GNUNET_strdup (unique_name);
   client->data = NULL;
   client->prefers_pretty_encodings = false;
+  client->ref_count = 1;
 
   return client;
 };

Modified: gnunet-dbus/src/lib/common/gnunet_dbus_lib_object.c
===================================================================
--- gnunet-dbus/src/lib/common/gnunet_dbus_lib_object.c 2014-04-18 22:12:22 UTC 
(rev 33113)
+++ gnunet-dbus/src/lib/common/gnunet_dbus_lib_object.c 2014-04-19 02:09:39 UTC 
(rev 33114)
@@ -168,9 +168,10 @@
   GNUNET_CONTAINER_DLL_remove (object->subobjects_front,
                                object->subobjects_back,
                                subobject_it);
+  GNUNET_free (subobject_it);
 };
 
-const struct GNUNET_DBUS_ObjectIterator *
+struct GNUNET_DBUS_ObjectIterator *
 GNUNET_DBUS_object_iterate_subobjects (
     const struct GNUNET_DBUS_Object *object)
 {

Modified: gnunet-dbus/src/lib/include/gnunet_dbus_lib_object.h
===================================================================
--- gnunet-dbus/src/lib/include/gnunet_dbus_lib_object.h        2014-04-18 
22:12:22 UTC (rev 33113)
+++ gnunet-dbus/src/lib/include/gnunet_dbus_lib_object.h        2014-04-19 
02:09:39 UTC (rev 33114)
@@ -59,7 +59,7 @@
     struct GNUNET_DBUS_Object *object,
     struct GNUNET_DBUS_ObjectIterator *subobject_it);
 
-const struct GNUNET_DBUS_ObjectIterator *
+struct GNUNET_DBUS_ObjectIterator *
 GNUNET_DBUS_object_iterate_subobjects (
     const struct GNUNET_DBUS_Object *object);
 

Modified: gnunet-dbus/src/services/gnunet-service-dht-dbus.c
===================================================================
--- gnunet-dbus/src/services/gnunet-service-dht-dbus.c  2014-04-18 22:12:22 UTC 
(rev 33113)
+++ gnunet-dbus/src/services/gnunet-service-dht-dbus.c  2014-04-19 02:09:39 UTC 
(rev 33114)
@@ -37,6 +37,7 @@
 static struct GNUNET_DBUS_Interface *gbl_dht_get_request_interface;
 static struct GNUNET_DBUS_Method    
     *gbl_dht_get_request_filter_known_results_method;
+static struct GNUNET_DBUS_Method    *gbl_dht_get_request_stop_method;
 static struct GNUNET_DBUS_Signal    *gbl_dht_get_request_result_signal;
 
 static void
@@ -205,6 +206,45 @@
 }
 
 static void
+get_stop (
+    struct GNUNET_DBUS_MethodContext *mc)
+{
+  struct GNUNET_DBUS_Object *object = mc->object;
+  struct GetRequest *get_request = GNUNET_DBUS_object_get_data (object);
+  struct GNUNET_DHT_GetHandle *handle = get_request->handle;
+
+  GNUNET_DHT_get_stop (handle);
+
+  struct GNUNET_DBUS_ObjectIterator *obj_it =
+      GNUNET_DBUS_object_iterate_subobjects (gbl_dht_get_object);
+  while (obj_it)
+  {
+    if (obj_it->object == object)
+    {
+      GNUNET_DBUS_object_remove_subobject (gbl_dht_get_object, obj_it);
+      break;
+    }
+    obj_it = obj_it->next;
+  };
+  if (obj_it)
+  {
+    GNUNET_DBUS_client_unref (get_request->client);
+    GNUNET_free (get_request);
+  }
+  else
+  {
+    LOG (GNUNET_ERROR_TYPE_WARNING,
+         "Tried to stop request that does not exist\n");
+    LOG (GNUNET_ERROR_TYPE_WARNING,
+         "  name == %s\n",
+           GNUNET_DBUS_object_get_name (object));
+  }
+
+  DBusMessage *reply = GNUNET_DBUS_method_context_create_reply (mc);
+  GNUNET_DBUS_method_context_send_reply (mc, reply);
+}
+
+static void
 get_iter_return (
     void *cls,
     struct GNUNET_TIME_Absolute expiry,
@@ -279,8 +319,6 @@
   DBusMessageIter iter;
   dbus_message_iter_init (message, &iter);
 
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "here qwe\n");
-
   DBusMessage *reply = NULL;
   reply = reply ? reply : GNUNET_BLOCK_DBUS_pop_type (
                               message, &iter,
@@ -298,7 +336,6 @@
                               message, &iter,
                               "options",
                               &options);
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "here asd\n");
   if (reply)
   {
     GNUNET_DBUS_method_context_send_reply (mc, reply);
@@ -306,7 +343,6 @@
   };
   //if (GNUNET_DBUS_message_get_pretty_encoded (message))
     //GNUNET_DBUS_client_set_prefers_pretty_encodings (mc->client, true);
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "here zxc\n");
 
   GNUNET_DBUS_method_context_ref (mc);
   struct ClientData *cd = GNUNET_DBUS_client_get_data (mc->client);
@@ -314,32 +350,28 @@
 
   struct GetRequest *get_request = GNUNET_new (struct GetRequest);
   get_request->client = mc->client;
+  GNUNET_DBUS_client_ref (mc->client);
   get_request->pretty = GNUNET_DBUS_message_get_pretty (message);
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "here rty\n");
 
   struct GNUNET_DBUS_Object *request_object = 
       GNUNET_DBUS_object_create_uniquely_named_subobject (gbl_dht_get_object,
                                                           get_request);
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "here passed rty\n");
   GNUNET_DBUS_object_add_interface (request_object,
                                     GNUNET_DBUS_interface_introspectable ());
   GNUNET_DBUS_object_add_interface (request_object,
                                     gbl_dht_get_request_interface);
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "here fgh\n");
 
   struct GNUNET_DBUS_ObjectPath *path = 
       GNUNET_DBUS_object_path_create (gbl_dht_service,
                                       gbl_dht_get_object,
                                       request_object,
                                       NULL);
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "here vbn\n");
 
   reply = GNUNET_DBUS_method_context_create_reply (mc);
   DBusMessageIter reply_iter;
   dbus_message_iter_init_append (reply, &reply_iter);
   GNUNET_DBUS_push_object_path (reply, &reply_iter, path);
   GNUNET_DBUS_method_context_send_reply (mc, reply);
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "here uio\n");
 
   struct GNUNET_DBUS_ObjectIterator *obj_it = 
       GNUNET_new (struct GNUNET_DBUS_ObjectIterator);
@@ -348,7 +380,6 @@
                                cd->gets_back,
                                obj_it);
 
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "here jkl\n");
   get_request->handle = GNUNET_DHT_get_start (
       handle,
       type,
@@ -359,7 +390,6 @@
       0,
       get_iter_return,
       request_object);
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "here m,.\n");
 };
 
 static void
@@ -507,6 +537,11 @@
                               GNUNET_DBUS_SIGNATURE_ARRAY (
                                   GNUNET_DBUS_SIGNATURE_HASHCODE));
 
+  gbl_dht_get_request_stop_method = GNUNET_DBUS_method_create ("stop",
+                                                               get_stop);
+  GNUNET_DBUS_interface_add_method (gbl_dht_get_request_interface,
+                                    gbl_dht_get_request_stop_method);
+
   gbl_dht_get_request_result_signal = GNUNET_DBUS_signal_create ("result");
   GNUNET_DBUS_interface_add_signal (gbl_dht_get_request_interface, 
                                     gbl_dht_get_request_result_signal);




reply via email to

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