From 78f2c519b11bb16a53f5a122c7548ddcbeedef4a Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Fri, 18 Jul 2014 16:05:44 +0000 Subject: [PATCH] changed memory type of path message git-svn-id: https://zerberus.eonerc.rwth-aachen.de:8443/svn/s2ss/trunk@164 8ec27952-4edc-4aab-86aa-e87bb2611832 --- server/src/path.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/server/src/path.c b/server/src/path.c index 02ce22663..45e9f352b 100644 --- a/server/src/path.c +++ b/server/src/path.c @@ -65,26 +65,29 @@ static void * path_send(void *arg) static void * path_run(void *arg) { struct path *p = (struct path *) arg; - struct msg m; + struct msg *m = malloc(sizeof(struct msg)); + + if (!m) + error("Failed to allocate memory!"); /* Main thread loop */ while (1) { - msg_recv(&m, p->in); /* Receive message */ + msg_recv(m, p->in); /* Receive message */ p->received++; /** Check header fields */ - if (m.version != MSG_VERSION) { + if (m->version != MSG_VERSION) { p->invalid++; continue; } - if (m.type != MSG_TYPE_DATA) { + if (m->type != MSG_TYPE_DATA) { p->invalid++; continue; } /* Check sequence number */ - if (m.sequence <= 1) { + if (m->sequence <= 1) { path_stats(p); info("Simulation started"); @@ -96,30 +99,32 @@ static void * path_run(void *arg) p->duplicated = 0; p->invalid = 0; } - else if (m.sequence < p->sequence) { + else if (m->sequence < p->sequence) { p->delayed++; continue; } - else if (m.sequence == p->sequence) { + else if (m->sequence == p->sequence) { p->duplicated++; continue; } - if (p->hook && p->hook(&m)) { + if (p->hook && p->hook(m)) { p->skipped++; continue; } /* At fixed rate mode, messages are send by another thread */ if (p->rate) - p->last = &m; + p->last = m; else - msg_send(&m, p->out); + msg_send(m, p->out); - p->sequence = m.sequence; + p->sequence = m->sequence; p->sent++; } + free(m); + return NULL; }