diff options
Diffstat (limited to 'esds/node.py')
| -rw-r--r-- | esds/node.py | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/esds/node.py b/esds/node.py index e26e239..4c9ca5f 100644 --- a/esds/node.py +++ b/esds/node.py @@ -4,7 +4,7 @@ class Node: available_node_id=0 def __init__(self,src,interfaces): """ - + self.chest: contains mutex protected data """ self.node_id=Node.available_node_id Node.available_node_id+=1 # Refresh node id @@ -71,12 +71,16 @@ class Node: def wait(self,duration): if type(duration) != int and type(duration) != float: self.abort("wait() called with a non-number duration") + elif duration < 0: + self.abort("wait() called with a negative duration (duration="+str(duration)+")") + elif duration == 0: + return self.rargs=duration - self["request"]="timeout_add" + self["request"]="notify_add" self["state"]="call_non_blocking" - self.wait_ack(["timeout_add"]) + self.wait_ack(["notify_add"]) self["state"]="pending" - self.wait_ack(["timeout"]) + self.wait_ack(["notify"]) def wait_end(self): self["request"]="wait_end" @@ -103,6 +107,8 @@ class Node: self.abort("send() called with a non-number datasize") elif type(dst) != int and type(dst) != float and dst != None: self.abort("send() called with a non-number dst (wired interfaces) or dst is not None (wireless interfaces)") + elif not self["turned_on"]: + self.abort("send() called while node is turned off") self.plugin_notify("send_call",(interface,data,datasize,dst)) self.rargs=(interface, data, datasize, dst) self["request"]="send" @@ -118,8 +124,12 @@ class Node: self.abort("sendt() called with a non-number datasize") elif type(timeout) != int and type(timeout) != float: self.abort("sendt() called with a non-number timeout") + elif timeout < 0: + self.abort("sendt() called with a negative timeout (timeout="+str(timeout)+")") elif type(dst) != int and type(dst) != float and dst != None: self.abort("send() called with a non-number dst (wired interfaces) or dst is not None (wireless interfaces)") + elif not self["turned_on"]: + self.abort("sendt() called while node is turned off") self.rargs=timeout self["request"]="timeout_add" self["state"]="call_non_blocking" @@ -141,6 +151,8 @@ class Node: def receive(self,interface): if interface not in self["interfaces"]: self.abort("receive() called with an unknown interface \""+interface+"\"") + elif not self["turned_on"]: + self.abort("receive() called while node is turned off") self["request"]="receive" self.rargs=interface self["state"]="call_blocking" @@ -154,6 +166,10 @@ class Node: self.abort("receivet() called with an unknown interface \""+interface+"\"") elif type(timeout) != int and type(timeout) != float: self.abort("receivet() called with a non-number timeout") + elif timeout < 0: + self.abort("receivet() called with a negative timeout (timeout="+str(timeout)+")") + elif not self["turned_on"]: + self.abort("receivet() called while node is turned off") self.rargs=timeout self["request"]="timeout_add" self["state"]="call_non_blocking" |
