[gogo] lock contention in piped writer when reader doesn't read all input
-------------------------------------------------------------------------

                 Key: FELIX-2380
                 URL: https://issues.apache.org/jira/browse/FELIX-2380
             Project: Felix
          Issue Type: Bug
          Components: Gogo
            Reporter: Derek Baum
            Assignee: Derek Baum
            Priority: Minor


The following completes almost immediately:

g! cat conf/config.properties | grep Apache
# Licensed to the Apache Software Foundation (ASF) under one
# to you under the Apache License, Version 2.0 (the
true

but adding the --quiet flag to grep makes it take 1000mS longer:

g! cat conf/config.properties | grep --quiet Apache 
true

This is because grep stops reading its input as soon as it has seen the first 
match when --quiet is given.
The same delay also occurs if you pipe into a command that doesn't read its 
input:

g! cat conf/config.properties | echo

The contention occurs because the writer (cat) is blocked  on wait(1024) in 
PipedInputStream when the 1024 byte buffer is full. It is only unblocked when 
the reader (grep) reads more input. It is NOT unblocked when the reader closes 
the piped input.







-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to