-
Notifications
You must be signed in to change notification settings - Fork 7
Wait methods fixes [part 2] #145
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
Wait methods fixes [part 2] #145
Conversation
214c640 to
aa5e506
Compare
drewdzzz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the patch! I believe it improves connector usability quite a lot.
9a9401c to
0465dee
Compare
|
@mkostoevr @drewdzzz I got pissed off by #150, and discovered a bug #151 while fixing it. Please take a look at the two new commits I have added fixing those and at an additional bugfix for #147 that I added in the scope of |
d19648c to
a956eeb
Compare
`Connection`s model shared pointers on `ConnectionImpl` and are intended for external usage by library consumers. Using them internally in the Connector can cause bugs. For instance, we internally store `Connection` objects in the LibevNetProvider, which adds an additional reference to them and prevents them from being deleted, even when all user objects are dead. Also we leak connections in `close`, since we do not erase them from the `m_ReadyToSend` and `m_ReadyToDecode` sets. To fix this, let's internally use `ConnectionImpl` to model weak pointers. We rely on the fact that the lifetime of these weak pointers is tied to the lifetime of the shared user objects. The ideal solution would be to remove the `Connection`<-`ConnectionImpl` constructor, but we still need to return new Connection objects in methods like waitAny, so let's just enforce as a rule that we should not use `Connection` objects internally. While we are here, let's also fix all the formating issues that the linter is reporting for the refactored code. Closes tarantool#140 Closes tarantool#147
Currently, to avoid double-close of a connection we check for the `SS_DEAD` status on its stream. However, the `SS_DEAD` status can be set for a multitude of reasons without the connection being closed or even connected. For instance, we set it if a send/recv failed unrecoverably. To fix this, let's rely on the fact that a connection is open iff the file descriptor of its stream is a valid (i.e., not -1). This approach seems to be portable to the Windows platform too. Closes tarantool#142
Currently, all connection bookkeeping is done opaquely through the network providers which, in turn, also do this bookkeeping opaquely using system interfaces (e.g., libev, epoll). Because of this, we cannot handle cases when waitAny is called and there are no connections (tarantoolgh-51) or when a connection has ready responses (tarantoolgh-132). In order to improve `waitAny` robustness, we need to add connection bookkeeping to Connector. We should move the timer start to the beginning of the waiting loop, since the preceding checking overhead should not be accounted for the waiting time. Closes tarantool#51 Needed for tarantool#132
Currently, `waitAny` does not account for connections that already have ready responses. Let's handle this by going through the set of owned connections and checking them for ready responses. We should do this before the timer start, since the checking overhead should not be accounted for the waiting time. Closes tarantool#132
Currently, if we timeout waiting for `connect` using `poll`, we set `connect_errno` to `ETIMEOUT`. However, after we exit the `connect` interruption loop, we unconditionally set to `errno`, which we do not even clear after checking the `connect` result. As a result, the timeout error gets masked by the in-progress connection error. To fix this, let's: 1. Clear `errno` after checking the `connect` result; 2. Check the value of `connect_errno` after exiting the `connect` interrupt loop before setting it to `errno`; 3. Zero out `socket_errno`, `connect_errno` each `addr_info` loop iteration. Closes tarantool#151
`ClientMultithreadTest` fails on MacOS because the `connect`s are timing out. To fix this, let's increase the `connect_timeout` for `ClientMultithreadTest` to 10 seconds. Closes tarantool#150
1ad6d87 to
b06da2b
Compare
Currently, we have a bunch of free functions on ConnectionImpl and Connection, such as `hasSentBytes`, `hasNotRecvBytes`, `hasDataToSend`, `hasDataToDecode`, etc. All of them have a `ConnectionImpl` or `Connection` as an argument. This is an anti-pattern, and these functions need to be encapsulated in the corresponding classes. Closes tarantool#152
b06da2b to
3b81a8a
Compare
drewdzzz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, truly massive bugfix patchset! 😄
This patchset performs a major refactoring of the client code to replace all internal
Connectionusage withConnectionImpl, and fixes several related bugs.Closes #51
Closes #132
Closes #140
Closes #142
Closes #147
Closes #150
Closes #151
Closes #152