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

Incorrectly implemented Close() operation #29

Closed
hpfousac opened this issue Feb 18, 2022 · 3 comments
Closed

Incorrectly implemented Close() operation #29

hpfousac opened this issue Feb 18, 2022 · 3 comments

Comments

@hpfousac
Copy link

Func Close() sends logout packet, then immediately close the socket, without waiting to server's response.
It causes:

  • At server: logged error messge A client process exited abnormally, or a network error was encountered.
  • At network level: multiple TCP RST packets are sent back to the server, when logout response arrives
@hpfousac
Copy link
Author

strace output

Erroneous behaviour

Note irrelevant lines are not exposed here

[pid   234] write(3, "\17\1\0\n\0\0\0\0q\0", 10 <unfinished ...> ## LOGOUT PACKET
[pid   234] <... write resumed>)        = 10

[pid   234] close(3 <unfinished ...>
[pid   234] <... close resumed>)        = 0

After fix

not confirmed yet from db admin

[pid   334] 14:34:16 socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP <unfinished ...>
[pid   334] 14:34:16 <... socket resumed>) = 3
[pid   334] 14:34:16 connect(3, {sa_family=AF_INET, sin_port=htons(4100), sin_addr=inet_addr("10.6.14.150")}, 16 <unfinished ...>
[pid   330] 14:34:16 <... connect resumed>) = 0

[pid   330] 14:34:16 write(3, "\17\1\0\n\0\0\0\0q\0", 10 <unfinished ...>
[pid   330] 14:34:16 <... write resumed>) = 10

[pid   330] 14:34:16 read(3,  <unfinished ...>
[pid   333] 14:34:16 <... nanosleep resumed>NULL) = 0
[pid   330] 14:34:16 read(3,  <unfinished ...>
[pid   330] 14:34:16 <... read resumed>"\1", 1) = 1
[pid   330] 14:34:16 read(3,  <unfinished ...>
[pid   330] 14:34:16 read(3,  <unfinished ...>
[pid   330] 14:34:16 <... read resumed>"\0\0", 2) = 2
[pid   330] 14:34:16 read(3,  <unfinished ...>
[pid   330] 14:34:16 <... read resumed>"\0", 1) = 1
[pid   330] 14:34:16 read(3,  <unfinished ...>
[pid   330] 14:34:16 <... read resumed>"\0", 1) = 1
[pid   330] 14:34:16 read(3,  <unfinished ...>
[pid   330] 14:34:16 <... read resumed>"\375\0\0\2\0\1\0\0\0", 9) = 9
[pid   330] 14:34:16 close(3)           = 0

@thda
Copy link
Owner

thda commented Mar 7, 2022

Thanks for the feedback,

I've reviewed your PR, can you please take a look before I merge ?

@hpfousac
Copy link
Author

Hello, there is nothing for aditional review from my side.

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

No branches or pull requests

2 participants