From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anatoly Burakov Subject: [PATCH v4 4/5] eal: don't hardcode socket filter value in IPC Date: Fri, 2 Mar 2018 15:14:11 +0000 Message-ID: References: Cc: jianfeng.tan@intel.com, keith.wiles@intel.com To: dev@dpdk.org Return-path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id A69325B3E for ; Fri, 2 Mar 2018 16:14:15 +0100 (CET) In-Reply-To: In-Reply-To: References: List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Currently, filter value is hardcoded and disconnected from actual value returned by eal_mp_socket_path(). Fix this to generate filter value by deriving it from eal_mp_socket_path() instead. Signed-off-by: Anatoly Burakov Acked-by: Jianfeng Tan --- Notes: v4: added filtering for init files as well v3: no changes v2: no changes lib/librte_eal/common/eal_common_proc.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c index 94672ba..f382184 100644 --- a/lib/librte_eal/common/eal_common_proc.c +++ b/lib/librte_eal/common/eal_common_proc.c @@ -402,7 +402,7 @@ socket_is_ready(const char *peer_name) } static int -unlink_sockets(const char *filter) +unlink_files(const char *filter) { int dir_fd; DIR *mp_dir; @@ -466,16 +466,22 @@ int rte_mp_channel_init(void) { char thread_name[RTE_MAX_THREAD_NAME_LEN]; - char *path; + char path[PATH_MAX]; + char init_filter[PATH_MAX]; int dir_fd; pthread_t tid; - snprintf(mp_filter, PATH_MAX, ".%s_unix_*", - internal_config.hugefile_prefix); + /* create filter path */ + create_socket_path("*", path, sizeof(path)); + snprintf(mp_filter, sizeof(mp_filter), "%s", basename(path)); - path = strdup(eal_mp_socket_path()); - snprintf(mp_dir_path, PATH_MAX, "%s", dirname(path)); - free(path); + /* path may have been modified, so recreate it */ + create_socket_path("*", path, sizeof(path)); + snprintf(mp_dir_path, sizeof(mp_dir_path), "%s", dirname(path)); + + /* also, create init file filter */ + create_initfile_path("*", path, sizeof(path)); + snprintf(init_filter, sizeof(init_filter), "%s", basename(path)); /* lock the directory */ dir_fd = open(mp_dir_path, O_RDONLY); @@ -493,7 +499,8 @@ rte_mp_channel_init(void) } if (rte_eal_process_type() == RTE_PROC_PRIMARY && - unlink_sockets(mp_filter)) { + (unlink_files(mp_filter) || + unlink_files(init_filter))) { RTE_LOG(ERR, EAL, "failed to unlink mp sockets\n"); close(dir_fd); return -1; -- 2.7.4