Hi Anders Widell,

On 11/21/2016 2:00 PM, Anders Widell wrote:
> Hi!
>
> Do you really think this would be necessary, considering that we don't 
> support Linux kernel versions older than 2.6.37?

Not required , I already sent correction, I am using Linux kernel 
3.0.13-0.27 , so no issue ,

ACK from me not tested.

-AVM

> The OpenSAF README file clearly states the minimum required versions 
> of important OS packages, including the Linux kernel version.
>
> regards,
>
> Anders Widell
>
>
> On 11/21/2016 06:46 AM, A V Mahesh wrote:
>> Hi Anders Widell,
>>
>> It seems SOCK_CLOEXEC is unsupported on Linux kernel older than 
>> 2.6.27, for example I am currently using :
>>
>> # uname -r
>> 2.6.18-308.1.1.el5
>>
>> It looks EINVAL is what socket returns if it does not support 
>> SOCK_CLOEXEC, may be we need to do
>> ` flags = fcntl(tcp_cb->DBSRsock, F_GETFD, 0);` in else case of 
>> SOCK_CLOEXEC is unsupported on Linux kernel,
>> can you please cross check.
>>
>> -AVMC
>>
>>
>> On 11/10/2016 4:58 PM, Anders Widell wrote:
>>>   osaf/libs/core/mds/mds_dt_tcp.c  |  23 +++++++-------------
>>>   osaf/libs/core/mds/mds_dt_tipc.c |  43 
>>> ++++++++-------------------------------
>>>   2 files changed, 17 insertions(+), 49 deletions(-)
>>>
>>>
>>> To avoid a potential race between fcntl(FD_CLOEXEC) in one thread 
>>> and exec() in
>>> another thread, use the SOCK_CLOEXEC flag when creating sockets.
>>>
>>> diff --git a/osaf/libs/core/mds/mds_dt_tcp.c 
>>> b/osaf/libs/core/mds/mds_dt_tcp.c
>>> --- a/osaf/libs/core/mds/mds_dt_tcp.c
>>> +++ b/osaf/libs/core/mds/mds_dt_tcp.c
>>> @@ -38,6 +38,13 @@
>>>   #include <arpa/inet.h>
>>>   #include <configmake.h>
>>>   +#ifndef SOCK_CLOEXEC
>>> +enum {
>>> +    SOCK_CLOEXEC = 0x80000
>>> +};
>>> +#define SOCK_CLOEXEC SOCK_CLOEXEC
>>> +#endif
>>> +
>>>   #define MDS_MDTM_SUN_PATH 255
>>>   #define MDS_MDTM_CONNECT_PATH PKGLOCALSTATEDIR 
>>> "/osaf_dtm_intra_server"
>>>   @@ -81,7 +88,6 @@ uint32_t mdtm_process_recv_events_tcp(vo
>>>    */
>>>   uint32_t mds_mdtm_init_tcp(NODE_ID nodeid, uint32_t *mds_tcp_ref)
>>>   {
>>> -    uint32_t flags;
>>>       uint32_t sndbuf_size = 0; /* Send buffer size */
>>>       uint32_t rcvbuf_size = 0;  /* Receive buffer size */
>>>       socklen_t optlen; /* Option length */
>>> @@ -125,7 +131,7 @@ uint32_t mds_mdtm_init_tcp(NODE_ID nodei
>>>         /* Create the sockets required for Binding, Send, receive 
>>> and Discovery */
>>>   -    tcp_cb->DBSRsock = socket(mds_socket_domain, 
>>> SOCK_STREAM|SOCK_CLOEXEC, 0);
>>> +    tcp_cb->DBSRsock = socket(mds_socket_domain, SOCK_STREAM | 
>>> SOCK_CLOEXEC, 0);
>>>       if (tcp_cb->DBSRsock < 0) {
>>>           syslog(LOG_ERR, "MDTM:TCP DBSRsock Socket creation failed 
>>> in MDTM_INIT err :%s", strerror(errno));
>>>           return NCSCC_RC_FAILURE;
>>> @@ -177,19 +183,6 @@ uint32_t mds_mdtm_init_tcp(NODE_ID nodei
>>>           return NCSCC_RC_FAILURE;
>>>       }
>>>   -    flags = fcntl(tcp_cb->DBSRsock, F_GETFD, 0);
>>> -    if ((flags < 0) || (flags > 1)) {
>>> -        syslog(LOG_ERR, "MDTM:TCP Unable to get the CLOEXEC Flag on 
>>> DBSRsock  err :%s", strerror(errno));
>>> -        close(tcp_cb->DBSRsock);
>>> -        return NCSCC_RC_FAILURE;
>>> -    } else {
>>> -        if (fcntl(tcp_cb->DBSRsock, F_SETFD, (flags | FD_CLOEXEC)) 
>>> == (-1)) {
>>> -            syslog(LOG_ERR, "MDTM:TCP Unable to set the CLOEXEC 
>>> Flag on DBSRsock err :%s", strerror(errno));
>>> -            close(tcp_cb->DBSRsock);
>>> -            return NCSCC_RC_FAILURE;
>>> -        }
>>> -    }
>>> -
>>>       tcp_cb->adest = ((uint64_t)(nodeid)) << 32;
>>>       tcp_cb->adest |= mdtm_pid;
>>>       tcp_cb->node_id = nodeid;
>>> diff --git a/osaf/libs/core/mds/mds_dt_tipc.c 
>>> b/osaf/libs/core/mds/mds_dt_tipc.c
>>> --- a/osaf/libs/core/mds/mds_dt_tipc.c
>>> +++ b/osaf/libs/core/mds/mds_dt_tipc.c
>>> @@ -45,6 +45,13 @@
>>>   #include "mds_core.h"
>>>   #include "osaf_utility.h"
>>>   +#ifndef SOCK_CLOEXEC
>>> +enum {
>>> +    SOCK_CLOEXEC = 0x80000
>>> +};
>>> +#define SOCK_CLOEXEC SOCK_CLOEXEC
>>> +#endif
>>> +
>>>   /*
>>>       tipc_id will be <NODE_ID,RANDOM NUMBER>
>>>   */
>>> @@ -151,7 +158,6 @@ uint32_t mdtm_global_frag_num;
>>>   uint32_t mdtm_tipc_init(NODE_ID nodeid, uint32_t *mds_tipc_ref)
>>>   {
>>>       uint32_t tipc_node_id = 0;
>>> -    int flags;
>>>         NCS_PATRICIA_PARAMS pat_tree_params;
>>>   @@ -176,48 +182,17 @@ uint32_t mdtm_tipc_init(NODE_ID nodeid,
>>>         /* Create the sockets required for Binding, Send, receive 
>>> and Discovery */
>>>   -    tipc_cb.Dsock = socket(AF_TIPC, SOCK_SEQPACKET, 0);
>>> +    tipc_cb.Dsock = socket(AF_TIPC, SOCK_SEQPACKET | SOCK_CLOEXEC, 0);
>>>       if (tipc_cb.Dsock < 0) {
>>>           syslog(LOG_ERR, "MDTM:TIPC Dsock Socket creation failed in 
>>> MDTM_INIT err :%s", strerror(errno));
>>>           return NCSCC_RC_FAILURE;
>>>       }
>>> -    tipc_cb.BSRsock = socket(AF_TIPC, SOCK_RDM, 0);
>>> +    tipc_cb.BSRsock = socket(AF_TIPC, SOCK_RDM | SOCK_CLOEXEC, 0);
>>>       if (tipc_cb.BSRsock < 0) {
>>>           syslog(LOG_ERR, "MDTM:TIPC BSRsock Socket creation failed 
>>> in MDTM_INIT err :%s", strerror(errno));
>>>           return NCSCC_RC_FAILURE;
>>>       }
>>>   -    flags = fcntl(tipc_cb.Dsock, F_GETFD, 0);
>>> -    if ((flags < 0) || (flags > 1)) {
>>> -        syslog(LOG_ERR, "MDTM:TIPC Unable to get the CLOEXEC Flag 
>>> on Dsock err :%s", strerror(errno));
>>> -        close(tipc_cb.Dsock);
>>> -        close(tipc_cb.BSRsock);
>>> -        return NCSCC_RC_FAILURE;
>>> -    } else {
>>> -        if (fcntl(tipc_cb.Dsock, F_SETFD, (flags | FD_CLOEXEC)) == 
>>> (-1)) {
>>> -            syslog(LOG_ERR, "MDTM:TIPC Unable to set the CLOEXEC 
>>> Flag on Dsock err :%s", strerror(errno));
>>> -            close(tipc_cb.Dsock);
>>> -            close(tipc_cb.BSRsock);
>>> -            return NCSCC_RC_FAILURE;
>>> -        }
>>> -    }
>>> -
>>> -    flags = fcntl(tipc_cb.BSRsock, F_GETFD, 0);
>>> -    if ((flags < 0) || (flags > 1)) {
>>> -        syslog(LOG_ERR, "MDTM:TIPC Unable to get the CLOEXEC Flag 
>>> on BSRsock err :%s", strerror(errno));
>>> -        close(tipc_cb.Dsock);
>>> -        close(tipc_cb.BSRsock);
>>> -        return NCSCC_RC_FAILURE;
>>> -    } else {
>>> -        if (fcntl(tipc_cb.BSRsock, F_SETFD, (flags | FD_CLOEXEC)) 
>>> == (-1)) {
>>> -            syslog(LOG_ERR, "MDTM:TIPC Unable to set the CLOEXEC 
>>> Flag on BSRsock err :%s", strerror(errno));
>>> -            close(tipc_cb.Dsock);
>>> -            close(tipc_cb.BSRsock);
>>> -            return NCSCC_RC_FAILURE;
>>> -        }
>>> -    }
>>> -    /* End Fix */
>>> -
>>>       /* Code for getting the self tipc random number */
>>>       memset(&addr, 0, sizeof(addr));
>>>       if (0 > getsockname(tipc_cb.BSRsock, (struct sockaddr *)&addr, 
>>> &sz)) {
>>
>


------------------------------------------------------------------------------
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to