Skip to content

Commit

Permalink
Problem: potential reuse of inproc address
Browse files Browse the repository at this point in the history
see zeromq#252

Use unique ids returned by czmq library instead of random numbers
to build unique inproc addresses in function newChanneler
  • Loading branch information
cyrilleverrier committed Feb 22, 2019
1 parent 3608957 commit bb25b0c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions channeler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import "C"

import (
"fmt"
"math/rand"
"strings"
)

Expand All @@ -18,7 +17,7 @@ import (
// channel, and send everything back to the socket thrad for sending
// using an additional inproc socket.
type Channeler struct {
id int64
id string
sockType int
endpoints string
subscribe *string
Expand Down Expand Up @@ -246,7 +245,7 @@ func newChanneler(sockType int, endpoints string, subscribe []string, options []

C.Sock_init()
c := &Channeler{
id: rand.Int63(),
id: C.GoString(C.zuuid_str(C.zuuid_new())),
endpoints: endpoints,
sockType: sockType,
commandChan: commandChan,
Expand All @@ -255,8 +254,8 @@ func newChanneler(sockType int, endpoints string, subscribe []string, options []
ErrChan: errChan,
errChan: errChan,
}
c.commandAddr = fmt.Sprintf("inproc://actorcontrol%d", c.id)
c.proxyAddr = fmt.Sprintf("inproc://proxy%d", c.id)
c.commandAddr = fmt.Sprintf("inproc://actorcontrol_%s", c.id)
c.proxyAddr = fmt.Sprintf("inproc://proxy_%s", c.id)

if len(subscribe) > 0 {
topics := strings.Join(subscribe, ",")
Expand Down

0 comments on commit bb25b0c

Please sign in to comment.