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

msg/async: support of non-block connect in async messenger #5681

Closed

Conversation

zuiwanyuan
Copy link
Contributor

Async messenger should avoid all potential blocking point, but we use a block connect now.
So we must add this feature.

{
int ret = ::connect(sd, (sockaddr*)&addr.addr, addr.addr_size());

if (ret < 0 && errno != EISCONN) {
Copy link
Member

Choose a reason for hiding this comment

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

it maybe still in connecting(EINPROGRESS)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In reconnect , it must be wakened by poll(epoll) with an read event. That means it being connected or peer have sent some data to me. We can use reconnect to test whether it is connected or not. If it is connected, then errno will be EISCONN. If it is not connected, we will go to fail, and go to connecting again.

Copy link
Member

Choose a reason for hiding this comment

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

Actually it may not only wake up from epoll. AsyncConnection has time event which also can wakeup and it maybe legacy so that wakeup connection when connecting

@zuiwanyuan
Copy link
Contributor Author

In my test, the second commit have serious problem. I close the fd in fault(). Let me correct it,and test

if (r < 0) {
if (first_connect == true) {
Copy link
Member

Choose a reason for hiding this comment

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

What's the usage of "first_connect"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When first call nonblock_connect, if we call reconnect fail. We don't need to go to fail and retry, we just break. In other cases, we must retry.
When you have many breakdown peer, retrying may make msg thread busy, and also mark_down other peer wrongly.

Copy link
Member

Choose a reason for hiding this comment

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

If r < 0, we should goto fail. Only when r == EINPROGRESS, we always need to break and retry later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean "errno == EINPROGRESS"? Oh, at this time, the read event still exist. Yes, you are right.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

“2015-09-06 13:31:51.563489 7fcde1ffb700 20 -- :/1551015 >> 172.16.50.12:6789/0 conn(0x7fcde4171090 sd=18 :-1 s=STATE_CONNECTING_RE pgs=0 cs=0 l=1).process state is STATE_CONNECTING_RE, prev state is STATE_CONNECTING
2015-09-06 13:31:51.563497 7fcde1ffb700 10 NetHandler reconnect reconnect: Operation already in progress”
Subsquent calls to reconnect may return EALREADY, so we also check it. And let it to break?

Copy link
Member

Choose a reason for hiding this comment

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

Yep!

@tchaikov
Copy link
Contributor

tchaikov commented Sep 9, 2015

@zuiwanyuan needs rebase your pull request against master to resolve the conflicts.

and could you please

@zuiwanyuan zuiwanyuan changed the title support of non-block connect in async messenger msg/async: support of non-block connect in async messenger Sep 9, 2015
@zuiwanyuan zuiwanyuan closed this Sep 9, 2015
@zuiwanyuan zuiwanyuan deleted the wip-nonblock-connect branch September 9, 2015 06:26
@zuiwanyuan
Copy link
Contributor Author

@tchaikov I close this PR. And create a new one: "msg/async: support of non-block connect in async messenger #5848"

@tchaikov
Copy link
Contributor

tchaikov commented Sep 9, 2015

@zuiwanyuan , you could also git push -f to your remote branch of wip-nonblock-connect after fixing your commits. that would update this pull request automatically.

@zuiwanyuan
Copy link
Contributor Author

@tchaikov , thanks you. I get it now.

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