TestPhone: Take a lock when draining the send queue.
This commit is contained in:
parent
1898744e02
commit
181fc048cf
19
TestPhone.st
19
TestPhone.st
|
@ -1,7 +1,7 @@
|
|||
PackageLoader fileInPackage: 'OsmoNetwork'.
|
||||
|
||||
Object subclass: IPAConnection [
|
||||
| socket demuxer queue muxer dispatcher sccp ipa |
|
||||
| socket demuxer queue muxer dispatcher sccp ipa sem |
|
||||
IPAConnection class >> initWith: anAddr port: aPort token: aToken [
|
||||
^ (self new)
|
||||
socket: (Sockets.Socket remote: anAddr port: aPort);
|
||||
|
@ -14,6 +14,8 @@ Object subclass: IPAConnection [
|
|||
]
|
||||
|
||||
setup: aToken [
|
||||
sem := Semaphore forMutualExclusion.
|
||||
|
||||
demuxer := Osmo.IPADemuxer initOn: socket.
|
||||
queue := SharedQueue new.
|
||||
muxer := Osmo.IPAMuxer initOn: queue.
|
||||
|
@ -43,12 +45,19 @@ Object subclass: IPAConnection [
|
|||
]
|
||||
|
||||
drainSendQueue [
|
||||
[queue isEmpty] whileFalse: [
|
||||
| msg |
|
||||
msg := queue next.
|
||||
socket nextPutAllFlush: msg.
|
||||
sem critical: [
|
||||
[queue isEmpty] whileFalse: [
|
||||
| msg |
|
||||
msg := queue next.
|
||||
socket nextPutAllFlush: msg.
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
send: aMsg with: aType [
|
||||
muxer nextPut: aMsg with: aType.
|
||||
self drainSendQueue.
|
||||
]
|
||||
]
|
||||
|
||||
Object subclass: IPAConfig [
|
||||
|
|
Reference in New Issue