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

pipe: simplify code by eliminating redundant variable

This commit is contained in:
Steffen Vogel 2017-07-01 20:45:45 +02:00
parent aa77c82b82
commit ce4fabb537

View file

@ -49,7 +49,6 @@ struct dir {
struct pool pool;
pthread_t thread;
bool enabled;
bool started;
} sendd, recvv;
bool reverse = false;
@ -60,13 +59,13 @@ pthread_t ptid; /**< Parent thread id */
static void quit(int signal, siginfo_t *sinfo, void *ctx)
{
if (recvv.started) {
if (recvv.enabled) {
pthread_cancel(recvv.thread);
pthread_join(recvv.thread, NULL);
pool_destroy(&recvv.pool);
}
if (sendd.started) {
if (sendd.enabled) {
pthread_cancel(sendd.thread);
pthread_join(sendd.thread, NULL);
pool_destroy(&sendd.pool);
@ -105,11 +104,6 @@ static void * send_loop(void *ctx)
int ret;
struct sample *smps[node->vectorize];
if (!sendd.enabled)
return NULL;
sendd.started = true;
/* Initialize memory */
ret = pool_init(&sendd.pool, LOG2_CEIL(node->vectorize), SAMPLE_LEN(DEFAULT_SAMPLELEN), &memtype_hugepage);
if (ret < 0)
@ -152,11 +146,6 @@ static void * recv_loop(void *ctx)
int ret;
struct sample *smps[node->vectorize];
if (!recvv.enabled)
return NULL;
recvv.started = true;
/* Initialize memory */
ret = pool_init(&recvv.pool, LOG2_CEIL(node->vectorize), SAMPLE_LEN(DEFAULT_SAMPLELEN), &memtype_hugepage);
if (ret < 0)
@ -264,8 +253,11 @@ int main(int argc, char *argv[])
error("Failed to start node: %s", node_name(node));
/* Start threads */
pthread_create(&recvv.thread, NULL, recv_loop, NULL);
pthread_create(&sendd.thread, NULL, send_loop, NULL);
if (recvv.enabled)
pthread_create(&recvv.thread, NULL, recv_loop, NULL);
if (sendd.enabled)
pthread_create(&sendd.thread, NULL, send_loop, NULL);
for (;;)
sleep(1);