Skip to content

Commit

Permalink
zmq4: do not panic b/c of invalid connection attempts
Browse files Browse the repository at this point in the history
Updates go-zeromq#56.
  • Loading branch information
sbinet committed Jan 21, 2020
1 parent 28043d4 commit 2c2791c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func Open(rw net.Conn, sec Security, sockType SocketType, sockID SocketIdentity,

err := conn.init(sec)
if err != nil {
return nil, err
return nil, xerrors.Errorf("zmq4: could not initialize ZMTP connection: %w", err)
}

return conn, nil
Expand Down
9 changes: 6 additions & 3 deletions socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package zmq4

import (
"context"
"log"
"net"
"os"
"strings"
Expand Down Expand Up @@ -183,14 +184,16 @@ func (sck *socket) accept() {
default:
conn, err := sck.listener.Accept()
if err != nil {
// log.Printf("zmq4: error accepting connection from %q: %v", sck.ep, err)
// FIXME(sbinet): maybe bubble up this error to application code?
// log.Printf("zmq4: error accepting connection from %q: %+v", sck.ep, err)
continue
}

zconn, err := Open(conn, sck.sec, sck.typ, sck.id, true, sck.scheduleRmConn)
if err != nil {
panic(err)
// return xerrors.Errorf("zmq4: could not open a ZMTP connection: %w", err)
// FIXME(sbinet): maybe bubble up this error to application code?
log.Printf("zmq4: could not open a ZMTP connection with %q: %+v", sck.ep, err)
continue
}

sck.addConn(zconn)
Expand Down

0 comments on commit 2c2791c

Please sign in to comment.