Commit 3cb82317 authored by Kirill Smelkov's avatar Kirill Smelkov

fixup! proto.NotPrimaryMaster: Fix .Primary data type (1)

Rerun `go generate`. As the diff in zproto-marshal.go shows changing
NotPrimaryMaster.Primary type from NodeID to int8 actually does make a
difference. This happens because NodeID type is based on int32 and
changing that to int8 changes how NotPrimaryMaster structure is layed
out in memory and on the wire.

The changes to zproto-marshal.go in 5d93e434 seem to be done by hand
and not matching the change to proto.go even though head of
zproto-marshal.go says

	// Code generated by protogen.go; DO NOT EDIT.
parent b2929804
......@@ -783,15 +783,15 @@ func (p *NotPrimaryMaster) neoMsgEncodedLenN() int {
a := &p.KnownMasterList[i]
size += (*a).neoEncodedLenN()
}
return 8 + size
return 5 + size
}
func (p *NotPrimaryMaster) neoMsgEncodeN(data []byte) {
binary.BigEndian.PutUint32(data[0:], uint32(int32(p.Primary)))
(data[0:])[0] = uint8(p.Primary)
{
l := len(p.KnownMasterList)
binary.BigEndian.PutUint32(data[4:], uint32(l))
data = data[8:]
binary.BigEndian.PutUint32(data[1:], uint32(l))
data = data[5:]
for i := 0; i < l; i++ {
a := &p.KnownMasterList[i]
{
......@@ -804,13 +804,13 @@ func (p *NotPrimaryMaster) neoMsgEncodeN(data []byte) {
func (p *NotPrimaryMaster) neoMsgDecodeN(data []byte) (int, error) {
var nread uint64
if len(data) < 8 {
if len(data) < 5 {
goto overflow
}
p.Primary = int8(int32(binary.BigEndian.Uint32(data[0 : 0+4])))
p.Primary = int8((data[0 : 0+1])[0])
{
l := binary.BigEndian.Uint32(data[4 : 4+4])
data = data[8:]
l := binary.BigEndian.Uint32(data[1 : 1+4])
data = data[5:]
p.KnownMasterList = make([]struct{ Address }, l)
for i := 0; uint32(i) < l; i++ {
a := &p.KnownMasterList[i]
......@@ -824,7 +824,7 @@ func (p *NotPrimaryMaster) neoMsgDecodeN(data []byte) (int, error) {
}
}
}
return 8 + int(nread), nil
return 5 + int(nread), nil
overflow:
return 0, ErrDecodeOverflow
......@@ -836,13 +836,13 @@ func (p *NotPrimaryMaster) neoMsgEncodedLenM() int {
a := &p.KnownMasterList[i]
size += msgpack.BinHeadSize(len((*a).Address.Host)) + len((*a).Address.Host) + msgpack.Uint16Size((*a).Address.Port)
}
return 1 + msgpack.Int32Size(int32(p.Primary)) + msgpack.ArrayHeadSize(len(p.KnownMasterList)) + len(p.KnownMasterList)*2 + size
return 1 + msgpack.Int8Size(p.Primary) + msgpack.ArrayHeadSize(len(p.KnownMasterList)) + len(p.KnownMasterList)*2 + size
}
func (p *NotPrimaryMaster) neoMsgEncodeM(data []byte) {
data[0] = byte(msgpack.FixArray_4 | 2)
{
n := msgpack.PutInt32(data[1:], int32(p.Primary))
n := msgpack.PutInt8(data[1:], p.Primary)
data = data[1+n:]
}
{
......@@ -878,11 +878,11 @@ func (p *NotPrimaryMaster) neoMsgDecodeM(data []byte) (int, error) {
}
data = data[1:]
{
v, tail, err := msgp.ReadInt32Bytes(data)
v, tail, err := msgp.ReadInt8Bytes(data)
if err != nil {
return 0, mdecodeErr("NotPrimaryMaster.Primary", err)
}
p.Primary = int8(v)
p.Primary = v
nread += uint64(len(data) - len(tail))
data = tail
}
......
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