The locks were not initialised correctly due to a misspelled define
and the fail_write was trying to lock a bad mutex (sometimes -1 out of
array).
Signed-off-by: Dimitri Staessens <dimitri.staessens@xxxxxxxx>
---
src/ipcpd/normal/dt.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/ipcpd/normal/dt.c b/src/ipcpd/normal/dt.c
index 2cfd741..01f78e1 100644
--- a/src/ipcpd/normal/dt.c
+++ b/src/ipcpd/normal/dt.c
@@ -542,11 +542,11 @@ int dt_init(enum pol_routing pr,
dt.res_fds = bmp_create(PROG_RES_FDS, 0);
if (dt.res_fds == NULL)
goto fail_res_fds;
-#ifdef IPCP_FLOW_STAT
+#ifdef IPCP_FLOW_STATS
memset(dt.stat, 0, sizeof(dt.stat));
- for (i = 0; i < PROG_MAX_FLOWS, ++i)
- if (pthread_mutex_init(&dt.stat[fd].lock, NULL)) {
+ for (i = 0; i < PROG_MAX_FLOWS; ++i)
+ if (pthread_mutex_init(&dt.stat[i].lock, NULL)) {
for (j = 0; j < i; ++j)
pthread_mutex_destroy(&dt.stat[j].lock);
goto fail_stat_lock;
@@ -560,7 +560,7 @@ int dt_init(enum pol_routing pr,
return 0;
fail_rib_reg:
-#ifdef IPCP_FLOW_STAT
+#ifdef IPCP_FLOW_STATS
for (i = 0; i < PROG_MAX_FLOWS; ++i)
pthread_mutex_destroy(&dt.stat[i].lock);
fail_stat_lock:
@@ -719,14 +719,14 @@ int dt_write_sdu(uint64_t dst_addr,
fail_write:
#ifdef IPCP_FLOW_STATS
- pthread_mutex_lock(&dt.stat[fd].lock);
+ pthread_mutex_lock(&dt.stat[dt_pci.eid].lock);
++dt.stat[dt_pci.eid].lcl_w_pkt[qc];
dt.stat[dt_pci.eid].lcl_w_bytes[qc] += len;
++dt.stat[fd].w_drp_pkt[qc];
dt.stat[fd].w_drp_bytes[qc] = len;
- pthread_mutex_unlock(&dt.stat[fd].lock);
+ pthread_mutex_unlock(&dt.stat[dt_pci.eid].lock);
#endif
return -1;
}
--
2.16.2