summaryrefslogtreecommitdiff
path: root/pkg/server/queue/queue.go
diff options
context:
space:
mode:
authorMikhail Osipov <mike.osipov@gmail.com>2021-04-14 15:02:11 +0300
committerMikhail Osipov <mike.osipov@gmail.com>2021-04-14 16:04:20 +0300
commita6a89cd5e025c6a6e12ad6060aae347385869cd3 (patch)
tree69e19085bc91aaa798bf1b8e5d39d8648c6e08ba /pkg/server/queue/queue.go
parent1517965447c59f1426405bf775e4c7c1f0611354 (diff)
add redial socket
Diffstat (limited to 'pkg/server/queue/queue.go')
-rw-r--r--pkg/server/queue/queue.go15
1 files changed, 6 insertions, 9 deletions
diff --git a/pkg/server/queue/queue.go b/pkg/server/queue/queue.go
index f0c1fc9..1478c07 100644
--- a/pkg/server/queue/queue.go
+++ b/pkg/server/queue/queue.go
@@ -55,13 +55,15 @@ func (r *reader) WriteTo(w io.Writer) (int64, error) {
}
if len(r.b) > 0 {
- if _, err := w.Write(r.b); err != nil {
+ if n, err := w.Write(r.b); err != nil {
+ r.b = r.b[n:]
return 0, err
}
}
for b := range r.q {
- if _, err := w.Write(b); err != nil {
+ if n, err := w.Write(b); err != nil {
+ r.b = b[n:]
return 0, err
}
}
@@ -91,13 +93,8 @@ func (w *writer) Write(p []byte) (int, error) {
}
func IoCopy(r io.Reader, w io.Writer) error {
- if _, err := io.Copy(w, r); err != nil {
- if err != io.EOF {
- return err
- }
- }
-
- return nil
+ _, err := io.Copy(w, r)
+ return err
}
func Copy(rq, wq Q) error {