From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Tan, Jianfeng" Subject: Re: [PATCH v2 3/4] eal: add synchronous multi-process communication Date: Wed, 17 Jan 2018 21:15:53 +0800 Message-ID: <7944df37-df86-67cc-9d1b-7be137771084@intel.com> References: <1512067450-59203-1-git-send-email-jianfeng.tan@intel.com> <1515643654-129489-1-git-send-email-jianfeng.tan@intel.com> <1515643654-129489-4-git-send-email-jianfeng.tan@intel.com> <2601191342CEEE43887BDE71AB9772588627E0E5@irsmsx105.ger.corp.intel.com> <5733adcf-ef47-2c07-a39c-7eda01add6e0@intel.com> <2601191342CEEE43887BDE71AB9772588627E2D8@irsmsx105.ger.corp.intel.com> <2601191342CEEE43887BDE71AB9772588627EE16@irsmsx105.ger.corp.intel.com> <74ccd840-86af-4dba-e5ba-494017052841@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Cc: "Richardson, Bruce" , "thomas@monjalon.net" To: "Ananyev, Konstantin" , "dev@dpdk.org" , "Burakov, Anatoly" Return-path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 241392951 for ; Wed, 17 Jan 2018 14:15:55 +0100 (CET) In-Reply-To: <74ccd840-86af-4dba-e5ba-494017052841@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 1/17/2018 9:09 PM, Tan, Jianfeng wrote: > > > On 1/17/2018 6:50 PM, Ananyev, Konstantin wrote: > [...] >> +int >> +rte_eal_mp_request(const char *action_name, >> + void *params, >> + int len_p, >> + int fds[], >> + int fds_in, >> + int fds_out) >> +{ >> + int i, j; >> + int sockfd; >> + int nprocs; >> + int ret = 0; >> + struct mp_msghdr *req; >> + struct timeval tv; >> + char buf[MAX_MSG_LENGTH]; >> + struct mp_msghdr *hdr; >> + >> + RTE_LOG(DEBUG, EAL, "request: %s\n", action_name); >> + >> + if (fds_in > SCM_MAX_FD || fds_out > SCM_MAX_FD) { >> + RTE_LOG(ERR, EAL, "Cannot send more than %d FDs\n", >> SCM_MAX_FD); >> + rte_errno = -E2BIG; >> + return 0; >> + } >> + >> + req = format_msg(action_name, params, len_p, fds_in, MP_REQ); >> + if (req == NULL) >> + return 0; >> + >> + if ((sockfd = open_unix_fd(0)) < 0) { >> + free(req); >> + return 0; >> + } >> + >> + tv.tv_sec = 5; /* 5 Secs Timeout */ >> + tv.tv_usec = 0; >> + if (setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, >> + (const void *)&tv, sizeof(struct timeval)) < 0) >> + RTE_LOG(INFO, EAL, "Failed to set recv timeout\n"); >> >> I f you set it just for one call, why do you not restore it? > > Yes, original code is buggy, I should have put it into the critical > section. > > Do you mean we just create once and use for ever? if yes, we could put > the open and setting into mp_init(). A second thought, we shall not put the setting into mp_init(). It'll be set to non-blocking as of sending msg, but blocking as of receiving msg. Thanks, Jianfeng