Issue 8118 - [PATCH] tool_write_ldif: flush stdout
Summary: [PATCH] tool_write_ldif: flush stdout
Status: VERIFIED FIXED
Alias: None
Product: OpenLDAP
Classification: Unclassified
Component: slapd (show other issues)
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-29 16:57 UTC by Thomas Cort
Modified: 2015-07-02 17:50 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Thomas Cort 2015-04-29 16:57:41 UTC
Full_Name: Thomas Cort
Version: HEAD
OS: Mac OS X 10.10.3
URL: ftp://ftp.openldap.org/incoming/thomas-cort-150429.patch
Submission from: (NULL) (96.46.34.154)


The LDIF output wasn't being explicitly flushed. In certain scenarios,
such as piping the output of a persistent ldapsearch to node.js v0.12
on Mac OS X 10.10.3, the output is unavailable to the process
consuming the search results until some operating system limit is
reached (8192 bytes for example) and it is automatically flushed.
This can leave the tail end of persistent search results in an operating
system buffer for a long time (until enough output has accumulated
for the OS to flush it).

Explicitly call flush so that the output is immediately available.

I uploaded the patch to ftp.openldap.org as thomas-cort-150429.patch

The attached patch file is derived from OpenLDAP Software. All of the
modifications to OpenLDAP Software represented in the following patch(es) were
developed by Thomas Cort <linuxgeek@gmail.com>. I have not assigned rights
and/or interest in this work to any party.

I, Thomas Cort, hereby place the following modifications to OpenLDAP Software
(and only these modifications) into the public domain. Hence, these
modifications may be freely used and/or redistributed for any purpose with or
without attribution and/or other notice.
Comment 1 Howard Chu 2015-04-29 17:16:58 UTC
linuxgeek@gmail.com wrote:
> Full_Name: Thomas Cort
> Version: HEAD
> OS: Mac OS X 10.10.3
> URL: ftp://ftp.openldap.org/incoming/thomas-cort-150429.patch
> Submission from: (NULL) (96.46.34.154)
>
>
> The LDIF output wasn't being explicitly flushed. In certain scenarios,
> such as piping the output of a persistent ldapsearch to node.js v0.12
> on Mac OS X 10.10.3, the output is unavailable to the process
> consuming the search results until some operating system limit is
> reached (8192 bytes for example) and it is automatically flushed.
> This can leave the tail end of persistent search results in an operating
> system buffer for a long time (until enough output has accumulated
> for the OS to flush it).
>
> Explicitly call flush so that the output is immediately available.

That totally defeats the purpose of using stdio - which is, to generate 
buffered output and avoid excessive numbers of system calls.

Rejecting this patch. A more suitable patch might be one that flushes 
once when all currently available messages have been processed in 
ldapsearch.c. I.e., after the for-loop in dosearch() completes.

>
> I uploaded the patch to ftp.openldap.org as thomas-cort-150429.patch
>
> The attached patch file is derived from OpenLDAP Software. All of the
> modifications to OpenLDAP Software represented in the following patch(es) were
> developed by Thomas Cort <linuxgeek@gmail.com>. I have not assigned rights
> and/or interest in this work to any party.
>
> I, Thomas Cort, hereby place the following modifications to OpenLDAP Software
> (and only these modifications) into the public domain. Hence, these
> modifications may be freely used and/or redistributed for any purpose with or
> without attribution and/or other notice.
>
>


-- 
   -- Howard Chu
   CTO, Symas Corp.           http://www.symas.com
   Director, Highland Sun     http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP  http://www.openldap.org/project/

Comment 2 Thomas Cort 2015-04-29 17:37:16 UTC
> A more suitable patch might be one that flushes once when all currently
> available messages have been processed in ldapsearch.c.
> I.e., after the for-loop in dosearch() completes.

Here's an updated patch:

ftp://ftp.openldap.org/incoming/thomas-cort-150429b.patch
Comment 3 Howard Chu 2015-04-29 19:05:18 UTC
changed notes
changed state Open to Test
moved from Incoming to Software Bugs
Comment 4 Quanah Gibson-Mount 2015-04-30 00:06:53 UTC
changed notes
changed state Test to Release
Comment 5 OpenLDAP project 2015-07-02 17:50:47 UTC
in master
in RE25
in RE24
Comment 6 Quanah Gibson-Mount 2015-07-02 17:50:47 UTC
changed notes
changed state Release to Closed