@@ -89,7 +89,7 @@ private void OnListenPipe(UvStreamHandle pipe, int status, UvException error)
89
89
dispatchPipe . Init ( Thread . Loop , Thread . QueueCloseHandle , true ) ;
90
90
pipe . Accept ( dispatchPipe ) ;
91
91
92
- // Ensure client sends "Kestrel" before adding pipe to _dispatchPipes.
92
+ // Ensure client sends _pipeMessage before adding pipe to _dispatchPipes.
93
93
var readContext = new PipeReadContext ( this ) ;
94
94
dispatchPipe . ReadStart (
95
95
( handle , status2 , state ) => ( ( PipeReadContext ) state ) . AllocCallback ( handle , status2 ) ,
@@ -228,6 +228,18 @@ public LibuvFunctions.uv_buf_t AllocCallback(UvStreamHandle dispatchPipe, int su
228
228
229
229
public void ReadCallback ( UvStreamHandle dispatchPipe , int status )
230
230
{
231
+ if ( status == LibuvConstants . EOF && _bytesRead == 0 )
232
+ {
233
+ // This is an unexpected immediate termination of the dispatch pipe most likely caused by an
234
+ // external process scanning the pipe, so don't we don't log it too severely.
235
+ // https://github.com/aspnet/AspNetCore/issues/4741
236
+
237
+ dispatchPipe . Dispose ( ) ;
238
+ _bufHandle . Free ( ) ;
239
+ _listener . Log . LogDebug ( "An internal pipe was opened unexpectedly." ) ;
240
+ return ;
241
+ }
242
+
231
243
try
232
244
{
233
245
dispatchPipe . Libuv . ThrowIfErrored ( status ) ;
@@ -254,7 +266,7 @@ public void ReadCallback(UvStreamHandle dispatchPipe, int status)
254
266
}
255
267
else
256
268
{
257
- throw new IOException ( "Bad data sent over Kestrel pipe." ) ;
269
+ throw new IOException ( "Bad data sent over an internal pipe." ) ;
258
270
}
259
271
}
260
272
}
0 commit comments