summaryrefslogtreecommitdiff
path: root/src/irmd/irm_flow.c
diff options
context:
space:
mode:
authorDimitri Staessens <[email protected]>2023-03-14 12:50:27 +0100
committerSander Vrijders <[email protected]>2023-03-18 17:12:27 +0100
commit99b4f4d6d6f18321489bae50f1762b29165f7de1 (patch)
tree980ce47c1e7e84b91403ecc8f8263c8d05dfc1c3 /src/irmd/irm_flow.c
parent3b2f38aeafa1d6d2976dd5581ef46a5d3b463825 (diff)
downloadouroboros-99b4f4d6d6f18321489bae50f1762b29165f7de1.tar.gz
ouroboros-99b4f4d6d6f18321489bae50f1762b29165f7de1.zip
irmd: Use buffer_t for piggybacked data
Instead of passing a const void * and len, it now passes buffer_t to operations that send piggybacked data (flow_req_arr and flow_reply) and a buffer_t * for operations that send and receive piggybacked data (flow_alloc and flow_accept). Signed-off-by: Dimitri Staessens <[email protected]> Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/irmd/irm_flow.c')
-rw-r--r--src/irmd/irm_flow.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/irmd/irm_flow.c b/src/irmd/irm_flow.c
index 44d3fb7e..6d22cbc8 100644
--- a/src/irmd/irm_flow.c
+++ b/src/irmd/irm_flow.c
@@ -33,9 +33,10 @@
#include "irm_flow.h"
-#include <stdlib.h>
-#include <stdbool.h>
#include <assert.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
struct irm_flow * irm_flow_create(pid_t n_pid,
pid_t n_1_pid,
@@ -43,10 +44,14 @@ struct irm_flow * irm_flow_create(pid_t n_pid,
qosspec_t qs)
{
pthread_condattr_t cattr;
- struct irm_flow * f = malloc(sizeof(*f));
+ struct irm_flow * f;
+
+ f = malloc(sizeof(*f));
if (f == NULL)
goto fail_malloc;
+ memset(f, 0, sizeof(*f));
+
if (pthread_condattr_init(&cattr))
goto fail_cattr;
@@ -59,14 +64,6 @@ struct irm_flow * irm_flow_create(pid_t n_pid,
if (pthread_mutex_init(&f->state_lock, NULL))
goto fail_mutex;
- f->n_pid = n_pid;
- f->n_1_pid = n_1_pid;
- f->flow_id = flow_id;
- f->mpl = 0;
- f->qs = qs;
- f->data = NULL;
- f->len = 0;
-
f->n_rb = shm_rbuff_create(n_pid, flow_id);
if (f->n_rb == NULL) {
log_err("Could not create ringbuffer for process %d.", n_pid);
@@ -79,11 +76,16 @@ struct irm_flow * irm_flow_create(pid_t n_pid,
goto fail_n_1_rbuff;
}
- f->state = FLOW_ALLOC_PENDING;
-
if (clock_gettime(CLOCK_MONOTONIC, &f->t0) < 0)
log_warn("Failed to set timestamp.");
+ f->n_pid = n_pid;
+ f->n_1_pid = n_1_pid;
+ f->flow_id = flow_id;
+ f->qs = qs;
+
+ f->state = FLOW_ALLOC_PENDING;
+
pthread_condattr_destroy(&cattr);
return f;
@@ -123,7 +125,7 @@ void irm_flow_destroy(struct irm_flow * f)
pthread_mutex_lock(&f->state_lock);
- assert(f->len == 0);
+ assert(f->data.len == 0);
if (f->state == FLOW_DESTROY) {
pthread_mutex_unlock(&f->state_lock);