Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Win32 named pipes and message size limits - is the old 64K limit still applicable?

Win32 used to have a message size limit of 64K for message-mode pipes, as witnessed by the remnants of KB article Q119218 PRB: Named Pipe Write() Limited to 64K. The "applies to" section lists only "Microsoft Win32 Application Programming Interface" and the article is rather old; there is no indication whether it also applies to reasonably current versions like Windows 7. Is there any reliable, current information on the issue?

The current online documentation contains only nebulous hints at unspecified limits, like this beautiful wording in the documentation for the CreateNamedPipe() function:

The input and output buffer sizes are advisory. The actual buffer size reserved for each end of the named pipe is either the system default, the system minimum or maximum, or the specified size rounded up to the next allocation boundary.

There is no indication what the 'system maximum' might be, or how one would query its value.

A 64K limit reappears in the documentation for TransactNamedPipe():

The maximum guaranteed size of a named pipe transaction is 64 kilobytes. In some limited cases, transactions beyond 64 kilobytes are possible, depending on OS versions participating in the transaction and dynamic network conditions. However, there is no guarantee that transactions above 64 kilobytes will succeed.

However, it might well be that the limit applies only to named pipe 'transactions' in the sense of TransactNamedPipe(); that is, a write followed by a read, all wrapped in a single system call and/or network transaction. The limit might be related to SMB and hence not applicable to local pipes. Is there any hard info on this?

Message-mode pipes would be a nice fit for a current project where server processes get fed a request packet and deliver a single response packet, with the dispatcher being a simple multi-threaded stub hosted in Apache (similar to mod_fcgid). Byte-mode pipes would require a bit of additional framing, which makes message-mode pipes seem simpler and thus preferable. However, it is not possible to limit request and response sizes to 64K; hence this question.

like image 881
DarthGizka Avatar asked Nov 05 '15 20:11

DarthGizka


1 Answers

No, there is no longer any such limitation.

The documentation for WriteFile says:

Windows Server 2003 and Windows XP: Pipe write operations across a network are limited in size per write. The amount varies per platform. For x86 platforms it's 63.97 MB. For x64 platforms it's 31.97 MB. For Itanium it's 63.95 MB.

From this we can conclude that the limitation does not apply to current versions of Windows, and probably only applied to XP when dealing with a network pipe.

We can also observe that if Q119218 was applicable to current versions of Windows, it would not have been archived.

Experimentally, I can confirm that on Windows 7 SP1 x64 a local message-mode pipe can handle messages well over a gigabyte in size. (I started getting "insufficient system resources" messages somewhere around the 1650MB mark.)

like image 132
Harry Johnston Avatar answered Nov 06 '22 06:11

Harry Johnston