Fixed socket closing

This commit is contained in:
gSpot
2023-08-29 23:52:07 +03:00
parent 170bd8ddd7
commit 259f4cf122
4 changed files with 7 additions and 4 deletions

View File

@@ -19,9 +19,9 @@ Internet-detector is an application for checking the availability of the Interne
**OpenWrt >= 21.02:** **OpenWrt >= 21.02:**
opkg update opkg update
wget --no-check-certificate -O /tmp/internet-detector_1.0-2_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector_1.0-2_all.ipk wget --no-check-certificate -O /tmp/internet-detector_1.0-3_all.ipk https://github.com/gSpotx2f/packages-openwrt/raw/master/current/internet-detector_1.0-3_all.ipk
opkg install /tmp/internet-detector_1.0-2_all.ipk opkg install /tmp/internet-detector_1.0-3_all.ipk
rm /tmp/internet-detector_1.0-2_all.ipk rm /tmp/internet-detector_1.0-3_all.ipk
/etc/init.d/internet-detector start /etc/init.d/internet-detector start
/etc/init.d/internet-detector enable /etc/init.d/internet-detector enable

View File

@@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=internet-detector PKG_NAME:=internet-detector
PKG_VERSION:=1.0 PKG_VERSION:=1.0
PKG_RELEASE:=2 PKG_RELEASE:=3
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector> PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk

View File

@@ -260,6 +260,7 @@ function InternetDetector:TCPConnectionToHost(host, port)
io.stdout:write(string.format( io.stdout:write(string.format(
"SOCKET ERROR: %s, %s\n", errMsg, errNum)) "SOCKET ERROR: %s, %s\n", errMsg, errNum))
end end
unistd.close(sock)
return retCode return retCode
end end
end end
@@ -299,6 +300,7 @@ function InternetDetector:TCPConnectionToHost(host, port)
io.stdout:flush() io.stdout:flush()
end end
socket.shutdown(sock, socket.SHUT_RDWR)
unistd.close(sock) unistd.close(sock)
retCode = success and 0 or 1 retCode = success and 0 or 1
end end

View File

@@ -161,6 +161,7 @@ function Module:sendUDPMessage(message, server, port)
io.stdout:write(string.format( io.stdout:write(string.format(
"SOCKET ERROR: %s, %s\n", errMsg, errNum)) "SOCKET ERROR: %s, %s\n", errMsg, errNum))
end end
unistd.close(sock)
return retCode return retCode
end end
end end