[io/http] Fix race condition where RawSecureSocket dispatches read events after shutdown#62520
[io/http] Fix race condition where RawSecureSocket dispatches read events after shutdown#62520Colton127 wants to merge 2 commits intodart-lang:mainfrom
Conversation
|
Thank you for your contribution! This project uses Gerrit for code reviews. Your pull request has automatically been converted into a code review at: https://dart-review.googlesource.com/c/sdk/+/475941 Please wait for a developer to review your code review at the above link; you can speed up the review if you sign into Gerrit and manually add a reviewer that has recently worked on the relevant code. See CONTRIBUTING.md to learn how to upload changes to Gerrit directly. Additional commits pushed to this PR will update both the PR and the corresponding Gerrit CL. After the review is complete on the CL, your reviewer will merge the CL (automatically closing this PR). |
|
@Colton127 could you include this as a regression test (you can place it in // Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
//
// OtherResources=certificates/server_chain.pem
// OtherResources=certificates/server_key.pem
// Test that cancellation of subscription to [SecureSocket] works as
// expected.
import 'dart:async';
import 'dart:io';
import 'dart:typed_data';
import 'package:async_helper/async_helper.dart';
import 'package:expect/expect.dart';
String relativeToScript(path) => Platform.script.resolve(path).toFilePath();
final String serverCert = relativeToScript('certificates/server_chain.pem');
final String serverKey = relativeToScript('certificates/server_key.pem');
void main() {
asyncTest(() async {
final serverContext = SecurityContext()
..useCertificateChain(serverCert)
..usePrivateKey(serverKey, password: 'dartdart');
final secureServer = await SecureServerSocket.bind(
InternetAddress.loopbackIPv4,
0,
serverContext,
);
final dataStream = Stream.fromIterable(
Iterable<List<int>>.generate(100, (_) => Uint8List(1024 * 1024)),
);
secureServer.listen((client) async {
await dataStream.pipe(client);
await client.close();
});
final secureClient = await SecureSocket.connect(
InternetAddress.loopbackIPv4,
secureServer.port,
context: SecurityContext()..setTrustedCertificates(serverCert),
);
late final StreamSubscription clientSub;
clientSub = secureClient.listen((event) async {
clientSub.cancel();
});
await clientSub.asFuture();
await Future.wait([secureClient.close(), secureServer.close()]);
});
} |
|
@mraleph Got it, thank you |
|
https://dart-review.googlesource.com/c/sdk/+/475941 has been updated with the latest commits from this pull request. |
1 similar comment
|
https://dart-review.googlesource.com/c/sdk/+/475941 has been updated with the latest commits from this pull request. |
This PR resolves an issue where
RawSecureSocketpotentially emits aRawSocketEvent.readevent after the read-side of the socket has been closed. The receiver would then attempt to read from the socket, which throwsSocketException: Reading from a closed socket.Issue: #62514
Contribution guidelines:
dart format.Note that this repository uses Gerrit for code reviews. Your pull request will be automatically converted into a Gerrit CL and a link to the CL written into this PR. The review will happen on Gerrit but you can also push additional commits to this PR to update the code review.