gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r4912 - in GNUnet: . src/applications/fs/namespace src/incl


From: gnunet
Subject: [GNUnet-SVN] r4912 - in GNUnet: . src/applications/fs/namespace src/include src/util/network
Date: Sun, 3 Jun 2007 16:13:33 -0600 (MDT)

Author: grothoff
Date: 2007-06-03 16:13:33 -0600 (Sun, 03 Jun 2007)
New Revision: 4912

Modified:
   GNUnet/src/applications/fs/namespace/namespace_info.c
   GNUnet/src/include/gnunet_namespace_lib.h
   GNUnet/src/include/gnunet_util_string.h
   GNUnet/src/util/network/select.c
   GNUnet/todo
Log:
adding notification for namespace discovery/creation

Modified: GNUnet/src/applications/fs/namespace/namespace_info.c
===================================================================
--- GNUnet/src/applications/fs/namespace/namespace_info.c       2007-06-03 
21:18:21 UTC (rev 4911)
+++ GNUnet/src/applications/fs/namespace/namespace_info.c       2007-06-03 
22:13:33 UTC (rev 4912)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet
-     (C) 2003, 2004, 2005, 2006 Christian Grothoff (and other contributing 
authors)
+     (C) 2003, 2004, 2005, 2006, 2007 Christian Grothoff (and other 
contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -36,6 +36,41 @@
 #define NS_UPDATE_DIR "data" DIR_SEPARATOR_STR "namespace-updates" 
DIR_SEPARATOR_STR
 #define NS_ROOTS "data" DIR_SEPARATOR_STR "namespace-root" DIR_SEPARATOR_STR
 
+struct DiscoveryCallback {
+  struct DiscoveryCallback * next;
+  NS_NamespaceIterator callback;
+  void * closure;
+  int local;
+};
+
+static struct DiscoveryCallback * head;
+
+static struct MUTEX * lock;
+
+/**
+ * Internal notification about new tracked URI.
+ */
+static void internal_notify(const char * name,
+                           const HashCode512 * id,
+                           const struct ECRS_MetaData * md,
+                           int rating,
+                           int local) {
+  struct DiscoveryCallback * pos;
+
+  MUTEX_LOCK(lock);
+  pos = head;
+  while (pos != NULL) {
+    if (pos->local == local)
+      pos->callback(pos->closure,
+                   name,
+                   id,
+                   md,
+                   rating);
+    pos = pos->next;
+  }
+  MUTEX_UNLOCK(lock);
+}
+
 static void writeNamespaceInfo(struct GE_Context * ectx,
                               struct GC_Configuration * cfg,
                               const char * namespaceName,
@@ -206,6 +241,11 @@
                       name,
                       meta,
                       0);
+    internal_notify(namespaceName,
+                   &id,
+                   meta,
+                   0,
+                   YES);
     FREE(name);
   }
   return ret;
