Jump to content

djhfwk

Members
  • Content Count

    10
  • Joined

  • Last visited

Posts posted by djhfwk


  1. procedure THttpCli.DoRequestSync(Rq : THttpRequest);  { V7.04 Timeout added }
    var
        TimeOutMsec     : UINT;
        bFlag           : Boolean;
        dwWaitMs        : DWORD;	
        AbortRequired   : Boolean;         { V8.71 JK }
        AbortMsg        : String;          { V8.71 JK }
    begin
        DoRequestAsync(Rq);
        if not Assigned(FCtrlSocket.Counter) then
            FCtrlSocket.CreateCounter;
        FCtrlSocket.Counter.LastSendTick := IcsGetTickCount64; // Reset counter      { V8.71 }
        if FMultiThreaded then
           dwWaitMs:= 10 else
           dwWaitMs:= 1000;
        TimeOutMsec := FTimeOut * 1000;
        while FState <> httpReady do begin
          {$IFDEF MSWINDOWS}
            if MsgWaitForMultipleObjects(0, Pointer(nil)^, FALSE, dwWaitMs,
                                         QS_ALLINPUT) = WAIT_OBJECT_0 then
          {$ENDIF}
                MessagePump;
    
    
          { V8.71 JK see if user wants to abandon this request }

    In multithread mode, i think we can use lower period for MsgWaitForMultipleObjects.

     

     


  2. The UdpDataAvailable procedure should add len check before setlength,

    sometimes FUdpSocket.RcvdCount will return 0, and this will cause range error in delphi 11.1, although this can be turn off by uncheck the Range Check option in Project Options.

     

    procedure TSysLogServer.UdpDataAvailable(Sender: TObject; ErrCode: Word);
    var
        RawMessage : AnsiString;
        Len        : Integer;
        Src        : TSockAddrIn;
        SrcLen     : Integer;
        SrcIP      : AnsiString;
        SrcPort    : AnsiString;
    begin
        SrcLen := SizeOf(Src);
        Len    := FUdpSocket.RcvdCount;
    
        if Len = 0 then  //this should be added, but will cause the UdpDataAvailable event hang randomly
            Exit;
    
        SetLength(RawMessage, Len);
        Len    := FUdpSocket.ReceiveFrom(@RawMessage[1], Length(RawMessage),
                                         Src, SrcLen);
        if Len < 0 then
            Exit;
        SetLength(RawMessage, Len);
        SrcIP   := IcsStrPas(inet_ntoa(Src.sin_addr));
        SrcPort := AnsiString(IntToStr(ntohs(Src.sin_port)));
        if Assigned(FOnDataAvailable) then
            FOnDataAvailable(Self, SrcIP, SrcPort, RawMessage);
    end;

     

     


  3. On 11/27/2018 at 4:27 AM, vhanla said:

    Just created a DLL project, compiled and it shows the following exported functions.

     

    
    __dbk_fcall_wrapper
    dbkFCallWrapperAddr
    TMethodImplementationIntercept
    
    

     

    Are they necessary? Any way to hide them?

     

    not only dll but also exe have these exports.

    if you have source, modify the source and use BuildRTLGroup to rebuild the source,

    no source, use the tool to remove the exports.

×