diff --git a/server/include/path.h b/server/include/path.h index ce51ebd40..e113bc69a 100644 --- a/server/include/path.h +++ b/server/include/path.h @@ -81,7 +81,7 @@ void path_destroy(struct path *p); * * Start a new pthread for receiving/sending messages over this path. * - * @param p A pointer to the path struct + * @param p A pointer to the path structure. * @retval 0 Success. Everything went well. * @retval <0 Error. Something went wrong. */ @@ -89,7 +89,7 @@ int path_start(struct path *p); /** Stop a path. * - * @param p A pointer to the path struct + * @param p A pointer to the path structure. * @retval 0 Success. Everything went well. * @retval <0 Error. Something went wrong. */ @@ -97,12 +97,18 @@ int path_stop(struct path *p); /** Show some basic statistics for a path. * - * @param p A pointer to the path struct + * @param p A pointer to the path structure. */ -void path_stats(struct path *p); +void path_print_stats(struct path *p); +/** Fills the provided buffer with a string representation of the path. + * + * Format: source => [ dest1 dest2 dest3 ] + * + * @param p A pointer to the path structure. + * @param buf A pointer to the buffer which should be filled. + * @param len The length of buf in bytes. + */ int path_print(struct path *p, char *buf, int len); -int path_destroy(struct path *p); - #endif /* _PATH_H_ */ diff --git a/server/src/path.c b/server/src/path.c index 1cb8aea56..1db24ee0a 100644 --- a/server/src/path.c +++ b/server/src/path.c @@ -74,8 +74,6 @@ static void * path_run(void *arg) char buf[33]; struct path *p = arg; struct msg *m = alloc(sizeof(struct msg)); - if (!m) - error("Failed to allocate memory for message!"); /* Open deferred TCP connection */ node_start_defer(p->in); @@ -160,9 +158,9 @@ int path_start(struct path *p) /* At fixed rate mode, we start another thread for sending */ if (p->rate) - pthread_create(&p->sent_tid, NULL, &path_send, (void *) p); + pthread_create(&p->sent_tid, NULL, &path_send, p); - return pthread_create(&p->recv_tid, NULL, &path_run, (void *) p); + return pthread_create(&p->recv_tid, NULL, &path_run, p); } int path_stop(struct path *p) @@ -183,21 +181,20 @@ int path_stop(struct path *p) } if (p->sent || p->received) { - path_stats(p); + path_print_stats(p); hist_print(&p->histogram); } return 0; } -void path_stats(struct path *p) +void path_print_stats(struct path *p) { char buf[33]; path_print(p, buf, sizeof(buf)); - info("%-32s : %-8u %-8u %-8u %-8u %-8u", - buf, p->sent, p->received, p->dropped, p->skipped, p->invalid - ); + info("%-32s : %-8u %-8u %-8u %-8u %-8u", buf, + p->sent, p->received, p->dropped, p->skipped, p->invalid); } int path_print(struct path *p, char *buf, int len)