Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don’t hang on diskwriter errors #16

Merged
merged 2 commits into from
Nov 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions diskwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func NewDiskWriter(ctx context.Context, dest string, opt DiskWriterOpt) (*DiskWr
eg: eg,
ctx: ctx,
cancel: cancel,
filter: opt.Filter,
}, nil
}

Expand Down
7 changes: 6 additions & 1 deletion receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ func (r *receiver) run(ctx context.Context) error {

w := newDynamicWalker()

g.Go(func() error {
g.Go(func() (retErr error) {
defer func() {
if retErr != nil {
r.conn.SendMsg(&Packet{Type: PACKET_ERR, Data: []byte(retErr.Error())})
}
}()
destWalker := emptyWalker
if !r.merge {
destWalker = GetWalkerFn(r.dest)
Expand Down
2 changes: 2 additions & 0 deletions send.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ func (s *sender) run(ctx context.Context) error {
return err
}
switch p.Type {
case PACKET_ERR:
return errors.Errorf("error from receiver: %s", p.Data)
case PACKET_REQ:
if err := s.queue(p.ID); err != nil {
return err
Expand Down
20 changes: 12 additions & 8 deletions wire.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions wire.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ message Packet {
PACKET_REQ = 1;
PACKET_DATA = 2;
PACKET_FIN = 3;
PACKET_ERR = 4;
}
PacketType type = 1;
Stat stat = 2;
Expand Down