@@ -939,6 +979,11 @@
                       ranking);
     ECRS_freeMetaData(old);
   } else {
+    internal_notify(name,
+                   &id,
+                   meta,
+                   ranking,
+                   NO);
     writeNamespaceInfo(ectx,
                       cfg,
                       name,
@@ -989,5 +1034,72 @@
   return ret;
 }
 
+/**
+ * Register callback to be invoked whenever we discover
+ * a new namespace.
+ */
+int NS_registerDiscoveryCallback(struct GE_Context * ectx,
+                                struct GC_Configuration * cfg,
+                                int local,
+                                NS_NamespaceIterator iterator,
+                                void * closure) {
+  struct DiscoveryCallback * list;
+  
+  list = MALLOC(sizeof(struct DiscoveryCallback));
+  list->callback = iterator;
+  list->closure = closure;
+  list->local = local;
+  MUTEX_LOCK(lock);
+  list->next = head;
+  head = list;
+  NS_listNamespaces(ectx,
+                   cfg,
+                   local,
+                   iterator,
+                   closure);
+  MUTEX_UNLOCK(lock);
+  return OK;
+}
 
+/**
+ * Unregister namespace discovery callback.
+ */
+int NS_unregisterDiscoveryCallback(NS_NamespaceIterator iterator,
+                                  void * closure) {
+  struct DiscoveryCallback * prev;
+  struct DiscoveryCallback * pos;
+
+  prev = NULL;
+  MUTEX_LOCK(lock);
+  pos = head;
+  while ( (pos != NULL) &&
+         ( (pos->callback != iterator) ||
+           (pos->closure != closure) ) ) {
+    prev = pos;
+    pos = pos->next;
+  }
+  if (pos == NULL) {
+    MUTEX_UNLOCK(lock);
+    return SYSERR;
+  }
+  if (prev == NULL)
+    head = pos->next;
+  else
+    prev->next = pos->next;
+  FREE(pos);
+  MUTEX_UNLOCK(lock);
+  return OK;
+}
+
+
+void __attribute__ ((constructor)) gnunet_namespace_ltdl_init() {
+  lock = MUTEX_CREATE(NO);
+}
+
+void __attribute__ ((destructor)) gnunet_namespace_ltdl_fini() {
+  MUTEX_DESTROY(lock);
+  lock = NULL;
+}
+
+
 /* end of namespace_info.c */

Modified: GNUnet/src/include/gnunet_namespace_lib.h
===================================================================
--- GNUnet/src/include/gnunet_namespace_lib.h   2007-06-03 21:18:21 UTC (rev 
4911)
+++ GNUnet/src/include/gnunet_namespace_lib.h   2007-06-03 22:13:33 UTC (rev 
4912)
@@ -111,8 +111,8 @@
 
 /**
  * Add a namespace to the set of known namespaces.  For all namespace
- * advertisements that we discover NS should automatically call this
- * function.
+ * advertisements that we discover this function should be
+ * callled.
  *
  * @param ns the namespace identifier
  */
@@ -139,12 +139,29 @@
  *   non-local known namespaces are listed)
  */
 int NS_listNamespaces(struct GE_Context * ectx,
-                       struct GC_Configuration * cfg,
-                       int local,
-                       NS_NamespaceIterator iterator,
-                       void * closure); /* namespace_info.c */
+                     struct GC_Configuration * cfg,
+                     int local,
+                     NS_NamespaceIterator iterator,
+                     void * closure); /* namespace_info.c */
+/**
+ * Register callback to be invoked whenever we discover
+ * a new namespace.
+ */
+int NS_registerDiscoveryCallback(struct GE_Context * ectx,
+                                struct GC_Configuration * cfg,
+                                int local,
+                                NS_NamespaceIterator iterator,
+                                void * closure);
 
 /**
+ * Unregister namespace discovery callback.
+ */
+int NS_unregisterDiscoveryCallback(NS_NamespaceIterator iterator,
+                                  void * closure);
+
+
+
+/**
  * Add an entry into a namespace (also for publishing
  * updates).  Typical uses are (all others would be odd):
  * <ul>

Modified: GNUnet/src/include/gnunet_util_string.h
===================================================================
--- GNUnet/src/include/gnunet_util_string.h     2007-06-03 21:18:21 UTC (rev 
4911)
+++ GNUnet/src/include/gnunet_util_string.h     2007-06-03 22:13:33 UTC (rev 
4912)
@@ -168,6 +168,7 @@
 
 /**
  * Give relative time in human-readable fancy format.
+ * @param delta time in milli seconds
  */
 char * string_get_fancy_time_interval(unsigned long long delta);
 

Modified: GNUnet/src/util/network/select.c
===================================================================
--- GNUnet/src/util/network/select.c    2007-06-03 21:18:21 UTC (rev 4911)
+++ GNUnet/src/util/network/select.c    2007-06-03 22:13:33 UTC (rev 4912)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2003, 2006 Christian Grothoff (and other contributing authors)
+     (C) 2003, 2006, 2007 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published

Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2007-06-03 21:18:21 UTC (rev 4911)
+++ GNUnet/todo 2007-06-03 22:13:33 UTC (rev 4912)
@@ -1,26 +1,18 @@
-notes:
-  RC == Release Critical 
+This is just the current plan, plans change.
 
-  All issues that are targeted for the NEXT release
-  should also be filed on Mantis, except for "more testcases"
-  which is always an ongoing issue. 
+Annotations:
+  RC == Release Critical
 
-  Features that are targeted for future releases do not have
-  to be filed on Mantis (no need to bloat the database).
 
-  Oh, and this is of course just a plan.  And plans always change.
-
-
 0.7.2 [5'07]:
 - new features:
   * HTTP transport (libcurl, libmicrohttpd) [#765] [likely 0.7.2a]
 - RC bugs:
-  * UDP assertion failure (mtu < size)
-  * gethostbyaddr crash (stack overflow? non-reentrant?)
-  * low connectivity (NAT?)
+  * UDP assertion failure (mtu < size) [#1209]
+  * low connectivity (NAT? real issue?)
 
 0.7.3 [7'07] (aka "features"):
-- Chat support basics [RC]
+- chat support basics [RC]
 - insert meta-data under hash (md5? sha1? sha-512? GNUnet-URI?)
   as keyword (to allow getting meta-data from URI only) [RC]
 - old/new features:





reply via email to

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