From 63950c9259cb099c4182e29fef3d27b929d66258 Mon Sep 17 00:00:00 2001 From: longtengmcu Date: Sun, 17 May 2020 15:51:35 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1=E3=80=81=E8=A7=A3=E5=86=B3do=5Fpollfd?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E4=B8=AD=E5=A4=84=E7=90=86=E5=BA=95=E5=B1=82?= =?UTF-8?q?=E7=BD=91=E7=BB=9C=E8=AE=BE=E5=A4=87=E8=BF=94=E5=9B=9E=E9=94=99?= =?UTF-8?q?=E8=AF=AF-1=E7=9A=84=E6=83=85=E5=86=B5=EF=BC=8C=E8=BF=94?= =?UTF-8?q?=E5=9B=9E-1=E6=97=B6select=E5=87=BD=E6=95=B0=E4=B9=9F=E8=A6=81?= =?UTF-8?q?=E8=BF=94=E5=9B=9E-1=202=E3=80=81=E7=BD=91=E5=8D=A1=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E8=B0=83=E7=94=A8=E5=85=B3=E9=97=ADdhcp=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=BA=95=E5=B1=82=E8=A6=81=E8=B0=83=E7=94=A8dhcp=5Fst?= =?UTF-8?q?op=E5=87=BD=E6=95=B0=E6=9D=A5=E5=85=B3=E9=97=ADdhcp=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E6=89=93=E5=BC=80=E6=97=B6=E5=86=8D=E8=B0=83?= =?UTF-8?q?=E7=94=A8dhcp=5Fstart=EF=BC=8C=E5=90=A6=E5=88=99=E5=86=8D?= =?UTF-8?q?=E6=AC=A1=E6=89=93=E5=BC=80dhcp=E6=97=B6=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E8=8E=B7=E5=8F=96ip=E5=9C=B0=E5=9D=80=E6=88=96=E8=80=85?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E5=9C=A8=E4=BD=BF=E7=94=A8=E9=9D=99=E6=80=81?= =?UTF-8?q?ip=E5=9C=B0=E5=9D=80=E4=BC=9A=E5=9C=A8dhcp=E7=A7=9F=E7=BA=A6?= =?UTF-8?q?=E5=88=B0=E6=9C=9F=E6=97=B6=E8=87=AA=E5=8A=A8=E5=86=8D=E8=8E=B7?= =?UTF-8?q?=E5=8F=96ip=E5=9C=B0=E5=9D=80=E3=80=82=203=E3=80=81sal=5Fsocket?= =?UTF-8?q?.c=E7=A8=8B=E5=BA=8F=E4=B8=AD=E7=9A=84sal=5Faccept=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E5=A2=9E=E5=8A=A0=E5=88=A4=E6=96=AD=E7=BD=91=E5=8D=A1?= =?UTF-8?q?up,down=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/dfs/src/poll.c | 18 +++++++++++++++++- .../net/lwip-2.0.2/src/netif/ethernetif.c | 10 ++++++++++ components/net/sal_socket/src/sal_socket.c | 3 +++ 3 files changed, 30 insertions(+), 1 deletion(-) 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); From d75f03e4b03be4c72c5155cc0b00683da31ae74b Mon Sep 17 00:00:00 2001 From: longtengmcu Date: Thu, 21 May 2020 22:05:38 +0800 Subject: [PATCH 2/2] =?UTF-8?q?1=E3=80=81=E8=A7=A3=E5=86=B3do=5Fpollfd?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E4=B8=AD=E5=A4=84=E7=90=86=E5=BA=95=E5=B1=82?= =?UTF-8?q?=E7=BD=91=E7=BB=9C=E8=AE=BE=E5=A4=87=E8=BF=94=E5=9B=9E=E9=94=99?= =?UTF-8?q?=E8=AF=AF-1=E7=9A=84=E6=83=85=E5=86=B5=EF=BC=8C=E8=BF=94?= =?UTF-8?q?=E5=9B=9E-1=E6=97=B6select=E5=87=BD=E6=95=B0=E4=B9=9F=E8=A6=81?= =?UTF-8?q?=E8=BF=94=E5=9B=9E-1=20=E2=80=A6=202=E3=80=81=E7=BD=91=E5=8D=A1?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E8=B0=83=E7=94=A8=E5=85=B3=E9=97=ADdhcp?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=BA=95=E5=B1=82=E8=A6=81=E8=B0=83=E7=94=A8?= =?UTF-8?q?dhcp=5Fstop=E5=87=BD=E6=95=B0=E6=9D=A5=E5=85=B3=E9=97=ADdhcp?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=89=93=E5=BC=80=E6=97=B6=E5=86=8D?= =?UTF-8?q?=E8=B0=83=E7=94=A8dhcp=5Fstart=EF=BC=8C=E5=90=A6=E5=88=99?= =?UTF-8?q?=E5=86=8D=E6=AC=A1=E6=89=93=E5=BC=80dhcp=E6=97=B6=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E8=8E=B7=E5=8F=96ip=E5=9C=B0=E5=9D=80=E6=88=96?= =?UTF-8?q?=E8=80=85=E5=87=BA=E7=8E=B0=E5=9C=A8=E4=BD=BF=E7=94=A8=E9=9D=99?= =?UTF-8?q?=E6=80=81ip=E5=9C=B0=E5=9D=80=E4=BC=9A=E5=9C=A8dhcp=E7=A7=9F?= =?UTF-8?q?=E7=BA=A6=E5=88=B0=E6=9C=9F=E6=97=B6=E8=87=AA=E5=8A=A8=E5=86=8D?= =?UTF-8?q?=E8=8E=B7=E5=8F=96ip=E5=9C=B0=E5=9D=80=E3=80=82=203=E3=80=81sal?= =?UTF-8?q?=5Fsocket.c=E7=A8=8B=E5=BA=8F=E4=B8=AD=E7=9A=84sal=5Faccept?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E5=A2=9E=E5=8A=A0=E5=88=A4=E6=96=AD=E7=BD=91?= =?UTF-8?q?=E5=8D=A1up,down=E7=9A=84=E5=8A=9F=E8=83=BD=204=E3=80=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B3=A8=E9=87=8A=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/dfs/src/poll.c | 4 ++-- .../net/lwip-2.0.2/src/netif/ethernetif.c | 18 +++++++++--------- components/net/sal_socket/src/sal_socket.c | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/components/dfs/src/poll.c b/components/dfs/src/poll.c index 3996fdf580..fc48eca758 100644 --- a/components/dfs/src/poll.c +++ b/components/dfs/src/poll.c @@ -138,7 +138,7 @@ static int do_pollfd(struct pollfd *pollfd, rt_pollreq_t *req) mask = f->fops->poll(f, req); - /* dealwith the device return error -1 zhaoshimin 20200509*/ + /* dealwith the device return error -1*/ if (mask < 0) { fd_put(f); @@ -180,7 +180,7 @@ static int poll_do(struct pollfd *fds, nfds_t nfds, struct rt_poll_table *pt, in ret = do_pollfd(pf, &pt->req); if(ret < 0) { - /*dealwith the device return error -1 zhaoshimin 20200509*/ + /*dealwith the device return error -1 */ pt->req._proc = RT_NULL; return ret; } 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 8e90f0daf3..be16da7ad3 100644 --- a/components/net/lwip-2.0.2/src/netif/ethernetif.c +++ b/components/net/lwip-2.0.2/src/netif/ethernetif.c @@ -165,15 +165,15 @@ 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); - } + /*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 1e43896012..ec0519df02 100644 --- a/components/net/sal_socket/src/sal_socket.c +++ b/components/net/sal_socket/src/sal_socket.c @@ -564,7 +564,7 @@ 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*/ + /* check the network interface is up status */ SAL_NETDEV_IS_UP(sock->netdev); /* check the network interface socket operations */