aboutsummaryrefslogtreecommitdiffstats
path: root/SCCPHandler.st
diff options
context:
space:
mode:
Diffstat (limited to 'SCCPHandler.st')
-rw-r--r--SCCPHandler.st33
1 files changed, 24 insertions, 9 deletions
diff --git a/SCCPHandler.st b/SCCPHandler.st
index 309a930..deb8c34 100644
--- a/SCCPHandler.st
+++ b/SCCPHandler.st
@@ -205,16 +205,27 @@ Object subclass: MSGParser [
]
Object subclass: SCCPHandler [
- | connections last_ref connection |
+ | connections last_ref connection sem |
<comment: 'I handle SCCP messages'>
+ SCCPHandler class >> new [
+ ^ super new initialize; yourself
+ ]
+
+ initialize [
+ sem := Semaphore forMutualExclusion.
+ ]
+
addConnection: aConnection [
- self connections add: aConnection.
- aConnection srcRef: self assignSrcRef.
+ sem critical: [
+ self connections add: aConnection.
+ aConnection srcRef: self assignSrcRef.
+ ].
]
removeConnection: aConnection [
self connections remove: aConnection.
+
]
registerOn: aDispatcher [
@@ -224,7 +235,9 @@ Object subclass: SCCPHandler [
connectionTimeout: aConnection [
('SCCP Connection ', aConnection srcRef asString, ' timeout.') printNl.
- self removeConnection: aConnection.
+ sem critical: [
+ self removeConnection: aConnection.
+ ]
]
forwardMessage: aMessage with: aConnection[
@@ -258,11 +271,13 @@ Object subclass: SCCPHandler [
]
dispatchMessage: aMessage [
- self connections do: [:each |
- each srcRef = aMessage dst
- ifTrue: [
- ^ self forwardMessage: aMessage with: each.
- ].
+ sem critical: [
+ self connections do: [:each |
+ each srcRef = aMessage dst
+ ifTrue: [
+ ^ self forwardMessage: aMessage with: each.
+ ].
+ ]
].
'No one has handled the connection with ', aMessage dst asString printNl.