diff options
author | Valery Piashchynski <[email protected]> | 2021-10-06 10:55:53 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-10-06 10:55:53 +0300 |
commit | c8409d71958d7eba8595ccbe8950c49077a67c4d (patch) | |
tree | 747c676fdc41d5e745b8180d011a28cd7423629f /internal | |
parent | 59e29a90cfa6f16c790d16ac1f03a0f9f82b73d6 (diff) |
Allow to run scripts in the server's command
Signed-off-by: Valery Piashchynski <[email protected]>
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 } |