mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
some cleanup and cosmetic changes
git-svn-id: https://zerberus.eonerc.rwth-aachen.de:8443/svn/s2ss/trunk@77 8ec27952-4edc-4aab-86aa-e87bb2611832
This commit is contained in:
parent
dbc91f474a
commit
726aa5545c
5 changed files with 32 additions and 25 deletions
|
@ -44,6 +44,9 @@ struct node
|
|||
/** The socket descriptor */
|
||||
int sd;
|
||||
|
||||
/** A short identifier of the node */
|
||||
const char *name;
|
||||
|
||||
/** The type of this node */
|
||||
enum node_type type;
|
||||
|
||||
|
@ -59,9 +62,6 @@ struct node
|
|||
/** Socket mark for netem, routing and filtering */
|
||||
int mark;
|
||||
|
||||
/** A short identifier of the node */
|
||||
const char *name;
|
||||
|
||||
/** A pointer to the libconfig object which instantiated this node */
|
||||
config_setting_t *cfg;
|
||||
|
||||
|
@ -69,7 +69,7 @@ struct node
|
|||
struct node *next;
|
||||
};
|
||||
|
||||
/** Connect and bind the UDP socket of this node
|
||||
/** Connect and bind the UDP socket of this node.
|
||||
*
|
||||
* @param n A pointer to the node structure
|
||||
* @return
|
||||
|
|
|
@ -24,19 +24,14 @@
|
|||
#define CYN(str) "\x1B[36m" str "\x1B[0m"
|
||||
#define WHT(str) "\x1B[37m" str "\x1B[0m"
|
||||
|
||||
/** The log level which is passed as first argument to print() */
|
||||
enum log_level { DEBUG, INFO, WARN, ERROR };
|
||||
|
||||
/* Forward declarations */
|
||||
struct settings;
|
||||
struct sockaddr_in;
|
||||
struct sockaddr;
|
||||
|
||||
/** The log level which is passed as first argument to print() */
|
||||
enum log_level
|
||||
{
|
||||
DEBUG,
|
||||
INFO,
|
||||
WARN,
|
||||
ERROR
|
||||
};
|
||||
|
||||
/** Logs variadic messages to stdout.
|
||||
*
|
||||
* @param lvl The log level
|
||||
|
@ -73,7 +68,7 @@ int sockaddr_cmp(struct sockaddr *a, struct sockaddr *b);
|
|||
* @param set A cpu bitmask
|
||||
* @return The opaque cpu_set_t datatype
|
||||
*/
|
||||
cpu_set_t to_cpu_set_t(int set);
|
||||
cpu_set_t to_cpu_set(int set);
|
||||
|
||||
/** Append an element to a single linked list */
|
||||
#define list_add(list, elm) do { \
|
||||
|
|
|
@ -123,8 +123,6 @@ int config_parse_path(config_setting_t *cfg,
|
|||
if (!config_setting_lookup_string(cfg, "out", &out_str))
|
||||
cerror(cfg, "Missing output node for path");
|
||||
|
||||
info("Loading path from '%s' to '%s'", in_str, out_str);
|
||||
|
||||
path->in = node_lookup_name(in_str, nodes);
|
||||
if (!path->in)
|
||||
cerror(cfg, "Invalid input node '%s'");
|
||||
|
@ -135,6 +133,8 @@ int config_parse_path(config_setting_t *cfg,
|
|||
|
||||
path->cfg = cfg;
|
||||
|
||||
debug(3, "Loaded path from '%s' to '%s'", path->in->name, path->out->name);
|
||||
|
||||
if (enabled) {
|
||||
list_add(*paths, path);
|
||||
|
||||
|
|
24
src/server.c
24
src/server.c
|
@ -45,8 +45,18 @@ static void start()
|
|||
for (struct node *n = nodes; n; n = n->next) {
|
||||
node_connect(n);
|
||||
|
||||
debug(1, " We listen for node '%s' at %s:%u", n->name, inet_ntoa(n->local.sin_addr), ntohs(n->local.sin_port));
|
||||
debug(1, " We sent to node '%s' at %s:%u", n->name, inet_ntoa(n->remote.sin_addr), ntohs(n->remote.sin_port));
|
||||
/* Create queueing discipline */
|
||||
if (n->netem && n->interface->index != 1) {
|
||||
tc_mark(n->interface, TC_HDL(4000, n->mark), n->mark);
|
||||
tc_netem(n->interface, TC_HDL(4000, n->mark), n->netem);
|
||||
}
|
||||
|
||||
debug(1, " We listen for node '%s' at %s:%u",
|
||||
n->name, inet_ntoa(n->local.sin_addr),
|
||||
ntohs(n->local.sin_port));
|
||||
debug(1, " We sent to node '%s' at %s:%u",
|
||||
n->name, inet_ntoa(n->remote.sin_addr),
|
||||
ntohs(n->remote.sin_port));
|
||||
}
|
||||
|
||||
/* Start on thread per path for asynchronous processing */
|
||||
|
@ -66,12 +76,13 @@ static void stop()
|
|||
|
||||
info("Stopping path: %12s " RED("=>") " %s " RED("=>") " %-12s",
|
||||
p->in->name, settings.name, p->out->name);
|
||||
|
||||
info(" %u messages received", p->received);
|
||||
info(" %u messages duplicated", p->duplicated);
|
||||
info(" %u messages delayed", p->delayed);
|
||||
}
|
||||
|
||||
/* Close all sockets we listing on */
|
||||
/* Close all sockets we listen on */
|
||||
for (struct node *n = nodes; n; n = n->next) {
|
||||
node_disconnect(n);
|
||||
}
|
||||
|
@ -136,10 +147,9 @@ int main(int argc, char *argv[])
|
|||
debug(3, "Set task priority to %u", settings.priority);
|
||||
|
||||
/* Pin threads to CPUs by setting the affinity */
|
||||
cpu_set_t cset = to_cpu_set_t(settings.affinity);
|
||||
pid_t pid = getpid();
|
||||
if (sched_setaffinity(pid, sizeof(cset), &cset))
|
||||
perror("Failed to set CPU affinity");
|
||||
cpu_set_t cset = to_cpu_set(settings.affinity);
|
||||
if (sched_setaffinity(0, sizeof(cset), &cset))
|
||||
perror("Failed to set CPU affinity to '%#x'", settings.affinity);
|
||||
else
|
||||
debug(3, "Set affinity to %#x", settings.affinity);
|
||||
|
||||
|
|
|
@ -104,11 +104,13 @@ int sockaddr_cmp(struct sockaddr *a, struct sockaddr *b)
|
|||
return -1;
|
||||
}
|
||||
|
||||
cpu_set_t to_cpu_set_t(int set)
|
||||
cpu_set_t to_cpu_set(int set)
|
||||
{
|
||||
cpu_set_t cset;
|
||||
|
||||
for (int i = 0; i < sizeof(int) * 8; i++) {
|
||||
CPU_ZERO(&cset);
|
||||
|
||||
for (int i = 0; i < sizeof(set) * 8; i++) {
|
||||
if (set & (1L << i))
|
||||
CPU_SET(i, &cset);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue