Commit bb90dc01 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c31d9dbe
// Copyright (C) 2018-2019 Nexedi SA and Contributors. // Copyright (C) 2018-2020 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com> // Kirill Smelkov <kirr@nexedi.com>
// //
// This program is free software: you can Use, Study, Modify and Redistribute // This program is free software: you can Use, Study, Modify and Redistribute
...@@ -31,14 +31,13 @@ import ( ...@@ -31,14 +31,13 @@ import (
"net" "net"
"sync" "sync"
"golang.org/x/sync/errgroup"
pickle "github.com/kisielk/og-rek" pickle "github.com/kisielk/og-rek"
"github.com/someonegg/gocontainer/rbuf" "github.com/someonegg/gocontainer/rbuf"
"lab.nexedi.com/kirr/go123/xbytes" "lab.nexedi.com/kirr/go123/xbytes"
"lab.nexedi.com/kirr/go123/xerr" "lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/go123/xnet" "lab.nexedi.com/kirr/go123/xnet"
"lab.nexedi.com/kirr/go123/xsync"
"lab.nexedi.com/kirr/neo/go/zodb/internal/pickletools" "lab.nexedi.com/kirr/neo/go/zodb/internal/pickletools"
) )
...@@ -447,10 +446,10 @@ func handshake(ctx context.Context, conn net.Conn) (_ *zLink, err error) { ...@@ -447,10 +446,10 @@ func handshake(ctx context.Context, conn net.Conn) (_ *zLink, err error) {
// ready when/if handshake tx/rx exchange succeeds // ready when/if handshake tx/rx exchange succeeds
hok := make(chan struct{}) hok := make(chan struct{})
wg, ctx := errgroup.WithContext(ctx) wg := xsync.NewWorkGroup(ctx)
// rx/tx handshake packet // rx/tx handshake packet
wg.Go(func() error { wg.Go(func(ctx context.Context) error {
// server first announces its preferred protocol // server first announces its preferred protocol
// it is e.g. "M5", "Z5", "Z4", "Z3101", ... // it is e.g. "M5", "Z5", "Z4", "Z3101", ...
pkb, err := zl.recvPkt() pkb, err := zl.recvPkt()
...@@ -501,7 +500,7 @@ func handshake(ctx context.Context, conn net.Conn) (_ *zLink, err error) { ...@@ -501,7 +500,7 @@ func handshake(ctx context.Context, conn net.Conn) (_ *zLink, err error) {
return nil return nil
}) })
wg.Go(func() error { wg.Go(func(ctx context.Context) error {
select { select {
case <-ctx.Done(): case <-ctx.Done():
// either ctx canceled from outside, or it is tx/rx problem. // either ctx canceled from outside, or it is tx/rx problem.
......
// Copyright (C) 2019 Nexedi SA and Contributors. // Copyright (C) 2019-2020 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com> // Kirill Smelkov <kirr@nexedi.com>
// //
// This program is free software: you can Use, Study, Modify and Redistribute // This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your // it under the terms of the GNU General Public License version 3, or (at your
...@@ -29,9 +29,9 @@ import ( ...@@ -29,9 +29,9 @@ import (
"testing" "testing"
"github.com/pkg/errors" "github.com/pkg/errors"
"golang.org/x/sync/errgroup"
"lab.nexedi.com/kirr/go123/exc" "lab.nexedi.com/kirr/go123/exc"
"lab.nexedi.com/kirr/go123/xsync"
"lab.nexedi.com/kirr/neo/go/internal/xtesting" "lab.nexedi.com/kirr/neo/go/internal/xtesting"
"lab.nexedi.com/kirr/neo/go/zodb" "lab.nexedi.com/kirr/neo/go/zodb"
) )
...@@ -65,14 +65,14 @@ func TestWatch(t *testing.T) { ...@@ -65,14 +65,14 @@ func TestWatch(t *testing.T) {
stor, err := zodb.Open(bg, tfs, &zodb.OpenOptions{ReadOnly: true}); X(err) stor, err := zodb.Open(bg, tfs, &zodb.OpenOptions{ReadOnly: true}); X(err)
// spawn plain and verbose watchers // spawn plain and verbose watchers
ctx0, cancel := context.WithCancel(bg) ctx, cancel := context.WithCancel(bg)
wg, ctx := errgroup.WithContext(ctx0) wg := xsync.NewWorkGroup(ctx)
// gowatch spawns Watch(verbose) and returns expectf() func that is // gowatch spawns Watch(verbose) and returns expectf() func that is
// connected to verify Watch output. // connected to verify Watch output.
gowatch := func(verbose bool) /*expectf*/func(format string, argv ...interface{}) { gowatch := func(verbose bool) /*expectf*/func(format string, argv ...interface{}) {
pr, pw := io.Pipe() pr, pw := io.Pipe()
wg.Go(func() error { wg.Go(func(ctx context.Context) error {
return Watch(ctx, stor, pw, verbose) return Watch(ctx, stor, pw, verbose)
}) })
......
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