diff --git a/.gitignore b/.gitignore index cab19059ca54dc1e96fa511dc0e71aecdb6998a5..40a844cf97c51e9911797ce9870e063f2b71d5ed 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ *.o.cmd *.ko *.ko.cmd - +*.idea Module.symvers modules.builtin modules.order diff --git a/source/tools/monitor/unity/beaver/localBeaver.lua b/source/tools/monitor/unity/beaver/localBeaver.lua index 5267a3476e7818d4fd076434212894516f42dc15..d0c2c5dea9dbafc1eeed5e4c0f23384d562090cc 100644 --- a/source/tools/monitor/unity/beaver/localBeaver.lua +++ b/source/tools/monitor/unity/beaver/localBeaver.lua @@ -92,14 +92,13 @@ function CLocalBeaver:_installFFI() end -function CLocalBeaver:localBind(fd, tPort) +local function localBind(cffi, fd, tPort) local try = 0 local res, err, errno -- can reuse for time wait socket. --res, err, errno = socket.setsockopt(fd, socket.SOL_SOCKET, socket.SO_REUSEADDR, 1); - print(self) - res = self._cffi.setsockopt_AP(fd) + res = cffi.setsockopt_AP(fd) if res<0 then system:posixError("set sock opt failed."); end @@ -124,7 +123,7 @@ function CLocalBeaver:_install_fd_unisock(backlog,unix_socket) fd, err, errno = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0) if fd then -- for socket local tPort = {family=socket.AF_UNIX, path=unix_socket} - local r, msg = pcall(localBind, fd, tPort) + local r, msg = pcall(localBind, self._cffi, fd, tPort) if r then res, err, errno = socket.listen(fd, backlog) if res then -- for listen @@ -134,7 +133,7 @@ function CLocalBeaver:_install_fd_unisock(backlog,unix_socket) system:posixError("socket listen failed", err, errno) end else - print(msg) + print("call localBind failed, report: " .. msg) unistd.close(fd) os.exit(1) end @@ -148,7 +147,7 @@ function CLocalBeaver:_install_fd(port, ip, backlog) fd, err, errno = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) if fd then -- for socket local tPort = {family=socket.AF_INET, addr=ip, port=port} - local r, msg = pcall(localBind, fd, tPort) + local r, msg = pcall(localBind, self._cffi, fd, tPort) if r then res, err, errno = socket.listen(fd, backlog) if res then -- for listen @@ -158,7 +157,7 @@ function CLocalBeaver:_install_fd(port, ip, backlog) system:posixError("socket listen failed", err, errno) end else - print(msg) + print("call localBind failed, report: " .. msg) unistd.close(fd) os.exit(1) end diff --git a/source/tools/monitor/unity/beaver/native/local_beaver.c b/source/tools/monitor/unity/beaver/native/local_beaver.c index 8e83a8b5e24548ff69b682ae62f2279b302827ae..634907813f204e4027c2d695bfde37047835fc9b 100644 --- a/source/tools/monitor/unity/beaver/native/local_beaver.c +++ b/source/tools/monitor/unity/beaver/native/local_beaver.c @@ -4,6 +4,7 @@ #include "local_beaver.h" #include +#include #include #include #include