Skip to content

Commit

Permalink
fix: link init hook when action is not nil
Browse files Browse the repository at this point in the history
  • Loading branch information
siyul-park committed Dec 8, 2023
1 parent b30d6e0 commit db2af3b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions pkg/node/onetomany.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func NewOneToManyNode(action func(*process.Process, *packet.Packet) ([]*packet.P
errPort: port.New(),
}

if action != nil {
if n.action != nil {
n.inPort.AddInitHook(port.InitHookFunc(n.forward))
n.errPort.AddInitHook(port.InitHookFunc(func(proc *process.Process) {
n.mu.RLock()
Expand Down Expand Up @@ -58,14 +58,16 @@ func (n *OneToManyNode) Port(name string) (*port.Port, bool) {
for j := 0; j <= i; j++ {
if len(n.outPorts) <= j {
outPort := port.New()
outPort.AddInitHook(port.InitHookFunc(func(proc *process.Process) {
n.mu.RLock()
defer n.mu.RUnlock()
if n.action != nil {
outPort.AddInitHook(port.InitHookFunc(func(proc *process.Process) {
n.mu.RLock()
defer n.mu.RUnlock()

outStream := outPort.Open(proc)
outStream := outPort.Open(proc)

n.backward(proc, outStream)
}))
n.backward(proc, outStream)
}))
}
n.outPorts = append(n.outPorts, outPort)
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/node/onetoone.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewOneToOneNode(action func(*process.Process, *packet.Packet) (*packet.Pack
errPort: port.New(),
}

if action != nil {
if n.action != nil {
n.ioPort.AddInitHook(port.InitHookFunc(func(proc *process.Process) {
n.mu.RLock()
defer n.mu.RUnlock()
Expand Down

0 comments on commit db2af3b

Please sign in to comment.