Commit 0ad51ec1 authored by Levin Zimmermann's avatar Levin Zimmermann

proto fix, see comment in protogen

parent d64f1baf
...@@ -1735,7 +1735,36 @@ func (d *decoderM) genStructHead(path string, typ *types.Struct, userType types. ...@@ -1735,7 +1735,36 @@ func (d *decoderM) genStructHead(path string, typ *types.Struct, userType types.
d.emit("return 0, &mstructDecodeError{%q, op, opOk}", d.pathName(path)) d.emit("return 0, &mstructDecodeError{%q, op, opOk}", d.pathName(path))
d.emit("}") d.emit("}")
d.n += 1 // Arrays can have 1 or more bytes as a header:
//
// "Array format family stores a sequence of elements in 1, 3, or 5
// bytes of extra bytes in addition to the elements."
//
// see https://github.com/msgpack/msgpack/blob/master/spec.md
//
// Therefore it's better to use "ReadArrayHeaderBytes" than using
//
// >>> data = data[1:] // <- this fails in case we have array with 3 or 5 header bytes
//
// But there is another case, where this fix fails now, see:
//
// W0406 14:26:25.116792 2317874 mastered.go:127] C?: talk master(127.0.0.1:32747): C?: talk M1: after identification: expect nodeTab: 127.0.0.1:52480 - 127.0.0.1:32747 .0: decode: decode: M: NotifyNodeInformation.Addr: msgp: attempted to decode type "ext" with method for "array"
//
// So here we seem to use "genStructHead", because we create code for Addr decoding.
// But it doesn't work as expected, because we don't have an array, but an extension
// type. This means:
//
// Addr isn't an Array/Struct but an extension type and this needs to be adjusted in proto.go?
// We need to differentiate in 'genStructHead' between them?
d.emit("{")
d.emit("_, tail, err := msgp.ReadArrayHeaderBytes(data)")
d.emit("if err != nil {")
d.emit(fmt.Sprintf("return 0, mdecodeErr(%q, err)", d.pathName(path)))
d.emit("}")
d.emit("data = tail")
d.emit("}")
d.overflow.Add(1) d.overflow.Add(1)
} }
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment