Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Waiting the remaining tcp data are sent #4501

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lygstate
Copy link
Contributor

@lygstate lygstate commented Jan 18, 2021

So that the tcp socket are closed by debugger client first and
the debugger client won't receive socket are closed by remote error

The error message:
Test command:
cmd \
	/S \
	/C \
	C:\hostedtoolcache\windows\Python\3.7.9\x64\python.exe \
	D:\a\jerryscript\jerryscript\tools\runners/run-debugger-test.py \
	D:\a\jerryscript\jerryscript\build\tests\jerry_debugger_tests\local\bin\jerry.exe \
	websocket \
	D:\a\jerryscript\jerryscript\jerry-debugger/jerry_client.py \
	tests\debugger\do_abort
run debug server: D:\a\jerryscript\jerryscript\build\tests\jerry_debugger_tests\local\bin\jerry.exe tests\debugger\do_abort.js --start-debug-server --debug-channel websocket
run debug client: cmd /S /C C:\hostedtoolcache\windows\Python\3.7.9\x64\python.exe D:\a\jerryscript\jerryscript\jerry-debugger/jerry_client.py --channel websocket --non-interactive
input debug cmd: tests\debugger\do_abort.cmd
['git', '--no-pager', 'diff', '--ignore-space-at-eol', '--no-index', 'tests\\debugger\\do_abort.expected', 'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\do_abort5k9rpkyiout']
FAIL: tests\debugger\do_abort
warning: LF will be replaced by CRLF in C:\Users\RUNNER~1\AppData\Local\Temp\do_abort5k9rpkyiout.
The file will have its original line endings in your working directory
diff --git "a/tests\\debugger\\do_abort.expected" "b/C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\do_abort5k9rpkyiout"
index 7656e41..8d31910 100644
--- "a/tests\\debugger\\do_abort.expected"
+++ "b/C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\do_abort5k9rpkyiout"
@@ -10,3 +10,5 @@ Stopped at tests/debugger/do_abort.js:20 (in g() at line:19, col:1)
 Stopped at tests/debugger/do_abort.js:16 (in f() at line:15, col:1)
 (jerry-debugger) abort new Error('Fatal error :)')
 err: Error: Fatal error :)
+Failed to connect to the JerryScript debugger.
+Error: [WinError 10054] An existing connection was forcibly closed by the remote host

This is the random failure I am talking about:
https://github.com/jerryscript-project/jerryscript/runs/1721915835

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo [email protected]

@lygstate lygstate closed this Jan 19, 2021
@lygstate lygstate force-pushed the socket-closed-by-remote branch from ecbbe96 to d97540e Compare January 19, 2021 00:15
@lygstate lygstate reopened this Jan 23, 2021
@lygstate lygstate force-pushed the socket-closed-by-remote branch 3 times, most recently from 496b146 to a792221 Compare January 23, 2021 04:19
@lygstate lygstate force-pushed the socket-closed-by-remote branch from a792221 to bb174bc Compare January 23, 2021 04:25
@@ -144,6 +144,26 @@ jerryx_debugger_tcp_close (jerry_debugger_transport_header_t *header_p) /**< tcp

jerryx_debugger_transport_tcp_t *tcp_p = (jerryx_debugger_transport_tcp_t *) header_p;

/* Waiting the debug client close the tcp connection first */
for (;;)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use while(true)

The problem is this loop might never ends.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap, any suggestion? post here looking for suggestion

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use while(true)

The problem is this loop might never ends.

maybe we doesn't need consider that, as when debugger stopping, means the debug client always closing the socket?

@lygstate lygstate requested a review from zherczeg January 23, 2021 12:30
@lygstate lygstate force-pushed the socket-closed-by-remote branch from bb174bc to 1078318 Compare January 23, 2021 14:13
Copy link
Member

@zherczeg zherczeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about simply ignoring error 10054 on windows?

@@ -144,6 +144,26 @@ jerryx_debugger_tcp_close (jerry_debugger_transport_header_t *header_p) /**< tcp

jerryx_debugger_transport_tcp_t *tcp_p = (jerryx_debugger_transport_tcp_t *) header_p;

/* Waiting the debug client close the tcp connection first */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment: Waiting for the debug client close the tcp connection first.

{
/**
* If result >= 0, this means that there is either data available on the socket, or the socket
* has been closed. So waiting the socket closed by remote client by result == 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part breaks the loop. Where is the 'waiting' part?

Copy link
Contributor Author

@lygstate lygstate Feb 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

== 0 means remote closed the tcp socket, > 0 means still have data, < 0 means have error, JERRYX_EWOULDBLOCK error should be ignored(means have no data but the tcp socket still there)

@rerobika
Copy link
Member

rerobika commented Feb 4, 2021

@zherczeg Just to clarify that's not only windows related issue. https://github.com/jerryscript-project/jerryscript/runs/1721915835#step:5:708

@lygstate lygstate force-pushed the socket-closed-by-remote branch 2 times, most recently from 60eed79 to 18c2040 Compare February 5, 2021 05:20
So that the tcp socket are closed by debugger client first and
the debugger client won't receive socket are closed by remote error

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo [email protected]
@lygstate lygstate force-pushed the socket-closed-by-remote branch from 18c2040 to a2d7a70 Compare February 5, 2021 05:45
@zherczeg
Copy link
Member

zherczeg commented Feb 5, 2021

I am still curious: [WinError 10054] An existing connection was forcibly closed by the remote host - this is a hint, not an error, why can't we simply ignore it?

@lygstate
Copy link
Contributor Author

lygstate commented Feb 5, 2021

I am still curious: [WinError 10054] An existing connection was forcibly closed by the remote host - this is a hint, not an error, why can't we simply ignore it?

Are you talking about ignore the error in python side?
There is a testcase that restart the jerry engine in debugger, so ignore this error is not acceptable, as you don't know it's a abnormal connection disconnect or an disconnection that caused by the user(the restart debug instruction).

@zherczeg
Copy link
Member

zherczeg commented Feb 5, 2021

In the restart debug case you are expecting a restart, it doesn't matter if it fails why it fails. A successful close does not guarantee that the restart will successful. So I still don't get why we cannot ignore this.

@lygstate
Copy link
Contributor Author

lygstate commented Feb 5, 2021

In the restart debug case you are expecting a restart, it doesn't matter if it fails why it fails. A successful close does not guarantee that the restart will successful. So I still don't get why we cannot ignore this.

As I said, we can not disinguish normal disconnection(restart instruction) or it's the jerry executable crash(cause connection reset).
So it's better to waiting normal close when restarting, and when crash, [WinError 10054] happens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants