summaryrefslogtreecommitdiff
path: root/winpipes.cpp
diff options
context:
space:
mode:
authorweidai <weidai11@users.noreply.github.com>2003-06-06 02:34:03 +0000
committerweidai <weidai11@users.noreply.github.com>2003-06-06 02:34:03 +0000
commit6c4437d03df6a1beadfadfc7c5388005c69665db (patch)
tree22ac172cd2a9920b7d33711a25947c5c98e8cef2 /winpipes.cpp
parent2f50e8eac958f5a1bf7be05aeac015e5ee400927 (diff)
downloadcryptopp-git-6c4437d03df6a1beadfadfc7c5388005c69665db.tar.gz
sync with private branch
Diffstat (limited to 'winpipes.cpp')
-rw-r--r--winpipes.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/winpipes.cpp b/winpipes.cpp
index a195d174..d125a6be 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;