1
0
Fork 0

TestPhone: Take a lock when draining the send queue.

This commit is contained in:
Holger Hans Peter Freyther 2010-11-20 01:33:47 +01:00
parent 1898744e02
commit 181fc048cf
1 changed files with 14 additions and 5 deletions

View File

@ -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 [