Race condition fix
This commit is contained in:
parent
01978a2399
commit
5690a27219
|
@ -604,7 +604,7 @@ Namespace GameJolt
|
||||||
request.ContentType = "application/x-www-form-urlencoded"
|
request.ContentType = "application/x-www-form-urlencoded"
|
||||||
request.ServicePoint.Expect100Continue = False
|
request.ServicePoint.Expect100Continue = False
|
||||||
|
|
||||||
Dim writer As StreamWriter = New StreamWriter(request.GetRequestStream())
|
Dim writer As StreamWriterLock = New StreamWriterLock(request.GetRequestStream())
|
||||||
writer.Write(post)
|
writer.Write(post)
|
||||||
writer.Close()
|
writer.Close()
|
||||||
Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
|
Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
|
||||||
|
|
|
@ -14,7 +14,7 @@ Namespace Servers
|
||||||
|
|
||||||
Private _stream As NetworkStream
|
Private _stream As NetworkStream
|
||||||
Private _streamReader As StreamReader
|
Private _streamReader As StreamReader
|
||||||
Private _streamWriter As StreamWriter
|
Private _streamWriter As StreamWriterLock
|
||||||
|
|
||||||
Private _receiveThread As Threading.Thread
|
Private _receiveThread As Threading.Thread
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ Namespace Servers
|
||||||
'Send GameData package first:
|
'Send GameData package first:
|
||||||
Me._stream = Me._client.GetStream()
|
Me._stream = Me._client.GetStream()
|
||||||
Me._streamReader = New StreamReader(Me._stream)
|
Me._streamReader = New StreamReader(Me._stream)
|
||||||
Me._streamWriter = New StreamWriter(Me._stream)
|
Me._streamWriter = New StreamWriterLock(Me._stream)
|
||||||
|
|
||||||
Core.ServersManager.PlayerManager.Reset()
|
Core.ServersManager.PlayerManager.Reset()
|
||||||
Dim initialPlayerData As String = Core.ServersManager.PlayerManager.CreatePlayerDataPackage().ToString()
|
Dim initialPlayerData As String = Core.ServersManager.PlayerManager.CreatePlayerDataPackage().ToString()
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
Imports System.IO
|
||||||
|
|
||||||
|
Public Class StreamWriterLock
|
||||||
|
Inherits StreamWriter
|
||||||
|
Private _lock As New Object()
|
||||||
|
|
||||||
|
Public Sub New(stream As Stream)
|
||||||
|
MyBase.New(stream)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Overrides Sub Write(value As Char)
|
||||||
|
SyncLock _lock
|
||||||
|
MyBase.Write(value)
|
||||||
|
End SyncLock
|
||||||
|
End Sub
|
||||||
|
End Class
|
|
@ -460,7 +460,7 @@ Public Class JoinServerScreen
|
||||||
Dim Stream As NetworkStream = client.GetStream()
|
Dim Stream As NetworkStream = client.GetStream()
|
||||||
|
|
||||||
Dim streamr As StreamReader = New StreamReader(Stream)
|
Dim streamr As StreamReader = New StreamReader(Stream)
|
||||||
Dim streamw As StreamWriter = New StreamWriter(Stream)
|
Dim streamw As StreamWriterLock = New StreamWriterLock(Stream)
|
||||||
|
|
||||||
streamw.WriteLine(New Servers.Package(Servers.Package.PackageTypes.ServerDataRequest, -1, Servers.Package.ProtocolTypes.TCP, "r").ToString())
|
streamw.WriteLine(New Servers.Package(Servers.Package.PackageTypes.ServerDataRequest, -1, Servers.Package.ProtocolTypes.TCP, "r").ToString())
|
||||||
streamw.Flush()
|
streamw.Flush()
|
||||||
|
|
Loading…
Reference in New Issue