1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

more cleanups

This commit is contained in:
Steffen Vogel 2015-03-21 15:31:42 +01:00
parent b3d1fc8c45
commit 57081daa93
2 changed files with 18 additions and 15 deletions

View file

@ -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_ */

View file

@ -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)