On 16-Apr-19 4:43 AM, ogawa.yasuf...@lab.ntt.co.jp wrote:
From: Yasufumi Ogawa <ogawa.yasuf...@lab.ntt.co.jp>

In secondary_msl_create_walk(), it creates a file for fbarrays with its
PID for reserving unique name among secondary processes. However, it
does not work if secondary is run as app container because each of
containerized secondary has PID 1. To reserve unique name, use hostname
instead of PID if the value is 1.

Cc: sta...@dpdk.org

Signed-off-by: Yasufumi Ogawa <ogawa.yasuf...@lab.ntt.co.jp>
---

I'm not too well versed in containers - is this hostname 1) always set, and 2) always unique?

<snip>

+       if (getpid() == 1) {
+               FILE *hn_fp;
+               hn_fp = fopen("/etc/hostname", "r");
+               if (hn_fp == NULL) {
+                       RTE_LOG(ERR, EAL,
+                               "Cannot open '/etc/hostname' for secondary\n");
+                       return -1;
+               }
+
+               /* with docker, /etc/hostname just has one entry of hostname */
+               if (fscanf(hn_fp, "%s", proc_id) == EOF)
+                       return -1;

Wouldn't an error in fscanf() leak the file handle? I think you need to fclose() before checking the result.

+               fclose(hn_fp);
+       } else
+               sprintf(proc_id, "%d", (int)getpid());
+
+       snprintf(name, RTE_FBARRAY_NAME_LEN, "%s_%s",
+                       primary_msl->memseg_arr.name, proc_id);
ret = rte_fbarray_init(&local_msl->memseg_arr, name,
                primary_msl->memseg_arr.len,



--
Thanks,
Anatoly

Reply via email to