Skip to content

Commit

Permalink
Test: fix test_sigpipe of the ClientTest suite
Browse files Browse the repository at this point in the history
There are two fixes required:
1. The request payload size needs to be increased on Linux to guarantee
that more than one send is required.
2. Due to the peculiarities of how closed connections are handled in Linux
[1, 2], an explicit socket shutdown is required in order to get a  EPIPE
error rather than a ECONNRESET.

Closes #53

1. https://stackoverflow.com/a/33053926
2. https://stackoverflow.com/a/2979806
  • Loading branch information
CuriousGeorgiy committed Nov 15, 2023
1 parent 82b6919 commit 26c28df
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
5 changes: 1 addition & 4 deletions test/ClientTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,12 +712,9 @@ test_sigpipe(Connector<BUFFER, NetProvider> &client)
* Create a large payload so that request needs at least 2 `send`s, the
* latter being written to a closed socket.
*/
rid_t f = conn.space[0].replace(std::vector<uint64_t>(100000, 777));
rid_t f = conn.space[0].replace(std::vector<uint64_t>(500000, 777));
fail_if(client.wait(conn, f, WAIT_TIMEOUT) == 0);
#ifdef __FreeBSD___
/* FIXME(gh-53) reenable the test if possible. */
fail_unless(conn.getError().saved_errno == EPIPE);
#endif
fail_if(conn.futureIsReady(f));
}

Expand Down
1 change: 1 addition & 0 deletions test/Utils/System.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ launchDummyServer(const char *addr, int port)
::exit(EXIT_FAILURE);
}

::shutdown(accepted_sock, SHUT_RDWR);
::close(accepted_sock);

::exit(EXIT_SUCCESS);
Expand Down

0 comments on commit 26c28df

Please sign in to comment.