feat: TCP-only builds; TCP options and timeouts; receives that report and keep what arrived
- --no-quic leaves QUIC, HTTP/3 and WebTransport out of the build, and with
them msquic: a consumer that only needs TCP builds no msquic. The flag
isn't passed on to dependencies.
- --local takes Crafter.Thread from the sibling checkout, as the other
Crafter projects do.
- ClientTCP gains SetNoDelay, SetReceiveTimeout, a connect timeout and
SocketTimeoutException.
- TCP receives return the bytes that arrived:
- RecieveSync(n) returned the whole buffer when fewer had come;
- RecieveUntilCloseSync truncated what it had read;
- a signal (EINTR) during a receive threw where it should wait on;
- RecieveSync(size, buffer) returns the count and throws like the others;
- a receive of no bytes returns at once: recv's 0 for it isn't a close.
- Every TCP *Async receive takes an onError(std::exception_ptr): an
exception escaping a ThreadPool task ended the program. An empty onError
drops the error.
- QUIC streams:
- async receives deliver an empty chunk on close, as the browser build does;
- RecieveUntilFullAsync gives what arrived on a stream that closes early;
- RecieveUntilFullSync takes all it asked for or nothing, under one hold
of the lock, so what did arrive stays for the next receive and no
other receive can take bytes from among it;
- SendAsync's callback hears whether the send went out (bool sent): native,
browser, the JS bridge and the example.
- msquic is pinned to v2.6.3 and built against the system OpenSSL
(QUIC_TLS_LIB=openssl, 3.5 or newer). Its bundled quictls read the system's
openssl.cnf, and the Flatpak runtime's (a PKCS#11 engine, with
config_diagnostics on) made it fail to initialise. The README says to use
--no-quic where the distro's OpenSSL is older.
- Tests now register on any Linux triple: they never ran under the Flatpak's
x86_64-unknown-linux-gnu. New: ShouldBuildWithoutQUIC, ShouldConfigureTCP,
ShouldRecieveTCP, ShouldReportClosedQUICStream.
Breaking: SendAsync's callback takes a bool, the TCP *Async receives take
an onError, and RecieveSync(size, buffer) returns the count.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
05f7652770
commit
f683216850
14 changed files with 1216 additions and 382 deletions
|
|
@ -101,8 +101,8 @@ namespace Crafter::NetworkBrowser {
|
|||
static std::unordered_map<std::int32_t, ConnectionState*> m;
|
||||
return m;
|
||||
}
|
||||
inline std::unordered_map<std::int32_t, std::function<void()>>& WriteCallbacks() {
|
||||
static std::unordered_map<std::int32_t, std::function<void()>> m;
|
||||
inline std::unordered_map<std::int32_t, std::function<void(bool)>>& WriteCallbacks() {
|
||||
static std::unordered_map<std::int32_t, std::function<void(bool)>> m;
|
||||
return m;
|
||||
}
|
||||
inline std::int32_t NextWriteCallbackId() {
|
||||
|
|
@ -200,9 +200,9 @@ QUICStream::~QUICStream() {
|
|||
}
|
||||
|
||||
void QUICStream::SendAsync(const void* buffer, std::uint32_t size, bool finish,
|
||||
std::function<void()> onSent) {
|
||||
std::function<void(bool sent)> onSent) {
|
||||
if (!impl || impl->state.handle == 0 || impl->state.closed) {
|
||||
if (onSent) onSent();
|
||||
if (onSent) onSent(false);
|
||||
return;
|
||||
}
|
||||
std::int32_t cbId = 0;
|
||||
|
|
@ -402,13 +402,14 @@ extern "C" {
|
|||
TryDispatchRecv(s);
|
||||
}
|
||||
|
||||
// `sent` is nonzero when the write (and the close, with finish) resolved.
|
||||
__attribute__((export_name("CrafterNetworkOnWtStreamWriteComplete")))
|
||||
void CrafterNetworkOnWtStreamWriteComplete(std::int32_t callbackId) {
|
||||
void CrafterNetworkOnWtStreamWriteComplete(std::int32_t callbackId, std::int32_t sent) {
|
||||
auto it = WriteCallbacks().find(callbackId);
|
||||
if (it == WriteCallbacks().end()) return;
|
||||
auto cb = std::move(it->second);
|
||||
WriteCallbacks().erase(it);
|
||||
if (cb) cb();
|
||||
if (cb) cb(sent != 0);
|
||||
}
|
||||
|
||||
__attribute__((export_name("CrafterNetworkOnWtDatagram")))
|
||||
|
|
|
|||
Loading…
Reference in a new issue