File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -2510,6 +2510,23 @@ _dispatch_operation_perform(dispatch_operation_t op)
2510
2510
}
2511
2511
bSuccess = TRUE;
2512
2512
} else if (GetFileType (hFile ) == FILE_TYPE_PIPE ) {
2513
+ // WriteFile with more bytes than are available in the
2514
+ // buffer of a NOWAIT pipe will immediately return 0,
2515
+ // so clamp our requested write length to make progress.
2516
+ IO_STATUS_BLOCK iosb ;
2517
+ FILE_PIPE_LOCAL_INFORMATION fpli ;
2518
+ NTSTATUS status = _dispatch_NtQueryInformationFile (hFile ,
2519
+ & iosb , & fpli , sizeof (fpli ), FilePipeLocalInformation );
2520
+ if (NT_SUCCESS (status )) {
2521
+ // WriteQuotaAvailable is unreliable in the presence
2522
+ // of a blocking reader, when it can return zero, so only
2523
+ // account for it otherwise
2524
+ if (fpli .WriteQuotaAvailable > 0 ) {
2525
+ len = MIN (len , fpli .WriteQuotaAvailable );
2526
+ }
2527
+ len = MIN (len , fpli .OutboundQuota );
2528
+ }
2529
+
2513
2530
OVERLAPPED ovlOverlapped = {};
2514
2531
bSuccess = WriteFile (hFile , buf , (DWORD )len ,
2515
2532
(LPDWORD )& processed , & ovlOverlapped );
You can’t perform that action at this time.
0 commit comments