@@ -90,7 +90,7 @@ class ConnectionServer {
90
90
final CodecRegistry ? _codecRegistry;
91
91
final GrpcErrorHandler ? _errorHandler;
92
92
final ServerKeepAliveOptions _keepAliveOptions;
93
- final List <ServerHandler > _handlers = [] ;
93
+ final Map < ServerTransportConnection , List <ServerHandler >> _handlers = {} ;
94
94
95
95
final _connections = < ServerTransportConnection > [];
96
96
@@ -117,6 +117,7 @@ class ConnectionServer {
117
117
InternetAddress ? remoteAddress,
118
118
}) async {
119
119
_connections.add (connection);
120
+ _handlers[connection] = [];
120
121
// TODO(jakobr): Set active state handlers, close connection after idle
121
122
// timeout.
122
123
final onDataReceivedController = StreamController <void >();
@@ -128,7 +129,7 @@ class ConnectionServer {
128
129
dataNotifier: onDataReceivedController.stream,
129
130
).handle ();
130
131
connection.incomingStreams.listen ((stream) {
131
- _handlers.add (serveStream_ (
132
+ _handlers[connection] ! .add (serveStream_ (
132
133
stream: stream,
133
134
clientCertificate: clientCertificate,
134
135
remoteAddress: remoteAddress,
@@ -143,10 +144,11 @@ class ConnectionServer {
143
144
// half-closed tcp streams.
144
145
// Half-closed streams seems to not be fully supported by package:http2.
145
146
// https://github.com/dart-lang/http2/issues/42
146
- for (var handler in _handlers) {
147
+ for (var handler in _handlers[connection] ! ) {
147
148
handler.cancel ();
148
149
}
149
150
_connections.remove (connection);
151
+ _handlers.remove (connection);
150
152
await onDataReceivedController.close ();
151
153
});
152
154
}
0 commit comments