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 {
// NewConn creates new connection on top of node-node link.
func (link *NodeLink) NewConn() (*Conn, error) {
link.connMu.Lock()
//defer link.connMu.Unlock()
c, err := link._NewConn()
link.connMu.Unlock()
return c, err
}
defer link.connMu.Unlock()
func (link *NodeLink) _NewConn() (*Conn, error) {
if link.connTab == nil {
if link.closed.Get() != 0 {
return nil, link.err("newconn", ErrLinkClosed)
......@@ -1331,13 +1326,8 @@ func (c *Conn) Recv() (proto.Msg, error) {
if err != nil {
return nil, err
}
//defer pkt.Free()
msg, err := c._Recv(pkt)
pkt.Free()
return msg, err
}
defer pkt.Free()
func (c *Conn) _Recv(pkt *pktBuf) (proto.Msg, error) {
// decode packet
pkth := pkt.Header()
msgCode := packed.Ntoh16(pkth.MsgCode)
......@@ -1353,7 +1343,7 @@ func (c *Conn) _Recv(pkt *pktBuf) (proto.Msg, error) {
// msg := reflect.NewAt(msgType, bufAlloc(msgType.Size())
_, err := msg.NEOMsgDecode(pkt.Payload())
_, err = msg.NEOMsgDecode(pkt.Payload())
if err != nil {
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) {
if err != nil {
return -1, err
}
//defer pkt.Free()
which, err = c._Expect(pkt, msgv...)
pkt.Free()
return which, err
}
defer pkt.Free()
func (c *Conn) _Expect(pkt *pktBuf, msgv ...proto.Msg) (int, error) {
pkth := pkt.Header()
msgCode := packed.Ntoh16(pkth.MsgCode)
......@@ -1578,15 +1563,9 @@ func (link *NodeLink) Ask1(req proto.Msg, resp proto.Msg) (err error) {
if err != nil {
return err
}
defer conn.lightClose()
//defer conn.lightClose()
err = conn._Ask1(req, resp)
conn.lightClose()
return err
}
func (conn *Conn) _Ask1(req proto.Msg, resp proto.Msg) error {
err := conn.sendMsgDirect(req)
err = conn.sendMsgDirect(req)
if err != nil {
return err
}
......
......@@ -192,16 +192,9 @@ func (fs *FileStorage) load(xid zodb.Xid) (buf *mem.Buf, serial, nextSerial zodb
dh.Oid = xid.Oid
dh.Tid = zodb.TidMax
dh.PrevRevPos = dataPos
//defer dh.Free()
buf, serial, nextSerial, err = fs._load(dh, xid)
dh.Free()
return buf, serial, nextSerial, err
}
defer dh.Free()
// 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
var nextSerial zodb.Tid
for {
nextSerial = dh.Tid
err := dh.LoadPrevRev(fs.file)
......@@ -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
// 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 {
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