Compare commits

..

No commits in common. "46407b368528abdb2acbfc76b3556407d6049919" and "bc81ab84cb4a4d4a01ac35d2b6c464cf9d0805fe" have entirely different histories.

2 changed files with 5 additions and 27 deletions

View file

@ -71,7 +71,7 @@ func (h *Handler) Run(ctx context.Context) error {
defer func() { defer func() {
cancel() cancel()
h.logger.Info("context canceled, waiting for shutdown of components") h.logger.Info("context canceled waiting for shutdown of components")
wg.Wait() wg.Wait()
h.logger.Info("shutdown complete") h.logger.Info("shutdown complete")
}() }()

View file

@ -510,34 +510,12 @@ func (c *COBSFramer) WriteFrames(ctx context.Context, writer io.Writer, frameCha
encoded := c.encoder.Encode(frame) encoded := c.encoder.Encode(frame)
err := c.writeRaw(ctx, writer, encoded) n, err := io.Copy(writer, bytes.NewReader(encoded))
if err != nil { if err != nil {
return err return fmt.Errorf("cold not write data: %w", err)
} }
c.logger.Tracef("wrote %d bytes", n)
} }
} }
} }
func (c *COBSFramer) writeRaw(ctx context.Context, writer io.Writer, raw []byte) error {
errChan := make(chan error)
go func() {
n, err := io.Copy(writer, bytes.NewReader(raw))
if err != nil {
errChan <- fmt.Errorf("could not write data: %w", err)
return
}
c.logger.WithField("count", n).Tracef("wrote bytes")
close(errChan)
}()
select {
case <-ctx.Done():
return nil
case err := <-errChan:
return err
}
}