transaction: Protect the timeouts with a semaphore
This commit is contained in:
parent
273fa71a2a
commit
7311c1c681
|
@ -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 |
|
||||
<comment: 'I handle timers for the transaction'>
|
||||
<category: 'MGCP-Callagent'>
|
||||
|
||||
MGCPTransactionBase class >> on: aCallagent [
|
||||
^ self new
|
||||
initialize;
|
||||
callagent: aCallagent;
|
||||
yourself
|
||||
]
|
||||
|
@ -35,6 +36,11 @@ Object subclass: MGCPTransactionBase [
|
|||
MGCPTransactionBase class >> expireTime [ <category: 'timeouts'> ^ 60 ]
|
||||
MGCPTransactionBase class >> removeTime [ <category: 'timeouts'> ^ 3 * 60 ]
|
||||
|
||||
initialize [
|
||||
<category: 'creation'>
|
||||
sem := RecursionLock new.
|
||||
]
|
||||
|
||||
callagent: aCallagent [
|
||||
<category: 'private'>
|
||||
callagent := aCallagent.
|
||||
|
@ -54,14 +60,18 @@ Object subclass: MGCPTransactionBase [
|
|||
|
||||
startRetransmitTimer [
|
||||
<category: 'private'>
|
||||
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 [
|
||||
<category: 'private'>
|
||||
t_retransmit ifNotNil: [t_retransmit cancel].
|
||||
sem critical: [
|
||||
t_retransmit ifNotNil: [t_retransmit cancel].
|
||||
]
|
||||
]
|
||||
|
||||
started [
|
||||
|
@ -75,8 +85,10 @@ Object subclass: MGCPTransactionBase [
|
|||
|
||||
completed [
|
||||
<category: 'public'>
|
||||
t_retransmit cancel.
|
||||
t_expire cancel.
|
||||
sem critical: [
|
||||
t_retransmit cancel.
|
||||
t_expire cancel.
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
|
|
Reference in New Issue