Skip to content

Commit

Permalink
fixbug#116 rpc:call from [Erlang/OTP24] to [Ergo/Go 1.19] is not working
Browse files Browse the repository at this point in the history
  • Loading branch information
leonlee2013 committed Dec 3, 2022
1 parent 73feb27 commit a98e834
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion node/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ func (c *core) RouteSpawnRequest(node string, behaviorName string, request gen.R

// spawn new process
process_opts := processOptions{}
process_opts.Env = map[gen.EnvKey]interface{}{EnvKeyRemoteSpawn: request.Options}
process_opts.Env = map[gen.EnvKey]interface{}{EnvKeyRemoteSpawn: request.Options, "ergo:RemoteSpawnRequest": request}
process, err_spawn := c.spawn(request.Options.Name, process_opts, b.Behavior, args...)

// reply
Expand Down
15 changes: 9 additions & 6 deletions proto/dist/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -1297,12 +1297,11 @@ func (dc *distConnection) handleMessage(message *distMessage) (err error) {
registerName := ""
for _, option := range t.Element(6).(etf.List) {
name, ok := option.(etf.Tuple)
if !ok || len(name) != 2 {
return fmt.Errorf("malformed spawn request")
}
switch name.Element(1) {
case etf.Atom("name"):
registerName = string(name.Element(2).(etf.Atom))
if ok || len(name) == 2 {
switch name.Element(1) {
case etf.Atom("name"):
registerName = string(name.Element(2).(etf.Atom))
}
}
}

Expand All @@ -1323,6 +1322,10 @@ func (dc *distConnection) handleMessage(message *distMessage) (err error) {
}
}

if registerName == "" && module == etf.Atom("erpc") {
registerName = "erpc"
}

spawnRequestOptions := gen.RemoteSpawnOptions{
Name: registerName,
Function: string(function),
Expand Down

0 comments on commit a98e834

Please sign in to comment.