diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-10-07 17:49:10 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-10-07 17:49:10 +0000 |
commit | 23f103db87f8567814a1ec9ebdbb090e881ea32d (patch) | |
tree | 7a3adf5c44cbb84148b4185101696ceb46909da2 | |
parent | 0663a057d7611270d5f41ae8b345125d737387f2 (diff) | |
download | gnunet-23f103db87f8567814a1ec9ebdbb090e881ea32d.tar.gz gnunet-23f103db87f8567814a1ec9ebdbb090e881ea32d.zip |
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
-rw-r--r-- | contrib/gnunet_janitor.py.in | 16 | ||||
-rw-r--r-- | src/include/gnunet_common.h | 9 | ||||
-rw-r--r-- | src/include/gnunet_core_service.h | 13 | ||||
-rw-r--r-- | src/util/common_allocation.c | 21 |
4 files changed, 49 insertions, 10 deletions
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 (): | |||
55 | gnunet_procs.append (p) | 55 | gnunet_procs.append (p) |
56 | for p in gnunet_procs: | 56 | for p in gnunet_procs: |
57 | if re.match (r'gnunet-service-arm', p[1]): | 57 | if re.match (r'gnunet-service-arm', p[1]): |
58 | print ("killing arm {0:5} {1}".format (p[0], p[1])) | 58 | print ("killing arm process {0:5} {1}".format (p[0], p[1])) |
59 | os.kill (p[0], signal.SIGTERM) | 59 | try: |
60 | os.kill (p[0], signal.SIGTERM) | ||
61 | except OSError as e: | ||
62 | print ("failed: {0}".format (e)) | ||
63 | pass | ||
60 | for p in gnunet_procs: | 64 | for p in gnunet_procs: |
61 | if not re.match (r'gnunet-service-arm', p[1]): | 65 | if not re.match (r'gnunet-service-arm', p[1]): |
62 | print ("killing arm {0:5} {1}".format (p[0], p[1])) | 66 | print ("killing non-arm process {0:5} {1}".format (p[0], p[1])) |
63 | os.kill (p[0], signal.SIGTERM) | 67 | try: |
68 | os.kill (p[0], signal.SIGTERM) | ||
69 | except OSError as e: | ||
70 | print ("failed: {0}".format (e)) | ||
71 | pass | ||
64 | 72 | ||
65 | if __name__ == '__main__': | 73 | if __name__ == '__main__': |
66 | sys.exit (main ()) | 74 | 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 * | |||
569 | GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber); | 569 | GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber); |
570 | 570 | ||
571 | 571 | ||
572 | |||
573 | /** | 572 | /** |
574 | * Allocate and initialize memory. Checks the return value, aborts if no more | 573 | * Allocate and initialize memory. Checks the return value, aborts if no more |
575 | * memory is available. Don't use GNUNET_xmemdup_ directly. Use the | 574 | * 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, | |||
664 | unsigned int newCount, const char *filename, int linenumber); | 663 | unsigned int newCount, const char *filename, int linenumber); |
665 | 664 | ||
666 | 665 | ||
666 | /** | ||
667 | * Create a copy of the given message. | ||
668 | * | ||
669 | * @param msg message to copy | ||
670 | * @return duplicate of the message | ||
671 | */ | ||
672 | struct GNUNET_MessageHeader * | ||
673 | GNUNET_copy_message (const struct GNUNET_MessageHeader *msg); | ||
667 | 674 | ||
668 | 675 | ||
669 | #if __STDC_VERSION__ < 199901L | 676 | #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; | |||
281 | * @param info function to call with the resulting configuration information | 281 | * @param info function to call with the resulting configuration information |
282 | * @param info_cls closure for info | 282 | * @param info_cls closure for info |
283 | * @return NULL on error | 283 | * @return NULL on error |
284 | * @deprecated will be replaced soon | ||
284 | */ | 285 | */ |
285 | struct GNUNET_CORE_InformationRequestContext * | 286 | struct GNUNET_CORE_InformationRequestContext * |
286 | GNUNET_CORE_peer_change_preference (struct GNUNET_CORE_Handle *h, | 287 | GNUNET_CORE_peer_change_preference (struct GNUNET_CORE_Handle *h, |
@@ -300,6 +301,7 @@ GNUNET_CORE_peer_change_preference (struct GNUNET_CORE_Handle *h, | |||
300 | * from the original request will no longer be called. | 301 | * from the original request will no longer be called. |
301 | * | 302 | * |
302 | * @param irc context returned by the original GNUNET_CORE_peer_get_info call | 303 | * @param irc context returned by the original GNUNET_CORE_peer_get_info call |
304 | * @deprecated will be replaced soon | ||
303 | */ | 305 | */ |
304 | void | 306 | void |
305 | GNUNET_CORE_peer_change_preference_cancel (struct | 307 | GNUNET_CORE_peer_change_preference_cancel (struct |
@@ -308,7 +310,9 @@ GNUNET_CORE_peer_change_preference_cancel (struct | |||
308 | 310 | ||
309 | 311 | ||
310 | /** | 312 | /** |
311 | * Iterate over all connected peers. | 313 | * Iterate over all connected peers. Calls peer_cb with each |
314 | * connected peer, and then once with NULL to indicate that all peers | ||
315 | * have been handled. | ||
312 | * | 316 | * |
313 | * @param cfg configuration handle | 317 | * @param cfg configuration handle |
314 | * @param peer_cb function to call with the peer information | 318 | * @param peer_cb function to call with the peer information |
@@ -320,11 +324,10 @@ GNUNET_CORE_iterate_peers (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
320 | GNUNET_CORE_ConnectEventHandler peer_cb, | 324 | GNUNET_CORE_ConnectEventHandler peer_cb, |
321 | void *cb_cls); | 325 | void *cb_cls); |
322 | 326 | ||
327 | |||
323 | /** | 328 | /** |
324 | * Iterate over all currently connected peers. | 329 | * Check if the given peer is currently connected and return information |
325 | * Calls peer_cb with each connected peer, and then | 330 | * about the session if so. |
326 | * once with NULL to indicate that all peers have | ||
327 | * been handled. | ||
328 | * | 331 | * |
329 | * @param cfg configuration to use | 332 | * @param cfg configuration to use |
330 | * @param peer the specific peer to check for | 333 | * @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, ...) | |||
332 | return ret; | 332 | return ret; |
333 | } | 333 | } |
334 | 334 | ||
335 | |||
336 | /** | ||
337 | * Create a copy of the given message. | ||
338 | * | ||
339 | * @param msg message to copy | ||
340 | * @return duplicate of the message | ||
341 | */ | ||
342 | struct GNUNET_MessageHeader * | ||
343 | GNUNET_copy_message (const struct GNUNET_MessageHeader *msg) | ||
344 | { | ||
345 | struct GNUNET_MessageHeader *ret; | ||
346 | uint16_t msize; | ||
347 | |||
348 | msize = ntohs (msg->size); | ||
349 | GNUNET_assert (msize >= sizeof (struct GNUNET_MessageHeader)); | ||
350 | ret = GNUNET_malloc (msize); | ||
351 | memcpy (ret, msg, msize); | ||
352 | return ret; | ||
353 | } | ||
354 | |||
355 | |||
335 | /* end of common_allocation.c */ | 356 | /* end of common_allocation.c */ |