Bugfix double Trheads
If a Client connect comes from the same Session multiple Threads and Allocate / Freememory Problems. Debug for Thread Cleanup (ltls:CloseTLS Problems) Currently witouth a fix...
This commit is contained in:
parent
f5521f2e39
commit
5f81ea4ebf
1 changed files with 56 additions and 25 deletions
37
lweb.pbi
37
lweb.pbi
|
@ -310,6 +310,9 @@ Module lhs_web
|
||||||
client_id = ltls::WaitTLSSocket(network_server_id)
|
client_id = ltls::WaitTLSSocket(network_server_id)
|
||||||
Debug "New HTTPS Client:"+Str(client_id)
|
Debug "New HTTPS Client:"+Str(client_id)
|
||||||
If client_id > 0
|
If client_id > 0
|
||||||
|
If m_clients(Str(client_id))\client_id = client_id
|
||||||
|
Debug "Client Thread for socket already exist :"+Str(client_id)
|
||||||
|
Else
|
||||||
If count_HTTPS_client < conf_max_HTTPS_clients
|
If count_HTTPS_client < conf_max_HTTPS_clients
|
||||||
m_clients(Str(client_id))\client_id = client_id
|
m_clients(Str(client_id))\client_id = client_id
|
||||||
m_clients(Str(client_id))\client_do_cli = #CLI_DO_WaitDataReceive
|
m_clients(Str(client_id))\client_do_cli = #CLI_DO_WaitDataReceive
|
||||||
|
@ -322,6 +325,7 @@ Module lhs_web
|
||||||
Debug "Max HTTPS Clients reached..."
|
Debug "Max HTTPS Clients reached..."
|
||||||
ltls::CloseTLSSocket(client_id)
|
ltls::CloseTLSSocket(client_id)
|
||||||
EndIf
|
EndIf
|
||||||
|
EndIf
|
||||||
Else
|
Else
|
||||||
Break
|
Break
|
||||||
EndIf
|
EndIf
|
||||||
|
@ -343,6 +347,9 @@ Module lhs_web
|
||||||
client_id = lsocket::WaitSocket(network_server_id)
|
client_id = lsocket::WaitSocket(network_server_id)
|
||||||
Debug "New HTTP Client:"+Str(client_id)
|
Debug "New HTTP Client:"+Str(client_id)
|
||||||
If client_id > 0
|
If client_id > 0
|
||||||
|
If m_clients(Str(client_id))\client_id = client_id
|
||||||
|
Debug "Client Thread for socket already exist :"+Str(client_id)
|
||||||
|
Else
|
||||||
If count_HTTP_client < conf_max_HTTP_clients
|
If count_HTTP_client < conf_max_HTTP_clients
|
||||||
m_clients(Str(client_id))\client_id = client_id
|
m_clients(Str(client_id))\client_id = client_id
|
||||||
m_clients(Str(client_id))\client_do_cli = #CLI_DO_WaitDataReceive
|
m_clients(Str(client_id))\client_do_cli = #CLI_DO_WaitDataReceive
|
||||||
|
@ -355,6 +362,7 @@ Module lhs_web
|
||||||
Debug "Max HTTP Clients reached..."
|
Debug "Max HTTP Clients reached..."
|
||||||
lsocket::CloseSocket(client_id)
|
lsocket::CloseSocket(client_id)
|
||||||
EndIf
|
EndIf
|
||||||
|
EndIf
|
||||||
Else
|
Else
|
||||||
Break
|
Break
|
||||||
EndIf
|
EndIf
|
||||||
|
@ -533,10 +541,12 @@ Module lhs_web
|
||||||
Debug "Response Content:"+Response(#cha_R_ResponseContentType)
|
Debug "Response Content:"+Response(#cha_R_ResponseContentType)
|
||||||
Select Response(#cha_R_ResponseContentType)
|
Select Response(#cha_R_ResponseContentType)
|
||||||
Case #response_Memory
|
Case #response_Memory
|
||||||
|
Debug "Response Memory"
|
||||||
thread_data_size = Val(Response(#cha_R_MemorySize))
|
thread_data_size = Val(Response(#cha_R_MemorySize))
|
||||||
thread_temp_cache_memory = Val(Response(#cha_R_MemoryAdress))
|
thread_temp_cache_memory = Val(Response(#cha_R_MemoryAdress))
|
||||||
thread_type = Response(#cha_R_ResponseType)
|
thread_type = Response(#cha_R_ResponseType)
|
||||||
Case #response_string
|
Case #response_string
|
||||||
|
Debug "Response String"
|
||||||
thread_temp_decode_memory = AllocateMemory(StringByteLength(Response(#cha_R_StringBase64)))
|
thread_temp_decode_memory = AllocateMemory(StringByteLength(Response(#cha_R_StringBase64)))
|
||||||
thread_data_size = Base64Decoder(Response(#cha_R_StringBase64), thread_temp_decode_memory, StringByteLength(Response(#cha_R_StringBase64)))
|
thread_data_size = Base64Decoder(Response(#cha_R_StringBase64), thread_temp_decode_memory, StringByteLength(Response(#cha_R_StringBase64)))
|
||||||
thread_temp_cache_memory = AllocateMemory(thread_data_size)
|
thread_temp_cache_memory = AllocateMemory(thread_data_size)
|
||||||
|
@ -781,9 +791,16 @@ Module lhs_web
|
||||||
EndIf
|
EndIf
|
||||||
If thread_temp_cache_memory <> 0 And thread_buffer_offset <> 0 And thread_data_size <> 0
|
If thread_temp_cache_memory <> 0 And thread_buffer_offset <> 0 And thread_data_size <> 0
|
||||||
CopyMemory(thread_temp_cache_memory, thread_buffer_offset, thread_data_size)
|
CopyMemory(thread_temp_cache_memory, thread_buffer_offset, thread_data_size)
|
||||||
|
Debug thread_temp_cache_memory
|
||||||
FreeMemory(thread_temp_cache_memory)
|
FreeMemory(thread_temp_cache_memory)
|
||||||
|
thread_temp_cache_memory=0
|
||||||
Else
|
Else
|
||||||
Debug "File Buffer Troubles."
|
Debug "File Buffer Troubles."
|
||||||
|
If thread_temp_cache_memory = 0 : Debug "thread_temp_cache_memory = 0" : EndIf
|
||||||
|
If thread_buffer_offset = 0 : Debug "thread_buffer_offset = 0" : EndIf
|
||||||
|
If thread_data_size = 0 : Debug "thread_data_size = 0" : EndIf
|
||||||
|
thread_alive = #False
|
||||||
|
Break 2
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
; EndIf
|
; EndIf
|
||||||
|
@ -810,6 +827,8 @@ Module lhs_web
|
||||||
sent_total + sent
|
sent_total + sent
|
||||||
Else
|
Else
|
||||||
Debug "HTTPS Sent error:"+ltls::ErrorTLSCli(thread_cli_id)
|
Debug "HTTPS Sent error:"+ltls::ErrorTLSCli(thread_cli_id)
|
||||||
|
thread_alive = #False
|
||||||
|
Break 2
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
Until sent_length <= 0
|
Until sent_length <= 0
|
||||||
|
@ -828,6 +847,8 @@ Module lhs_web
|
||||||
sent_total + sent
|
sent_total + sent
|
||||||
Else
|
Else
|
||||||
Debug "HTTP Sent error:"+Str(sent)
|
Debug "HTTP Sent error:"+Str(sent)
|
||||||
|
thread_alive = #False
|
||||||
|
Break 2
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
Until sent_length <= 0
|
Until sent_length <= 0
|
||||||
|
@ -861,25 +882,35 @@ Module lhs_web
|
||||||
;}
|
;}
|
||||||
|
|
||||||
Until thread_alive = #False
|
Until thread_alive = #False
|
||||||
|
Debug "Thread should now die..."
|
||||||
ResetList(m_clients(Str(thread_cli_id))\datenbuffer())
|
ResetList(m_clients(Str(thread_cli_id))\datenbuffer())
|
||||||
|
Debug "Thread kill all Initialized Memory buffers:"
|
||||||
While NextElement(m_clients(Str(thread_cli_id))\datenbuffer())
|
While NextElement(m_clients(Str(thread_cli_id))\datenbuffer())
|
||||||
If m_clients(Str(thread_cli_id))\datenbuffer()\Initialized
|
If m_clients(Str(thread_cli_id))\datenbuffer()\Initialized
|
||||||
|
Debug "Kill:"+Str(m_clients(Str(thread_cli_id))\datenbuffer()\Buffer)+ " ..."
|
||||||
FreeMemory(m_clients(Str(thread_cli_id))\datenbuffer()\Buffer)
|
FreeMemory(m_clients(Str(thread_cli_id))\datenbuffer()\Buffer)
|
||||||
DeleteElement(m_clients(Str(thread_cli_id))\datenbuffer())
|
DeleteElement(m_clients(Str(thread_cli_id))\datenbuffer())
|
||||||
|
Debug "Freed and removed"
|
||||||
Else
|
Else
|
||||||
|
Debug "Remove element from List with uninitialized Memory ID: "+Str(m_clients(Str(thread_cli_id))\datenbuffer()\Buffer)
|
||||||
DeleteElement(m_clients(Str(thread_cli_id))\datenbuffer())
|
DeleteElement(m_clients(Str(thread_cli_id))\datenbuffer())
|
||||||
|
Debug "Removed"
|
||||||
EndIf
|
EndIf
|
||||||
Wend
|
Wend
|
||||||
If m_clients(Str(thread_cli_id))\client_type = #client_HTTPS
|
If m_clients(Str(thread_cli_id))\client_type = #client_HTTPS
|
||||||
ltls::CloseTLSSocket(thread_cli_id)
|
Debug "Kill HTTPS Socket:" + Str(thread_cli_id)
|
||||||
|
;ltls::CloseTLSSocket(thread_cli_id)
|
||||||
count_client(#client_HTTPS, #client_remove)
|
count_client(#client_HTTPS, #client_remove)
|
||||||
|
Debug "Killed."
|
||||||
Else
|
Else
|
||||||
|
Debug "Kill HTTP Socket:" + Str(thread_cli_id)
|
||||||
lsocket::CloseSocket(thread_cli_id)
|
lsocket::CloseSocket(thread_cli_id)
|
||||||
count_client(#client_HTTP, #client_remove)
|
count_client(#client_HTTP, #client_remove)
|
||||||
|
Debug "Killed."
|
||||||
EndIf
|
EndIf
|
||||||
|
Debug "Remove Client from map..."
|
||||||
DeleteMapElement(m_clients(), Str(thread_cli_id))
|
DeleteMapElement(m_clients(), Str(thread_cli_id))
|
||||||
Debug "Thread Beendet."
|
Debug "Removed and thread now died."
|
||||||
|
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue