summaryrefslogtreecommitdiff
path: root/src/irmd/irm_flow.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/irmd/irm_flow.c')
-rw-r--r--src/irmd/irm_flow.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/irmd/irm_flow.c b/src/irmd/irm_flow.c
index a228db06..2456f1e2 100644
--- a/src/irmd/irm_flow.c
+++ b/src/irmd/irm_flow.c
@@ -20,7 +20,10 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#define OUROBOROS_PREFIX "irm_flow"
+
#include <ouroboros/config.h>
+#include <ouroboros/logs.h>
#include "irm_flow.h"
@@ -28,20 +31,12 @@
#include <stdbool.h>
#include <assert.h>
-struct irm_flow * irm_flow_create()
+struct irm_flow * irm_flow_create(pid_t n_api, pid_t n_1_api, int port_id)
{
struct irm_flow * f = malloc(sizeof(*f));
if (f == NULL)
return NULL;
- f->n_api = -1;
- f->n_1_api = -1;
- f->port_id = -1;
- f->n_rb = NULL;
- f->n_1_rb = NULL;
-
- f->state = FLOW_NULL;
-
if (pthread_cond_init(&f->state_cond, NULL)) {
free(f);
return NULL;
@@ -52,8 +47,29 @@ struct irm_flow * irm_flow_create()
return NULL;
}
- f->t0.tv_sec = 0;
- f->t0.tv_nsec = 0;
+
+ f->n_api = n_api;
+ f->n_1_api = n_1_api;
+ f->port_id = port_id;
+
+ f->n_rb = shm_rbuff_create(n_api, port_id);
+ if (f->n_rb == NULL) {
+ LOG_ERR("Could not create ringbuffer for AP-I %d.", n_api);
+ free(f);
+ return NULL;
+ }
+
+ f->n_1_rb = shm_rbuff_create(n_1_api, port_id);
+ if (f->n_1_rb == NULL) {
+ LOG_ERR("Could not create ringbuffer for AP-I %d.", n_1_api);
+ free(f);
+ return NULL;
+ }
+
+ f->state = FLOW_ALLOC_PENDING;
+
+ if (clock_gettime(CLOCK_MONOTONIC, &f->t0) < 0)
+ LOG_WARN("Failed to set timestamp.");
return f;
}