From: Christian Grothoff Date: Fri, 7 Oct 2011 17:49:10 +0000 (+0000) Subject: LRN: Small janitor fixes X-Git-Tag: initial-import-from-subversion-38251~16701 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=23f103db87f8567814a1ec9ebdbb090e881ea32d;p=oweals%2Fgnunet.git LRN: Small janitor fixes * 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 --- diff --git a/contrib/gnunet_janitor.py.in b/contrib/gnunet_janitor.py.in index 52de8f9e9..c11ff4f12 100644 --- a/contrib/gnunet_janitor.py.in +++ b/contrib/gnunet_janitor.py.in @@ -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 ()) diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index 6b3ffe2af..ec54aece4 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h @@ -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 diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h index 4eddda41f..7419b44a2 100644 --- a/src/include/gnunet_core_service.h +++ b/src/include/gnunet_core_service.h @@ -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 diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c index ad74727bc..98c89d86a 100644 --- a/src/util/common_allocation.c +++ b/src/util/common_allocation.c @@ -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 */