Skip to content

Commit

Permalink
5.5.10 add error log for port listening issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-X-Net committed Aug 16, 2023
1 parent c6446af commit 4f2d992
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 59 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@


### 最新公告:
2023-07-08
* 新版 5.3.0, 提升连接性能
2023-08-15
* 新版 5.5.0, 提升连接性能
* 5.1.0,内置ChatGPT
* 原来是4.x.x 的老版本,需要重新下载新版安装,不能应用内升级。
* 原来是4.x.x 老版本的,需要重新下载新版安装,不能应用内升级。


<br>
Expand Down
107 changes: 58 additions & 49 deletions code/default/lib/noarch/simple_http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,69 +538,76 @@ def serve_forever(self):

while self.running:
try:
events = p.poll(timeout=1)
except IOError as e:
if e.errno != 4: # EINTR:
raise
else:
time.sleep(1)
continue

if not self.running:
break

for fn, event in events:
if fn not in fn_map:
self.logger.error("p.poll get fn:%d", fn)
continue

sock = fn_map[fn]
try:
(sock, address) = sock.accept()
events = p.poll(timeout=1)
except IOError as e:
if e.args[0] == 11:
# Resource temporarily unavailable is EAGAIN
# and that's not really an error.
# It means "I don't have answer for you right now and
# you have told me not to wait,
# so here I am returning without answer."
if e.errno != 4: # EINTR:
raise
else:
time.sleep(1)
continue

if e.args[0] == 24:
self.logger.warn("max file opened when sock.accept")
time.sleep(30)
if not self.running:
break

for fn, event in events:
if fn not in fn_map:
self.logger.error("p.poll get fn:%d", fn)
continue

self.logger.warn("socket accept fail(errno: %s).", e.args[0])
continue
sock = fn_map[fn]
try:
(sock, address) = sock.accept()
except IOError as e:
self.logger.warn("socket accept fail %r.", e)
if e.args[0] == 11:
# Resource temporarily unavailable is EAGAIN
# and that's not really an error.
# It means "I don't have answer for you right now and
# you have told me not to wait,
# so here I am returning without answer."
continue

if e.args[0] == 24:
self.logger.warn("max file opened when sock.accept")
time.sleep(30)
continue

self.logger.warn("socket accept fail(errno: %s).", e.args[0])
continue

try:
self.process_connect(sock, address)
except Exception as e:
self.logger.exception("process connect error:%r", e)
try:
self.process_connect(sock, address)
except Exception as e:
self.logger.exception("process connect error:%r", e)
except Exception as e:
self.logger.exception("serve except:%r", e)

else:
while self.running:
try:
r, w, e = select.select(self.sockets, [], [], 1)
except Exception as e:
continue

if not self.running:
break

for rsock in r:
try:
(sock, address) = rsock.accept()
except IOError as e:
self.logger.warn("socket accept fail(errno: %s).", e.args[0])
if e.args[0] == 10022:
self.logger.info("restart socket server.")
self.server_close()
self.init_socket()
r, w, e = select.select(self.sockets, [], [], 1)
except Exception as e:
continue

if not self.running:
break

self.process_connect(sock, address)
for rsock in r:
try:
(sock, address) = rsock.accept()
except IOError as e:
self.logger.warn("socket accept fail(errno: %s).", e.args[0])
if e.args[0] == 10022:
self.logger.info("restart socket server.")
self.server_close()
self.init_socket()
break

self.process_connect(sock, address)
except Exception as e:
self.logger.exception("serve except:%r", e)
self.server_close()

def process_connect(self, sock, address):
Expand All @@ -615,10 +622,12 @@ def process_connect(self, sock, address):
client_thread.start()

def shutdown(self):
self.logger.info("shutdown")
self.running = False
self.server_close()

def server_close(self):
self.logger.info("server_close")
for sock in self.sockets:
sock.close()
self.sockets = []
Expand Down
2 changes: 1 addition & 1 deletion code/default/update_v5.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ https://codeload.github.com/XX-net/XX-Net/zip/5.3.2 d4dcc4df1f5dcfc564e5119648ac


稳定版(Stable):
https://codeload.github.com/XX-net/XX-Net/zip/5.1.0 d15b27c484ce78ffcc524a5e17f9fdcf2937b8837117811da971e4e8954a2102
https://codeload.github.com/XX-net/XX-Net/zip/5.5.9 facac819b15e706b8a1797aa122212397e204c9128acdd4465ffd5c83718134d
2 changes: 1 addition & 1 deletion code/default/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.5.9
5.5.10
9 changes: 4 additions & 5 deletions code/default/x_tunnel/local/base_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,12 @@ def put(self, sn, data):
else:
# xlog.debug("recv_pool put sn:%d in order", sn)
self.process_callback(data)
self.next_sn = sn + 1
self.next_sn += 1

while sn + 1 in self.block_list:
sn += 1
while self.next_sn in self.block_list:
# xlog.debug("recv_pool sn:%d processed", sn)
self.block_list.remove(sn)
self.next_sn = sn + 1
self.block_list.remove(self.next_sn)
self.next_sn += 1
return True
except Exception as e:
raise Exception("recv_pool put sn:%d len:%d error:%r" % (sn, len(data), e))
Expand Down

0 comments on commit 4f2d992

Please sign in to comment.