response time can thus be reduced on heavy load.
download the latest version and source on my web site.
http://base.3322.org/miniweb/
Here is my server thread
download the latest version and source on my web site.
http://base.3322.org/miniweb/
Here is my server thread
ServerThread proc
LOCAL hHttpMem:DWORD
LOCAL Req:REQUESTINFO_STRUCT
invoke GlobalAlloc,GMEM_MOVEABLE or GMEM_ZEROINIT,HTTPBufSize
mov hHttpMem,eax
invoke GlobalLock,eax
mov Req.lpPath,eax
Invoke Beep, 1800, 10
ThreadLoop:
;Get a sock from the sock queue
xor eax,eax
lea ebx,SockQueue
invoke WaitForSingleObject,hMutex,-1
mov al,SockHead
push dword ptr [ebx+eax*4]
mov dword ptr [ebx+eax*4],0
lea ebx,TimeQueue
push dword ptr [ebx+eax*4]
inc al
and al,MaxThread
mov SockHead,al
invoke ReleaseMutex,hMutex
pop ebx
invoke GetTickCount
sub eax,ebx
mov Req.ReqTick,eax
pop eax
.if eax==0
jmp ThreadExit
.endif
mov Req.hSock,eax
invoke recv,Req.hSock,Req.lpPath,HTTPBufSize-1,NULL
lea ebx,Req
assume ebx:ptr REQUESTINFO_STRUCT
call ParseHeader
.if eax==1
call SendFile
.elseif eax==2
call CGIProcess
.elseif eax==3
call CGIProDLLProc
.endif
invoke closesocket,[ebx].hSock
inc cfg.FreeThreads
.if cfg.MaxLogSize>0
invoke AddLogText,addr Req
.endif
invoke WaitForSingleObject,hEventServe,10000
dec cfg.FreeThreads
.if eax==WAIT_OBJECT_0
jmp ThreadLoop
.endif
;Free up memory
ThreadExit:
invoke GlobalUnlock,Req.lpPath
invoke GlobalFree,hHttpMem
dec cfg.TotalThreads
IFE APPMODE
call UpdateDisplay
ENDIF
ret
ServerThread endp