diff options
author | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2003-06-06 02:34:03 +0000 |
---|---|---|
committer | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2003-06-06 02:34:03 +0000 |
commit | aec493328f4cd1a6d717743c984a153dc120013a (patch) | |
tree | 22ac172cd2a9920b7d33711a25947c5c98e8cef2 /winpipes.cpp | |
parent | e3e0c6c7d2d37b902060ffefc27270675fbf246b (diff) | |
download | cryptopp-aec493328f4cd1a6d717743c984a153dc120013a.tar.gz |
sync with private branch
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@76 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'winpipes.cpp')
-rw-r--r-- | winpipes.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/winpipes.cpp b/winpipes.cpp index a195d17..d125a6b 100644 --- a/winpipes.cpp +++ b/winpipes.cpp @@ -86,12 +86,13 @@ WindowsPipeReceiver::WindowsPipeReceiver() m_overlapped.hEvent = m_event; } -void WindowsPipeReceiver::Receive(byte* buf, unsigned int bufLen) +bool WindowsPipeReceiver::Receive(byte* buf, unsigned int bufLen) { assert(!m_resultPending && !m_eofReceived); HANDLE h = GetHandle(); - if (ReadFile(h, buf, bufLen, &m_lastResult, &m_overlapped)) + // don't queue too much at once, or we might use up non-paged memory + if (ReadFile(h, buf, STDMIN(bufLen, 128U*1024U), &m_lastResult, &m_overlapped)) { if (m_lastResult == 0) m_eofReceived = true; @@ -111,6 +112,7 @@ void WindowsPipeReceiver::Receive(byte* buf, unsigned int bufLen) m_resultPending = true; } } + return !m_resultPending; } void WindowsPipeReceiver::GetWaitObjects(WaitObjectContainer &container) @@ -163,7 +165,8 @@ void WindowsPipeSender::Send(const byte* buf, unsigned int bufLen) { DWORD written = 0; HANDLE h = GetHandle(); - if (WriteFile(h, buf, bufLen, &written, &m_overlapped)) + // don't queue too much at once, or we might use up non-paged memory + if (WriteFile(h, buf, STDMIN(bufLen, 128U*1024U), &written, &m_overlapped)) { m_resultPending = false; m_lastResult = written; |