Commit 8b25617f authored by Kirill Smelkov's avatar Kirill Smelkov

go/zodb/zeo: Close networkers

xnet.Networker added Close recently and is now required to be explicitly
closed by the user:

go123@01a77bb9
parent 3f12d2a5
......@@ -406,6 +406,11 @@ func openByURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (_ zodb
net = xnet.NetPlain("unix")
addr = u.Path
}
defer func() {
if net != nil {
net.Close()
}
}()
storageID := "1"
......@@ -422,6 +427,8 @@ func openByURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (_ zodb
if err != nil {
return nil, zodb.InvalidTid, err
}
zlink.closeq = append(zlink.closeq, net)
net = nil
defer func() {
if err != nil {
......
......@@ -230,6 +230,9 @@ func TestHandshake(t *testing.T) {
withZEOSrv(t, func(t *testing.T, zsrv ZEOSrv) {
ctx := context.Background()
net := xnet.NetPlain("unix")
defer func() {
err := net.Close(); X(err)
}()
zlink, err := dialZLink(ctx, net, zsrv.Addr()); X(err)
defer func() {
err := zlink.Close(); X(err)
......
......@@ -80,6 +80,8 @@ type zLink struct {
ver string // protocol version in use (without "Z" or "M" prefix)
enc encoding // protocol encoding in use ('Z' or 'M')
closeq []io.Closer // to be also closed on Close
}
// zLinkError is returned by zLink operations.
......@@ -128,6 +130,12 @@ func (zl *zLink) shutdown(err error) {
if err == nil {
err = err2
}
for _, c := range(zl.closeq) {
err2 := c.Close()
if err == nil {
err = err2
}
}
if err != nil {
log.Printf("%s", 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