http_client: Test a stray event while connecting #215

Open
koolkhel wants to merge 4 commits from koolkhel/vitastor:http-connect-stray-event-test into master
Contributor

Description

435301c1 stopped http_co_t::handle_events() from spinning forever when a connecting client gets an epoll event without EPOLLOUT or EPOLLERR, but came without a test. This adds one to test_http_client: it delivers EPOLLIN and EPOLLRDHUP to a client that is still connecting to a loopback listener (handlers mocked as in test_sync_error_leaves_no_timer), then EPOLLOUT, and checks that the request is still pending and reaches the listener, so the stray EPOLLRDHUP dropped by the connect handler (from d8e6486a) is covered too.

Found: seen in a run (hang): before 435301c1, a client process's event loop spun at 100% CPU inside http_co_t::handle_events() in the HTTP_CO_CONNECTING branch and never returned, matched against the binary's disassembly.

Tested: test_http_client passes on master; with the else { break; } from 435301c1 removed, the new case never returns (killed by a 20 s timeout); with this->epoll_events &= (EPOLLOUT|EPOLLIN); removed from the connect handler, it fails at the second assert(!done); with the send stubbed out, it fails waiting for the request on the listener.

Contributor Name

Yury Luneff (MIND Software LLC, https://mindsw.io)

CLA

### Description 435301c1 stopped `http_co_t::handle_events()` from spinning forever when a connecting client gets an epoll event without EPOLLOUT or EPOLLERR, but came without a test. This adds one to `test_http_client`: it delivers EPOLLIN and EPOLLRDHUP to a client that is still connecting to a loopback listener (handlers mocked as in `test_sync_error_leaves_no_timer`), then EPOLLOUT, and checks that the request is still pending and reaches the listener, so the stray EPOLLRDHUP dropped by the connect handler (from d8e6486a) is covered too. Found: seen in a run (hang): before 435301c1, a client process's event loop spun at 100% CPU inside `http_co_t::handle_events()` in the HTTP_CO_CONNECTING branch and never returned, matched against the binary's disassembly. Tested: test_http_client passes on master; with the `else { break; }` from 435301c1 removed, the new case never returns (killed by a 20 s timeout); with `this->epoll_events &= (EPOLLOUT|EPOLLIN);` removed from the connect handler, it fails at the second `assert(!done)`; with the send stubbed out, it fails waiting for the request on the listener. ### Contributor Name Yury Luneff (MIND Software LLC, https://mindsw.io) ### CLA - [x] I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
koolkhel added 1 commit 2026-12-01 21:25:15 +03:00
435301c1 stopped http_co_t::handle_events() from spinning forever when a
connecting client gets an epoll event without EPOLLOUT or EPOLLERR. Add a
test that delivers EPOLLIN and EPOLLRDHUP to a connecting client and checks
that it returns and still completes the connect afterwards.
koolkhel added 1 commit 2026-12-02 00:03:02 +03:00
The mock timerfd fires timers only from tick(), which this test never
calls.
koolkhel added 1 commit 2026-12-02 02:57:35 +03:00
A refused connect fails the same way whether or not a stray EPOLLRDHUP
is dropped once connect() completes. Connect to a listener and check that
the request is still pending after the stray events and the connect.
koolkhel added 1 commit 2026-12-02 04:48:06 +03:00
Every check in the stray event test was negative, so it also passed if
the client never sent the request once the connect completed. Accept
the connection on the listener and check that the request arrives.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u http-connect-stray-event-test:koolkhel-http-connect-stray-event-test
git checkout koolkhel-http-connect-stray-event-test
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#215
No description provided.