Commit 399a27f9 authored by Jozef Kralik's avatar Jozef Kralik

port/linux: make non-block shutdown read descriptor

the iotivity-lite hangs in read of shutdown descriptor.
so this fix it.
parent 750c2094
Pipeline #1297 failed with stage
in 3 minutes
......@@ -40,6 +40,7 @@
#include <sys/select.h>
#include <sys/un.h>
#include <unistd.h>
#include <fcntl.h>
/* Some outdated toolchains do not define IFA_FLAGS.
Note: Requires Linux kernel 3.14 or later. */
......@@ -1404,6 +1405,10 @@ oc_connectivity_init(size_t device)
OC_ERR("shutdown pipe: %d", errno);
return -1;
}
if (set_nonblock_socket(dev->shutdown_pipe[0]) < 0) {
OC_ERR("Could not set non-block shutdown_pipe[0]");
return -1;
}
memset(&dev->mcast, 0, sizeof(struct sockaddr_storage));
memset(&dev->server, 0, sizeof(struct sockaddr_storage));
......@@ -1792,3 +1797,13 @@ oc_dns_lookup(const char *domain, oc_string_t *addr, enum transport_flags flags)
return ret;
}
#endif /* OC_DNS_LOOKUP */
int
set_nonblock_socket(int sockfd) {
int flags = fcntl(sockfd, F_GETFL, 0);
if (flags < 0) {
return -1;
}
return fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
}
\ No newline at end of file
/****************************************************************************
*
* Copyright 2019 Jozef Kralik All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************/
#ifndef IPADAPTER_H
#define IPADAPTER_H
int set_nonblock_socket(int sockfd);
#endif /* IPADAPTER_H */
\ No newline at end of file
......@@ -18,6 +18,7 @@
#define __USE_GNU
#include "ipadapter.h"
#include "tcpadapter.h"
#include "api/oc_session_events_internal.h"
#include "ipcontext.h"
......@@ -690,16 +691,6 @@ tcp_connectivity_ipv4_init(ip_context_t *dev)
}
#endif /* OC_IPV4 */
static int
set_nonblock_socket(int sockfd) {
int flags = fcntl(sockfd, F_GETFL, 0);
if (flags < 0) {
return -1;
}
return fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
}
int
oc_tcp_connectivity_init(ip_context_t *dev)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment