From 819f3be3585e125328025113780e2f326cc7a3e9 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 2 Aug 2010 18:54:53 +0000 Subject: Add code for a threaded LDAP access to replace the wrapper process. Currently used for W32 and W32CE. --- common/ChangeLog | 4 ++++ common/estream.c | 23 ++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/ChangeLog b/common/ChangeLog index a60cf1ea8..05611f9c8 100644 --- a/common/ChangeLog +++ b/common/ChangeLog @@ -1,3 +1,7 @@ +2010-07-26 Werner Koch + + * estream.c (es_func_fp_write) [W32]: Write smaller chunks. + 2010-07-25 Werner Koch * argparse.c (initialize): Use ARGPARSE_PRINT_WARNING constant. diff --git a/common/estream.c b/common/estream.c index ec7c7099b..f3ba109ee 100644 --- a/common/estream.c +++ b/common/estream.c @@ -955,7 +955,28 @@ es_func_fp_write (void *cookie, const void *buffer, size_t size) if (file_cookie->fp) - bytes_written = fwrite (buffer, 1, size, file_cookie->fp); + { +#ifdef HAVE_W32_SYSTEM + /* Using an fwrite to stdout connected to the console fails with + the error "Not enough space" for an fwrite size of >= 52KB + (tested on Windows XP SP2). To solve this we always chunk + the writes up into smaller blocks. */ + bytes_written = 0; + while (bytes_written < size) + { + size_t cnt = size - bytes_written; + + if (cnt > 32*1024) + cnt = 32*1024; + if (fwrite ((const char*)buffer + bytes_written, + cnt, 1, file_cookie->fp) != 1) + break; /* Write error. */ + bytes_written += cnt; + } +#else + bytes_written = fwrite (buffer, 1, size, file_cookie->fp); +#endif + } else bytes_written = size; /* Successfully written to the bit bucket. */ if (bytes_written != size) -- cgit v1.2.3