From 7311c1c681399968ea9bbf526817ffd2aea3d508 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Tue, 28 Jun 2011 11:56:32 +0200 Subject: [PATCH] transaction: Protect the timeouts with a semaphore --- callagent/MGCPTransaction.st | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/callagent/MGCPTransaction.st b/callagent/MGCPTransaction.st index e588965..2de2672 100644 --- a/callagent/MGCPTransaction.st +++ b/callagent/MGCPTransaction.st @@ -21,12 +21,13 @@ PackageLoader fileInPackage: 'OsmoCore'. Object subclass: MGCPTransactionBase [ - | callagent t_retransmit t_expire t_remove | + | callagent t_retransmit t_expire t_remove sem | MGCPTransactionBase class >> on: aCallagent [ ^ self new + initialize; callagent: aCallagent; yourself ] @@ -35,6 +36,11 @@ Object subclass: MGCPTransactionBase [ MGCPTransactionBase class >> expireTime [ ^ 60 ] MGCPTransactionBase class >> removeTime [ ^ 3 * 60 ] + initialize [ + + sem := RecursionLock new. + ] + callagent: aCallagent [ callagent := aCallagent. @@ -54,14 +60,18 @@ Object subclass: MGCPTransactionBase [ startRetransmitTimer [ - t_retransmit ifNotNil: [t_retransmit cancel]. - t_retransmit := self schedule: self class retransmitTime + sem critical: [ + t_retransmit ifNotNil: [t_retransmit cancel]. + t_retransmit := self schedule: self class retransmitTime block: [self transactionRetransmit]. + ] ] stopRetransmitTimer [ - t_retransmit ifNotNil: [t_retransmit cancel]. + sem critical: [ + t_retransmit ifNotNil: [t_retransmit cancel]. + ] ] started [ @@ -75,8 +85,10 @@ Object subclass: MGCPTransactionBase [ completed [ - t_retransmit cancel. - t_expire cancel. + sem critical: [ + t_retransmit cancel. + t_expire cancel. + ] ] ]