Merge pull request #183 from rjschnorenberg/thread-safe-socket-writes

Synchronize ManagerConnection socket writes to make SendAction threadsafe
This commit is contained in:
Deantwo 2019-07-25 22:21:08 +02:00 committed by GitHub
commit 5b2802d2b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -46,6 +46,7 @@ namespace AsterNET.Manager
private int pingInterval = 10000; private int pingInterval = 10000;
private object lockSocket = new object(); private object lockSocket = new object();
private object lockSocketWrite = new object();
private object lockHandlers = new object(); private object lockHandlers = new object();
private bool enableEvents = true; private bool enableEvents = true;
@ -1593,9 +1594,12 @@ namespace AsterNET.Manager
private SendToAsteriskDelegate sa = null; private SendToAsteriskDelegate sa = null;
private void sendToAsterisk(string buffer) private void sendToAsterisk(string buffer)
{
lock (lockSocketWrite)
{ {
mrSocket.Write(buffer); mrSocket.Write(buffer);
} }
}
#endregion #endregion