Skip to content

Commit

Permalink
fix bug: high cpu after close browser
Browse files Browse the repository at this point in the history
  • Loading branch information
xxnet committed May 7, 2015
1 parent f4d7363 commit 3c07068
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ XX-Net
下载链接:
==========
测试版:
https://codeload.github.com/XX-net/XX-Net/zip/1.13.6
https://codeload.github.com/XX-net/XX-Net/zip/1.14.1

稳定版:
https://codeload.github.com/XX-net/XX-Net/zip/1.13.6
Expand Down
20 changes: 14 additions & 6 deletions goagent/3.1.49/local/direct_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def handler(method, host, url, headers, body, wfile):
wfile.write("\r\n")
except Exception as e:
send_to_broswer = False
logging.warn("direct_handler.hanler send response fail. t:%d e:%r %s/%s", time.time()-time_request, e, host, url)
logging.warn("direct_handler.handler send response fail. t:%d e:%r %s/%s", time.time()-time_request, e, host, url)

if method == 'HEAD' or response.status in (204, 304):
logging.info("DIRECT t:%d %d %s %s", (time.time()-time_request)*1000, response.status, host, url)
Expand All @@ -125,13 +125,21 @@ def handler(method, host, url, headers, body, wfile):
data = e.partial

if send_to_broswer:
try:
if not data:
wfile.write('0\r\n\r\n')
break
length += len(data)
wfile.write('%x\r\n' % len(data))
wfile.write(data)
wfile.write('\r\n')
except Exception as e:
send_to_broswer = False
logging.warn("direct_handler.handler send Transfer-Encoding t:%d e:%r %s/%s", time.time()-time_request, e, host, url)
else:
if not data:
wfile.write('0\r\n\r\n')
break
length += len(data)
wfile.write('%x\r\n' % len(data))
wfile.write(data)
wfile.write('\r\n')

response.close()
logging.info("DIRECT chucked t:%d s:%d %d %s %s", (time.time()-time_request)*1000, length, response.status, host, url)
return
Expand Down

0 comments on commit 3c07068

Please sign in to comment.