diff --git a/Dockerfile b/Dockerfile index 1db73caf9..c0f627d8d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,9 @@ FROM stv0g/dotfiles #FROM debian:jessie -MAINTAINER "Steffen Vogel +MAINTAINER Steffen Vogel + +EXPOSE 80 # Update package manager RUN apt-get update @@ -21,6 +23,7 @@ RUN apt-get -y install \ gcc \ gdb \ make \ + cmake \ libc6-dev \ pkg-config @@ -32,6 +35,7 @@ RUN apt-get -y install \ libpci-dev \ libjansson-dev \ libcurl4-openssl-dev \ + libssl-dev \ uuid-dev # Install dependencies for 32bit x86 arch (required for 32bit libOpalAsync) diff --git a/lib/list.c b/lib/list.c index 84fd4a252..d42674481 100644 --- a/lib/list.c +++ b/lib/list.c @@ -63,30 +63,15 @@ void list_push(struct list *l, void *p) pthread_mutex_unlock(&l->lock); } -void * list_lookup(struct list *l, const char *name) +void * list_lookup(struct list *l, const char *needle) { - int cmp(const void *a, const void *b) { - return strcmp(*(char **) a, b); + int cmp(const void *elm, const void *needle) { + char *name = * (char **) elm; /* Ugly hack: the lookup key (name) must be the first element in the list element struct */ + + return strcmp(name, needle); } - return list_search(l, cmp, (void *) name); -} - -int list_count(struct list *l, cmp_cb_t cmp, void *ctx) -{ - int c = 0; - - pthread_mutex_lock(&l->lock); - - void *e; - list_foreach(e, l) { - if (!cmp(e, ctx)) - c++; - } - - pthread_mutex_unlock(&l->lock); - - return c; + return list_search(l, cmp, (void *) needle); } int list_contains(struct list *l, void *p) @@ -98,6 +83,22 @@ int list_contains(struct list *l, void *p) return list_count(l, cmp, p); } +int list_count(struct list *l, cmp_cb_t cmp, void *ctx) +{ + int c = 0; + + pthread_mutex_lock(&l->lock); + + list_foreach(void *e, l) { + if (!cmp(e, ctx)) + c++; + } + + pthread_mutex_unlock(&l->lock); + + return c; +} + void * list_search(struct list *l, cmp_cb_t cmp, void *ctx) { pthread_mutex_lock(&l->lock); diff --git a/lib/node.c b/lib/node.c index 483dbaea0..88788ab36 100644 --- a/lib/node.c +++ b/lib/node.c @@ -28,28 +28,19 @@ int node_read(struct node *n, struct msg *p, int ps, int f, int c) int node_write(struct node *n, struct msg *p, int ps, int f, int c) { return n->_vt->write ? n->_vt->write(n, p, ps, f, c) : -1; -} - -int node_open(struct node *n) -{ - return n->_vt->open ? n->_vt->open(n) : -1; -} -int node_close(struct node *n) -{ - return n->_vt->close ? n->_vt->close(n) : -1; } int node_init(int argc, char *argv[], struct settings *set) { INDENT list_foreach(const struct node_type *vt, &node_types) { if (list_length(&vt->instances) > 0) { - info("Initializing '%s' node type", vt->name); + info("Initializing " YEL("%s") " node type", vt->name); if (vt->init) vt->init(argc, argv, set); } else - warn("No node is using the '%s' type. Skipping...", vt->name); + warn("No node is using the " YEL("%s") " node type. Skipping...", vt->name); } return 0; @@ -60,7 +51,7 @@ int node_deinit() /* De-initialize node types */ list_foreach(const struct node_type *vt, &node_types) { if (list_length(&vt->instances) > 0) { - info("De-initializing '%s' node type", vt->name); + info("De-initializing " YEL("%s") " node type", vt->name); if (vt->deinit) vt->deinit(); @@ -76,7 +67,7 @@ int node_start(struct node *n) info("Starting node %s", node_name_long(n)); { INDENT - ret = node_open(n); + ret = n->_vt->open ? n->_vt->open(n) : -1; } if (ret == 0) @@ -95,7 +86,7 @@ int node_stop(struct node *n) info("Stopping node %s", node_name(n)); { INDENT - ret = node_close(n); + ret = n->_vt->close ? n->_vt->close(n) : -1; } if (ret == 0) @@ -107,7 +98,7 @@ int node_stop(struct node *n) const char * node_name(struct node *n) { if (!n->_name) - strcatf(&n->_name, YEL("%s") GRY("(%s)"), n->name, n->_vt->name); + strcatf(&n->_name, RED("%s") "(" YEL("%s") ")", n->name, n->_vt->name); return n->_name; } diff --git a/src/pipe.c b/src/pipe.c index c2b92c13b..d3f517a26 100644 --- a/src/pipe.c +++ b/src/pipe.c @@ -110,6 +110,7 @@ void * recv_loop(void *ctx) /** @todo should we drop reordered / delayed packets here? */ msg_fprint(stdout, m, MSG_PRINT_ALL, time_delta(&MSG_TS(m), &ts)); + fflush(stdout); } } diff --git a/src/server.c b/src/server.c index 1eca072e6..499afb04a 100644 --- a/src/server.c +++ b/src/server.c @@ -162,7 +162,7 @@ int main(int argc, char *argv[]) } int refs = list_count(&paths, (cmp_cb_t) used_by_path, n); - if (refs) + if (refs > 0) node_start(n); else warn("Node %s is unused. Skipping...", node_name(n));