summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-10-06 10:55:53 +0300
committerValery Piashchynski <[email protected]>2021-10-06 10:55:53 +0300
commitc8409d71958d7eba8595ccbe8950c49077a67c4d (patch)
tree747c676fdc41d5e745b8180d011a28cd7423629f /internal
parent59e29a90cfa6f16c790d16ac1f03a0f9f82b73d6 (diff)
Allow to run scripts in the server's command
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'internal')
-rwxr-xr-xinternal/protocol.go9
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
}