diff options
| author | longtengmcu <[email protected]> | 2020-05-17 15:51:35 +0800 |
|---|---|---|
| committer | longtengmcu <[email protected]> | 2020-05-17 15:51:35 +0800 |
| commit | 63950c9259cb099c4182e29fef3d27b929d66258 (patch) | |
| tree | fca486866e8c49132dc2dfb50b9ec0e1f09e34bd /components | |
| parent | 21a3ba358aabad6c96bf803c752d86a870a2e019 (diff) | |
1、解决do_pollfd函数中处理底层网络设备返回错误-1的情况,返回-1时select函数也要返回-1
2、网卡设备调用关闭dhcp时,底层要调用dhcp_stop函数来关闭dhcp功能,打开时再调用dhcp_start,否则再次打开dhcp时无法获取ip地址或者出现在使用静态ip地址会在dhcp租约到期时自动再获取ip地址。
3、sal_socket.c程序中的sal_accept函数增加判断网卡up,down的功能
Diffstat (limited to 'components')
| -rw-r--r-- | components/dfs/src/poll.c | 18 | ||||
| -rw-r--r-- | components/net/lwip-2.0.2/src/netif/ethernetif.c | 10 | ||||
| -rw-r--r-- | components/net/sal_socket/src/sal_socket.c | 3 |
3 files changed, 30 insertions, 1 deletions
diff --git a/components/dfs/src/poll.c b/components/dfs/src/poll.c index 3f304549f7..3996fdf580 100644 --- a/components/dfs/src/poll.c +++ b/components/dfs/src/poll.c @@ -137,6 +137,14 @@ static int do_pollfd(struct pollfd *pollfd, rt_pollreq_t *req) req->_key = pollfd->events | POLLERR | POLLHUP; mask = f->fops->poll(f, req); + + /* dealwith the device return error -1 zhaoshimin 20200509*/ + if (mask < 0) + { + fd_put(f); + pollfd->revents = 0; + return mask; + } } /* Mask out unneeded events. */ mask &= pollfd->events | POLLERR | POLLHUP; @@ -154,6 +162,7 @@ static int poll_do(struct pollfd *fds, nfds_t nfds, struct rt_poll_table *pt, in int istimeout = 0; int n; struct pollfd *pf; + int ret = 0; if (msec == 0) { @@ -168,7 +177,14 @@ static int poll_do(struct pollfd *fds, nfds_t nfds, struct rt_poll_table *pt, in for (n = 0; n < nfds; n ++) { - if (do_pollfd(pf, &pt->req)) + ret = do_pollfd(pf, &pt->req); + if(ret < 0) + { + /*dealwith the device return error -1 zhaoshimin 20200509*/ + pt->req._proc = RT_NULL; + return ret; + } + else if(ret > 0) { num ++; pt->req._proc = RT_NULL; diff --git a/components/net/lwip-2.0.2/src/netif/ethernetif.c b/components/net/lwip-2.0.2/src/netif/ethernetif.c index 6c5621281c..8e90f0daf3 100644 --- a/components/net/lwip-2.0.2/src/netif/ethernetif.c +++ b/components/net/lwip-2.0.2/src/netif/ethernetif.c @@ -164,6 +164,16 @@ static int lwip_netdev_set_dns_server(struct netdev *netif, uint8_t dns_num, ip_ static int lwip_netdev_set_dhcp(struct netdev *netif, rt_bool_t is_enabled) { netdev_low_level_set_dhcp_status(netif, is_enabled); + + /*zhaoshimin 20200508 add dhcp start or stop must call dhcp_start and dhcp_stop function*/ + if(is_enabled == RT_TRUE) + { + dhcp_start((struct netif *)netif->user_data); + } + else + { + dhcp_stop((struct netif *)netif->user_data); + } return ERR_OK; } #endif /* RT_LWIP_DHCP */ diff --git a/components/net/sal_socket/src/sal_socket.c b/components/net/sal_socket/src/sal_socket.c index e3bea5a28e..1e43896012 100644 --- a/components/net/sal_socket/src/sal_socket.c +++ b/components/net/sal_socket/src/sal_socket.c @@ -564,6 +564,9 @@ int sal_accept(int socket, struct sockaddr *addr, socklen_t *addrlen) /* get the socket object by socket descriptor */ SAL_SOCKET_OBJ_GET(sock, socket); + /* check the network interface is up status zhaoshimin add 20200509*/ + SAL_NETDEV_IS_UP(sock->netdev); + /* check the network interface socket operations */ SAL_NETDEV_SOCKETOPS_VALID(sock->netdev, pf, accept); |
