diff options
Diffstat (limited to 'internal')
-rwxr-xr-x | internal/protocol.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/internal/protocol.go b/internal/protocol.go index 78174118..73cb960e 100755 --- a/internal/protocol.go +++ b/internal/protocol.go @@ -68,8 +68,7 @@ func SendControl(rl relay.Relay, payload interface{}) error { fr.WritePayload(data) fr.WriteCRC(fr.Header()) - // hold a pointer to a frame - // Do we need a copy here???? + // we don't need a copy here, because frame copy the data before send err = rl.Send(fr) if err != nil { return errors.E(op, err) @@ -78,7 +77,7 @@ func SendControl(rl relay.Relay, payload interface{}) error { return nil } -func FetchPID(rl relay.Relay) (int64, error) { +func Pid(rl relay.Relay) (int64, error) { const op = errors.Op("fetch_pid") err := SendControl(rl, pidCommand{Pid: os.Getpid()}) if err != nil { @@ -111,5 +110,9 @@ func FetchPID(rl relay.Relay) (int64, error) { return 0, errors.E(op, err) } + if link.Pid <= 0 { + return 0, errors.E(op, errors.Str("pid should be greater than 0")) + } + return int64(link.Pid), nil } |