LRN: Small janitor fixes
authorChristian Grothoff <christian@grothoff.org>
Fri, 7 Oct 2011 17:49:10 +0000 (17:49 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 7 Oct 2011 17:49:10 +0000 (17:49 +0000)
* Prevent janitor from failing if a process can't be killed (it might be dead
  by the time janitor gets around to killing it).
* Fix janitor messages about killing arm/non-arm processes

contrib/gnunet_janitor.py.in
src/include/gnunet_common.h
src/include/gnunet_core_service.h
src/util/common_allocation.c

index 52de8f9e91cc7fcb65f43139e419875b824b4fa6..c11ff4f122c9924d27b6516e2807fa159ed7c60f 100644 (file)
@@ -55,12 +55,20 @@ def main ():
       gnunet_procs.append (p)
   for p in gnunet_procs:
     if re.match (r'gnunet-service-arm', p[1]):
-      print ("killing arm {0:5} {1}".format (p[0], p[1]))
-      os.kill (p[0], signal.SIGTERM)
+      print ("killing arm process {0:5} {1}".format (p[0], p[1]))
+      try:
+        os.kill (p[0], signal.SIGTERM)
+      except OSError as e:
+        print ("failed: {0}".format (e))
+        pass
   for p in gnunet_procs:
     if not re.match (r'gnunet-service-arm', p[1]):
-      print ("killing arm {0:5} {1}".format (p[0], p[1]))
-      os.kill (p[0], signal.SIGTERM)
+      print ("killing non-arm process {0:5} {1}".format (p[0], p[1]))
+      try:
+        os.kill (p[0], signal.SIGTERM)
+      except OSError as e:
+        print ("failed: {0}".format (e))
+        pass
 
 if __name__ == '__main__':
   sys.exit (main ())
index 6b3ffe2afcdf01b79b20c3dbc8bd7a21e7bc68ec..ec54aece4c2597160d292232ef19b2adca1c4c9e 100644 (file)
@@ -569,7 +569,6 @@ void *
 GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber);
 
 
-
 /**
  * Allocate and initialize memory. Checks the return value, aborts if no more
  * memory is available.  Don't use GNUNET_xmemdup_ directly. Use the
@@ -664,6 +663,14 @@ GNUNET_xgrow_ (void **old, size_t elementSize, unsigned int *oldCount,
                unsigned int newCount, const char *filename, int linenumber);
 
 
+/**
+ * Create a copy of the given message.
+ *
+ * @param msg message to copy
+ * @return duplicate of the message
+ */
+struct GNUNET_MessageHeader *
+GNUNET_copy_message (const struct GNUNET_MessageHeader *msg);
 
 
 #if __STDC_VERSION__ < 199901L
index 4eddda41f5333fcae812f6a43c5f979e12e1f8e5..7419b44a236591fe96e7808d6d36c6491cca9c7e 100644 (file)
@@ -281,6 +281,7 @@ struct GNUNET_CORE_InformationRequestContext;
  * @param info function to call with the resulting configuration information
  * @param info_cls closure for info
  * @return NULL on error
+ * @deprecated will be replaced soon
  */
 struct GNUNET_CORE_InformationRequestContext *
 GNUNET_CORE_peer_change_preference (struct GNUNET_CORE_Handle *h,
@@ -300,6 +301,7 @@ GNUNET_CORE_peer_change_preference (struct GNUNET_CORE_Handle *h,
  * from the original request will no longer be called.
  *
  * @param irc context returned by the original GNUNET_CORE_peer_get_info call
+ * @deprecated will be replaced soon
  */
 void
 GNUNET_CORE_peer_change_preference_cancel (struct
@@ -308,7 +310,9 @@ GNUNET_CORE_peer_change_preference_cancel (struct
 
 
 /**
- * Iterate over all connected peers.
+ * Iterate over all connected peers.  Calls peer_cb with each
+ * connected peer, and then once with NULL to indicate that all peers
+ * have been handled.
  *
  * @param cfg configuration handle
  * @param peer_cb function to call with the peer information
@@ -320,11 +324,10 @@ GNUNET_CORE_iterate_peers (const struct GNUNET_CONFIGURATION_Handle *cfg,
                            GNUNET_CORE_ConnectEventHandler peer_cb,
                            void *cb_cls);
 
+
 /**
- * Iterate over all currently connected peers.
- * Calls peer_cb with each connected peer, and then
- * once with NULL to indicate that all peers have
- * been handled.
+ * Check if the given peer is currently connected and return information
+ * about the session if so.
  *
  * @param cfg configuration to use
  * @param peer the specific peer to check for
index ad74727bc89d1aab4c05aa54c460778db9822542..98c89d86a6b52ddf265694f12a27e1864ca43cbb 100644 (file)
@@ -332,4 +332,25 @@ GNUNET_snprintf (char *buf, size_t size, const char *format, ...)
   return ret;
 }
 
+
+/**
+ * Create a copy of the given message.
+ *
+ * @param msg message to copy
+ * @return duplicate of the message
+ */
+struct GNUNET_MessageHeader *
+GNUNET_copy_message (const struct GNUNET_MessageHeader *msg)
+{
+  struct GNUNET_MessageHeader *ret;
+  uint16_t msize;
+
+  msize = ntohs (msg->size);
+  GNUNET_assert (msize >= sizeof (struct GNUNET_MessageHeader));
+  ret = GNUNET_malloc (msize);
+  memcpy (ret, msg, msize);
+  return ret;
+}
+
+
 /* end of common_allocation.c */