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

change NextMsgLen() to return an uint32 instead of int (fixes #7) #8

Closed
wants to merge 1 commit into from

Conversation

cryptix
Copy link
Contributor

@cryptix cryptix commented Aug 29, 2015

see discussion on #7

@jbenet
Copy link
Owner

jbenet commented Aug 29, 2015

this LGTM. @whyrusleeping check? (important not to screw this up)

@cryptix
Copy link
Contributor Author

cryptix commented Aug 30, 2015

Uhm, wait.. s.more is never false here. Before it would return the last size in case of an error and not try to read the next header. Right now you can take out s.more all together and the tests still pass.

if _, err := io.ReadFull(s.R, s.lbuf); err != nil {
return 0, err
}
s.next = int(NBO.Uint32(s.lbuf))
n := NBO.Uint32(s.lbuf)
if n < 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

will this ever be true? if its a uint32?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, I overdid it.

Copy link
Owner

Choose a reason for hiding this comment

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

going to remove this?

was waiting for this to merge, but need my changes (#9) sooner. also cleans up all this logic and puts it in one place-- may be easier to rebase on that than vv

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, Sure - i can rebase, got derailed again. Actually only saw this twice on a box. I guess it was a dying client or something.

Sent from my iPhone

On 04.09.2015, at 16:32, Juan Benet notifications@github.com wrote:

In msgio.go:

    if _, err := io.ReadFull(s.R, s.lbuf); err != nil {
        return 0, err
    }
  •   s.next = int(NBO.Uint32(s.lbuf))
    
  •   n := NBO.Uint32(s.lbuf)
    
  •   if n < 0 {
    
    going to remove this?

was waiting for this to merge, but need my changes (#9) sooner. also cleans up all this logic and puts it in one place-- may be easier to rebase on that than vv


Reply to this email directly or view it on GitHub.

@cryptix cryptix force-pushed the NextMsgLen branch 2 times, most recently from dbf86f4 to 7e1bd4b Compare September 11, 2015 15:13
@cryptix
Copy link
Contributor Author

cryptix commented Sep 11, 2015

@jbenet @whyrusleeping rebased - can you take another look?

if s.next > s.max {
return 0, ErrMsgTooLarge
}

Copy link
Owner

Choose a reason for hiding this comment

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

the point of this function is to cache the result of ReadLen. i believe it will be called multiple times before another read is merited.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@jbenet I dont think thats right.

// NextMsgLen reads the length of the next msg into s.lbuf, and returns it.
// WARNING: like Read, NextMsgLen is destructive. It reads from the internal
// reader.  

Copy link
Owner

Choose a reason for hiding this comment

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

look at the older code. it's meant to be able to call nextMsgLen multiple times.

Copy link
Collaborator

Choose a reason for hiding this comment

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

oooh, okay. so the comment on NextMsgLen is incorrect.

@jbenet
Copy link
Owner

jbenet commented Sep 14, 2015

The commit claims "change NextMsgLen() to return an uint32 instead of int ". this commit also changes nextMsgLen to something that i think is incorrect, as the func will be called multiple times.

Maybe divide this into two PRs? the Errs and uint32 makes sense to me, and is merge ready. the other stuff currently does not.

@whyrusleeping
Copy link
Collaborator

@jbenet @cryptix ping!

@jbenet
Copy link
Owner

jbenet commented Sep 30, 2015

This is waiting for a split between the two pieces.

@jbenet
Copy link
Owner

jbenet commented Sep 30, 2015

@cryptix do you have time soon? i think @whyrusleeping wants it to fix #1767 -- else we can probably do it

@cryptix
Copy link
Contributor Author

cryptix commented Sep 30, 2015

Sorry, no you go ahead please. This code is too fragile for my taste and you seem to have a lot of assumptions about it that aren't tested.

@cryptix cryptix closed this Sep 30, 2015
@cryptix cryptix deleted the NextMsgLen branch September 30, 2015 14:27
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