Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: lock source to ensure no double reads happen #4

Closed
wants to merge 1 commit into from

Conversation

dignifiedquire
Copy link
Member

When the source is read very fast while the file descriptor is still
being opened it can come to double reads of chunks of the file. This
introduces a lock to avoid this issue.

When the source is read very fast while the file descriptor is still
being opened it can come to double reads of chunks of the file. This
introduces a lock to avoid this issue.
@dignifiedquire
Copy link
Member Author

Currently the tests for termination are failing, because the locking causes the abort only to be propagated after the previous read is done. I would appreciate some input on how to best solve this.

cc @DamonOehlman @dominictarr

@dignifiedquire
Copy link
Member Author

Not a 100% sure this is the best solution, for the issues I'm seeing. Any feedback and ideas very welcome 💭

@dominictarr
Copy link
Member

calling read in parallel is not a valid pull stream, this is a bug in the sink not this module. maybe what would help is a spec-stream you could drop in to debug the sink?

@@ -161,11 +165,16 @@ module.exports = function(filename, opts) {
readNext(cb);
};

var lockedSource = function (end, cb) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the locking causes the abort only to be propagated after the previous read is done. I would appreciate some input on how to best solve this.

what happens if a termination signal skips the lock?

something like:

var lockedSource = function (end, cb) {
  if (end) return source(end, cb)
  lock('source', function (release) {
    source(null, release(cb))
  })
}

@dominictarr
Copy link
Member

clarify: except you can abort out of term. but not do a valid read out of turn.

@dignifiedquire
Copy link
Member Author

@dominictarr thanks for pointing my nose into the right place, it was a bug in my code. Closing this PR.

@dominictarr
Copy link
Member

No problem!

On Sep 12, 2016 21:18, "Friedel Ziegelmayer" notifications@github.com
wrote:

Closed #4 #4.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#4 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAP1Li1gH_lDcbY-XrDstFnTCxWZoGSYks5qpRj3gaJpZM4J5sll
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants