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

fix, unix socket bind should be only used in passive mode #373

Merged
merged 3 commits into from
May 23, 2022

Conversation

cscps
Copy link
Contributor

@cscps cscps commented May 22, 2022


name: Pull request
about: Propose changes to the code
title: ''
labels: ''
assignees: ''

1. Are you opening this pull request for bug-fixes, optimizations or new feature?

bug-fixes

2. Please describe how these code changes achieve your intention.

unix socket bind should be only used in passive mode
When using non-blocking socket as client, we should not close fd for EINPROGRESS error

3. Please link to the relevant issues (if any).

4. Which documentation changes (if any) need to be made/updated because of this PR?

4. Checklist

  • I have squashed all insignificant commits.
  • I have commented my code for explaining package types, values, functions, and non-obvious lines.
  • I have written unit tests and verified that all tests passes (if needed).
  • I have documented feature info on the README (only when this PR is adding a new feature).
  • (optional) I am willing to help maintain this change if there are issues with it later.

@panjf2000
Copy link
Owner

Good catch! please also make the same change to tcp_socket.go and udp_socket.go

@panjf2000 panjf2000 added waiting for response waiting for the response from commenter pending development Requested PR owner to improve code and waiting for the result needs fix labels May 22, 2022
@panjf2000
Copy link
Owner

Also, I wonder why the system call - bind() didn't raise an error when it's called by client socket.

@cscps
Copy link
Contributor Author

cscps commented May 22, 2022

the client of gnet is sync using built in net.Dial, it will never call this function. I found it when implementing my own async client code

@panjf2000
Copy link
Owner

the client of gnet is sync using built in net.Dial, it will never call this function. I found it when implementing my own async client code

You're right, I forgot that. Now please apply the same code changes to the other files.

@cscps
Copy link
Contributor Author

cscps commented May 22, 2022

ok, I foget :(

Copy link
Owner

@panjf2000 panjf2000 left a comment

Choose a reason for hiding this comment

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

Please take a look at these review comments.

@codecov
Copy link

codecov bot commented May 23, 2022

Codecov Report

Merging #373 (4331027) into dev (8d921f9) will decrease coverage by 0.68%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##              dev     #373      +/-   ##
==========================================
- Coverage   72.04%   71.36%   -0.69%     
==========================================
  Files          13       13              
  Lines        1381     1390       +9     
==========================================
- Hits          995      992       -3     
- Misses        318      326       +8     
- Partials       68       72       +4     
Flag Coverage Δ
unittests 71.36% <ø> (-0.69%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
connection.go 65.61% <0.00%> (-3.00%) ⬇️
client.go 50.65% <0.00%> (+0.32%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8d921f9...4331027. Read the comment docs.

@panjf2000 panjf2000 merged commit 2ae824a into panjf2000:dev May 23, 2022
@panjf2000
Copy link
Owner

Thanks~

@zhu121
Copy link

zhu121 commented May 24, 2022

@ccssrryy
There is a question, EINPROGRESS should occur when connect() is called, and when fd is non-blocking; but why the code change is to judge this error when socket() is called

@cscps
Copy link
Contributor Author

cscps commented May 24, 2022

@ccssrryy There is a question, EINPROGRESS should occur when connect() is called, and when fd is non-blocking; but why the code change is to judge this error when socket() is called

The error check is in defer which is checking returned error, not only for socket() call

0-haha pushed a commit to 0-haha/gnet that referenced this pull request Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs fix pending development Requested PR owner to improve code and waiting for the result waiting for response waiting for the response from commenter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants