Commit 30ed0fcd authored by Kirill Smelkov's avatar Kirill Smelkov

Merge branch 'master' into t

* master:
  go/neo/neonet: Don't avoid defer anymore
  go/zodb/fs1: Don't avoid defer anymore
parents 242455f7 1f26678b
...@@ -355,13 +355,8 @@ func (link *NodeLink) newConn(connId uint32) *Conn { ...@@ -355,13 +355,8 @@ func (link *NodeLink) newConn(connId uint32) *Conn {
// NewConn creates new connection on top of node-node link. // NewConn creates new connection on top of node-node link.
func (link *NodeLink) NewConn() (*Conn, error) { func (link *NodeLink) NewConn() (*Conn, error) {
link.connMu.Lock() link.connMu.Lock()
//defer link.connMu.Unlock() defer link.connMu.Unlock()
c, err := link._NewConn()
link.connMu.Unlock()
return c, err
}
func (link *NodeLink) _NewConn() (*Conn, error) {
if link.connTab == nil { if link.connTab == nil {
if link.closed.Get() != 0 { if link.closed.Get() != 0 {
return nil, link.err("newconn", ErrLinkClosed) return nil, link.err("newconn", ErrLinkClosed)
...@@ -1331,13 +1326,8 @@ func (c *Conn) Recv() (proto.Msg, error) { ...@@ -1331,13 +1326,8 @@ func (c *Conn) Recv() (proto.Msg, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
//defer pkt.Free() defer pkt.Free()
msg, err := c._Recv(pkt)
pkt.Free()
return msg, err
}
func (c *Conn) _Recv(pkt *pktBuf) (proto.Msg, error) {
// decode packet // decode packet
pkth := pkt.Header() pkth := pkt.Header()
msgCode := packed.Ntoh16(pkth.MsgCode) msgCode := packed.Ntoh16(pkth.MsgCode)
...@@ -1353,7 +1343,7 @@ func (c *Conn) _Recv(pkt *pktBuf) (proto.Msg, error) { ...@@ -1353,7 +1343,7 @@ func (c *Conn) _Recv(pkt *pktBuf) (proto.Msg, error) {
// msg := reflect.NewAt(msgType, bufAlloc(msgType.Size()) // msg := reflect.NewAt(msgType, bufAlloc(msgType.Size())
_, err := msg.NEOMsgDecode(pkt.Payload()) _, err = msg.NEOMsgDecode(pkt.Payload())
if err != nil { if err != nil {
return nil, c.err("decode", err) // XXX "decode:" is already in ErrDecodeOverflow return nil, c.err("decode", err) // XXX "decode:" is already in ErrDecodeOverflow
} }
...@@ -1400,13 +1390,8 @@ func (c *Conn) Expect(msgv ...proto.Msg) (which int, err error) { ...@@ -1400,13 +1390,8 @@ func (c *Conn) Expect(msgv ...proto.Msg) (which int, err error) {
if err != nil { if err != nil {
return -1, err return -1, err
} }
//defer pkt.Free() defer pkt.Free()
which, err = c._Expect(pkt, msgv...)
pkt.Free()
return which, err
}
func (c *Conn) _Expect(pkt *pktBuf, msgv ...proto.Msg) (int, error) {
pkth := pkt.Header() pkth := pkt.Header()
msgCode := packed.Ntoh16(pkth.MsgCode) msgCode := packed.Ntoh16(pkth.MsgCode)
...@@ -1578,15 +1563,9 @@ func (link *NodeLink) Ask1(req proto.Msg, resp proto.Msg) (err error) { ...@@ -1578,15 +1563,9 @@ func (link *NodeLink) Ask1(req proto.Msg, resp proto.Msg) (err error) {
if err != nil { if err != nil {
return err return err
} }
defer conn.lightClose()
//defer conn.lightClose() err = conn.sendMsgDirect(req)
err = conn._Ask1(req, resp)
conn.lightClose()
return err
}
func (conn *Conn) _Ask1(req proto.Msg, resp proto.Msg) error {
err := conn.sendMsgDirect(req)
if err != nil { if err != nil {
return err return err
} }
......
...@@ -192,16 +192,9 @@ func (fs *FileStorage) load(xid zodb.Xid) (buf *mem.Buf, serial, nextSerial zodb ...@@ -192,16 +192,9 @@ func (fs *FileStorage) load(xid zodb.Xid) (buf *mem.Buf, serial, nextSerial zodb
dh.Oid = xid.Oid dh.Oid = xid.Oid
dh.Tid = zodb.TidMax dh.Tid = zodb.TidMax
dh.PrevRevPos = dataPos dh.PrevRevPos = dataPos
//defer dh.Free() defer dh.Free()
buf, serial, nextSerial, err = fs._load(dh, xid)
dh.Free()
return buf, serial, nextSerial, err
}
// FIXME kill nextSerial support after neo/py cache does not depend on next_serial
func (fs *FileStorage) _load(dh *DataHeader, xid zodb.Xid) (*mem.Buf, zodb.Tid, zodb.Tid, error) {
// search backwards for when we first have data record with tid satisfying xid.At // search backwards for when we first have data record with tid satisfying xid.At
var nextSerial zodb.Tid
for { for {
nextSerial = dh.Tid nextSerial = dh.Tid
err := dh.LoadPrevRev(fs.file) err := dh.LoadPrevRev(fs.file)
...@@ -221,9 +214,9 @@ func (fs *FileStorage) _load(dh *DataHeader, xid zodb.Xid) (*mem.Buf, zodb.Tid, ...@@ -221,9 +214,9 @@ func (fs *FileStorage) _load(dh *DataHeader, xid zodb.Xid) (*mem.Buf, zodb.Tid,
// even if we will scan back via backpointers, the serial returned should // even if we will scan back via backpointers, the serial returned should
// be of first-found transaction // be of first-found transaction
serial := dh.Tid serial = dh.Tid
buf, err := dh.LoadData(fs.file) buf, err = dh.LoadData(fs.file)
if err != nil { if err != nil {
return nil, 0, 0, err return nil, 0, 0, err
} }
......
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