Rework Max Clients
This commit is contained in:
parent
5d85e13e50
commit
d20b7ddd55
5 changed files with 41 additions and 31 deletions
|
@ -12,7 +12,8 @@ WritePreferenceString("HTTPS_enable","0")
|
|||
WritePreferenceString("Defaultfile","/index.html")
|
||||
WritePreferenceString("Basedirectory","/home/renlin/testweb/")
|
||||
WritePreferenceString("Error400_Handling","integrated")
|
||||
WritePreferenceString("MaxClients","100")
|
||||
WritePreferenceString("Max_HTTP_Clients","10")
|
||||
WritePreferenceString("Max_HTTPS_Clients","100")
|
||||
WritePreferenceString("Filememorycache","0")
|
||||
ClosePreferences()
|
||||
End
|
||||
|
|
|
@ -12,5 +12,6 @@ HTTPS_enable=1
|
|||
Defaultfile=/index.html
|
||||
Basedirectory=/home/renlin/testweb/
|
||||
Error400_Handling=integrated
|
||||
MaxClients=100
|
||||
Max_HTTP_Clients=10
|
||||
Max_HTTPS_Clients=100
|
||||
Filememorycache=0
|
||||
|
|
|
@ -21,8 +21,8 @@ OpenConsole("Test")
|
|||
|
||||
If OpenPreferences("lhttpd.ini", #PB_Preference_GroupSeparator)
|
||||
If PreferenceGroup("lhttpd")
|
||||
lhs_web::set_config(lhs_web::#conf_port, ReadPreferenceString("HTTP_Port","8081"))
|
||||
lhs_web::set_config(lhs_web::#conf_binding, ReadPreferenceString("HTTP_Binding","0.0.0.0"))
|
||||
lhs_web::set_config(lhs_web::#conf_HTTP_port, ReadPreferenceString("HTTP_Port","8081"))
|
||||
lhs_web::set_config(lhs_web::#conf_HTTP_binding, ReadPreferenceString("HTTP_Binding","0.0.0.0"))
|
||||
lhs_web::set_config(lhs_web::#conf_HTTPS_CA, ReadPreferenceString("HTTPS_CA","/home/renlin/dev/libressl/sample/test_ca.pem"))
|
||||
lhs_web::set_config(lhs_web::#conf_HTTPS_Cert, ReadPreferenceString("HTTPS_Cert","/home/renlin/dev/libressl/sample/test_server_cert.pem"))
|
||||
lhs_web::set_config(lhs_web::#conf_HTTPS_Key, ReadPreferenceString("HTTPS_Key","/home/renlin/dev/libressl/sample/test_server_key.pem"))
|
||||
|
@ -33,7 +33,8 @@ If OpenPreferences("lhttpd.ini", #PB_Preference_GroupSeparator)
|
|||
lhs_web::set_config(lhs_web::#conf_defaultfile, ReadPreferenceString("Defaultfile","/index.html"))
|
||||
lhs_web::set_config(lhs_web::#conf_basedir, ReadPreferenceString("Basedirectory","/home/renlin/testweb/"))
|
||||
lhs_web::set_config(lhs_web::#conf_error400, ReadPreferenceString("Error400_Handling","integrated"))
|
||||
lhs_web::set_config(lhs_web::#conf_max_clients, ReadPreferenceString("MaxClients","100"))
|
||||
lhs_web::set_config(lhs_web::#conf_max_HTTP_clients, ReadPreferenceString("Max_HTTP_Clients","10"))
|
||||
lhs_web::set_config(lhs_web::#conf_max_HTTPS_clients, ReadPreferenceString("Max_HTTPS_Clients","100"))
|
||||
lhs_web::set_config(lhs_web::#conf_cache_enable, ReadPreferenceString("Filememorycache","0"))
|
||||
ClosePreferences()
|
||||
Else
|
||||
|
|
52
lweb.pbi
52
lweb.pbi
|
@ -31,11 +31,11 @@ Module lhs_web
|
|||
Global.s conf_defaultfile = "index.html"
|
||||
Global.s conf_basedir = "/srv/lweb-srv/"
|
||||
Global.s conf_error400 = "integrated" ; Kann "integrated" sein wass die integrierte Standard Fehlermeldung hervorruft.
|
||||
Global.i conf_max_clients = 100 ; Max gleichzeitige HTTP Verbindungen. Dieser Wert ist anzupassen an das jeweilige System
|
||||
; Pro Thread werden mindestens 384KBytes benötigt (3 * (64 KByte Standard Buffer + 64 KByte Overhead Buffer))
|
||||
Global.i conf_max_HTTP_clients = 10 ; Max sametime HTTP connections.
|
||||
Global.i conf_max_HTTPS_clients = 100 ; Max sametime HTTPS connections.
|
||||
Global.i conf_server_type = 0
|
||||
Global.i conf_port = 8080
|
||||
Global.s conf_binding = "127.0.0.1"
|
||||
Global.i conf_HTTP_port = 8080
|
||||
Global.s conf_HTTP_binding = "127.0.0.1"
|
||||
Global.i conf_cache_time = 120 ;120Sekunden
|
||||
Global.i conf_cache_maxsize = 1 ;1 Mbyte
|
||||
Global.i conf_cache_current = 0
|
||||
|
@ -166,22 +166,22 @@ Module lhs_web
|
|||
|
||||
Procedure set_config(parameter.i=#conf_defaultfile, setting.s="index.html")
|
||||
Select parameter
|
||||
Case #conf_port
|
||||
conf_port = Val(setting)
|
||||
Case #conf_HTTP_port
|
||||
conf_HTTP_port = Val(setting)
|
||||
Case #conf_HTTPS_Port
|
||||
conf_HTTPS_Port = Val(setting)
|
||||
Case #conf_binding
|
||||
Case #conf_HTTP_binding
|
||||
If IsIPStringValid(setting)
|
||||
conf_binding = setting
|
||||
conf_HTTP_binding = setting
|
||||
Else
|
||||
conf_binding = "127.0.0.1"
|
||||
conf_HTTP_binding = "127.0.0.1"
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
Case #conf_HTTPS_Binding
|
||||
If IsIPStringValid(setting)
|
||||
conf_binding = setting
|
||||
conf_HTTP_binding = setting
|
||||
Else
|
||||
conf_binding = "127.0.0.1"
|
||||
conf_HTTP_binding = "127.0.0.1"
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
Case #conf_HTTPS_CA
|
||||
|
@ -200,11 +200,18 @@ Module lhs_web
|
|||
conf_basedir = setting
|
||||
Case #conf_error400
|
||||
conf_error400 = setting ; Kann "integrated" sein wass die integrierte Standard Fehlermeldung hervorruft.
|
||||
Case #conf_max_clients
|
||||
Case #conf_max_HTTP_clients
|
||||
If MemoryStatus(#PB_System_FreePhysical) > (Val(setting)*(1024*384))
|
||||
conf_max_clients = Val(setting)
|
||||
conf_max_HTTP_clients = Val(setting)
|
||||
Else
|
||||
conf_max_clients = 100
|
||||
conf_max_HTTP_clients = 10
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
Case #conf_max_HTTPS_clients
|
||||
If MemoryStatus(#PB_System_FreePhysical) > (Val(setting)*(1024*384))
|
||||
conf_max_HTTPS_clients = Val(setting)
|
||||
Else
|
||||
conf_max_HTTPS_clients = 10
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
Case #conf_server_type
|
||||
|
@ -225,12 +232,12 @@ Module lhs_web
|
|||
ProcedureReturn conf_basedir
|
||||
Case #conf_error400
|
||||
ProcedureReturn conf_error400
|
||||
Case #conf_max_clients
|
||||
ProcedureReturn Str(conf_max_clients)
|
||||
Case #conf_max_HTTP_clients
|
||||
ProcedureReturn Str(conf_max_HTTP_clients)
|
||||
Case #conf_server_type
|
||||
ProcedureReturn Str(conf_server_type)
|
||||
Case #conf_port
|
||||
ProcedureReturn Str(conf_port)
|
||||
Case #conf_HTTP_port
|
||||
ProcedureReturn Str(conf_HTTP_port)
|
||||
Case #conf_HTTPS_Port
|
||||
ProcedureReturn Str(conf_HTTPS_Port)
|
||||
Default
|
||||
|
@ -239,11 +246,11 @@ Module lhs_web
|
|||
EndProcedure
|
||||
|
||||
Procedure start_server()
|
||||
Global NewMap m_clients.s_clients(conf_max_clients)
|
||||
Global NewMap m_clients.s_clients(conf_max_HTTP_clients+conf_max_HTTPS_clients)
|
||||
Protected tlsresponse.i
|
||||
|
||||
;Init HTTP Socket
|
||||
server_HTTP_id = lsocket::CreateSocket(conf_port, conf_max_clients, lsocket::#SOCK_STREAM, lsocket::#AF_INET, conf_binding)
|
||||
server_HTTP_id = lsocket::CreateSocket(conf_HTTP_port, conf_max_clients, lsocket::#SOCK_STREAM, lsocket::#AF_INET, conf_HTTP_binding)
|
||||
If conf_HTTPS_enable = 1
|
||||
server_HTTPS_id = lsocket::CreateSocket(conf_HTTPS_Port, conf_max_clients, lsocket::#SOCK_STREAM, lsocket::#AF_INET, conf_HTTPS_binding)
|
||||
If server_HTTPS_id
|
||||
|
@ -282,7 +289,7 @@ Module lhs_web
|
|||
client_id = ltls::WaitTLSSocket(network_server_id)
|
||||
Debug "New HTTPS Client:"+Str(client_id)
|
||||
If client_id > 0
|
||||
If count_HTTPS_client < conf_max_clients
|
||||
If count_HTTPS_client < conf_max_HTTPS_clients
|
||||
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_srv = #SRV_DO_DataReceive
|
||||
|
@ -315,7 +322,7 @@ Module lhs_web
|
|||
client_id = lsocket::WaitSocket(network_server_id)
|
||||
Debug "New HTTP Client:"+Str(client_id)
|
||||
If client_id > 0
|
||||
If count_HTTP_client < conf_max_clients
|
||||
If count_HTTP_client < conf_max_HTTP_clients
|
||||
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_srv = #SRV_DO_DataReceive
|
||||
|
@ -331,7 +338,6 @@ Module lhs_web
|
|||
Break
|
||||
EndIf
|
||||
ForEver
|
||||
ltls::CloseTLS(network_server_id)
|
||||
EndProcedure
|
||||
|
||||
Procedure IsIPStringValid(Adress.s)
|
||||
|
|
|
@ -21,12 +21,13 @@ DeclareModule lhs_web
|
|||
;*
|
||||
|
||||
Enumeration e_conf
|
||||
#conf_port
|
||||
#conf_binding
|
||||
#conf_HTTP_port
|
||||
#conf_HTTP_binding
|
||||
#conf_defaultfile
|
||||
#conf_basedir
|
||||
#conf_error400
|
||||
#conf_max_clients
|
||||
#conf_max_HTTP_clients
|
||||
#conf_max_HTTPS_clients
|
||||
#conf_server_type
|
||||
#conf_cache_enable
|
||||
#conf_HTTPS_CA
|
||||
|
|
Loading…
Reference in a new issue