Hello,

I have the following function called from worker thread context (NewHSocket 
passed with a message):

function TCustomWSocketMTServer.AfterClientCreated(
    Client : TWSocketMTClient; Error: Word; NewHSocket: integer) : boolean;
var
    currentClientCount: integer;
    currentMaxClients: integer;
begin
    Result := TRUE;

    FCriticalSection.Enter;
    Inc(FClientNum);
    Client.Name            := Name + 'Client' + IntToStr(FClientNum);
    FClientList.Add(Client);
    currentClientCount     := FClientList.Count;
    Client.Banner          := FBanner;
    Client.Server          := Self;
    currentMaxClients      := FMaxClients;
    FCriticalSection.Leave;

    {$IFNDEF NO_DEBUG_LOG}
    Client.IcsLogger       := IcsLogger;                           { V5.04 }
    {$ENDIF}

    Client.Dup(NewHSocket);  // SOMETIMES WHEN HIGH LOAD IS IN PLACE, THIS 
FUNCTION MAKES CLIENT.HSOCKET = -1 AND RAISES THE EXCEPTION "LIST ITEM OUT 
OF INDEX"
    Client.OnDataSent := nil;

    TriggerClientConnect(Client, Error);

    { Ok, the client is still there, process with the connection }
    if (currentMaxClients > 0) and (currentClientCount > currentMaxClients) 
then begin
        { Sorry, too much clients }
        Client.Banner := BannerTooBusy;
        Client.OnDataAvailable := nil; // should be set previously in 
initClient for non-503
        Client.StartConnection;
        Client.CloseDelayed;

        Result := false;
    end;
end;

Any idea?

Best Regards,

SZ 

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to