Skip to content

WriteStream: use libgit2's error when we fail to write to the next stream #1107

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

Merged
merged 1 commit into from
Jun 19, 2015

Conversation

carlosmn
Copy link
Member

This should let us see what libgit2 thinks the problem is when we fail to pass the data forward.

#1030 (comment)

@@ -53,9 +53,10 @@ public override void Write(byte[] buffer, int offset, int count)
{
fixed (byte* bufferPtr = &buffer[offset])
{
if (nextStream.write(nextPtr, (IntPtr)bufferPtr, (UIntPtr)count) < 0)
int ret = nextStream.write(nextPtr, (IntPtr)bufferPtr, (UIntPtr)count);
if (ret < 0)
Copy link
Member

Choose a reason for hiding this comment

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

Is write ever expected to return a positive number? If not, we can skip this check here.

Copy link
Member

Choose a reason for hiding this comment

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

Or use Ensure.Int32Result(ret).

And FWIW, we typically use res rather than ret.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yes, I'd missed that, that's the function we should use.

@dahlbyk
Copy link
Member

dahlbyk commented Jun 19, 2015

Does it matter if we check res inside or outside the fixed block? Proxy.git_odb_stream_write() checks ouside.

@carlosmn
Copy link
Member Author

It shouldn't particularly matter whether we do it inside or not, all it's doing is askiing the GC not to move something to which the caller has a reference, so it shouldn't be touching it; but it does seem good form to keep the fixed block to be as small as possible.

@carlosmn carlosmn force-pushed the cmn/ensure-next-stream branch from 3c88b78 to ce5db5e Compare June 19, 2015 12:38
@@ -51,14 +51,14 @@ public override void Write(byte[] buffer, int offset, int count)
{
unsafe
{
int res;
Copy link
Member

Choose a reason for hiding this comment

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

Have to define this outside the unsafe

@carlosmn carlosmn force-pushed the cmn/ensure-next-stream branch from ce5db5e to a6dccd1 Compare June 19, 2015 12:52
@dahlbyk
Copy link
Member

dahlbyk commented Jun 19, 2015

👍 assuming we're green

@whoisj
Copy link

whoisj commented Jun 19, 2015

👍

nulltoken added a commit that referenced this pull request Jun 19, 2015
WriteStream: use libgit2's error when we fail to write to the next stream
@nulltoken nulltoken merged commit 0e3b9f8 into vNext Jun 19, 2015
@nulltoken nulltoken deleted the cmn/ensure-next-stream branch June 19, 2015 21:37
@nulltoken nulltoken added this to the v0.22 milestone Jun 19, 2015
@nulltoken
Copy link
Member

👍

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.

4 participants