Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-10

How to stop a HttpApp via request? (Regression)

8 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog

Hello,

I updated the fcl-net and fcl-web of my Free Pascal copy, but when I try to terminate my app via request, it return same error reported in this topic.

My code is:

   1. program project1;
   2.
   3. {$mode objfpc}{$H+}
   4.
   5. uses
   6.   heaptrc, sysutils, HttpDefs, CustWeb, CustHTTPApp, FPHTTPServer;
   7.
   8. type
   9.
   10.   { TMyHttpApplication }
   11.
   12.   TMyHttpApplication = class(TCustomHTTPApplication)
   13.   protected
   14.     function InitializeWebHandler: TWebHandler; override;
   15.   end;
   16.
   17.   { TMyEmbeddedHttpServer }
   18.
   19.   TMyEmbeddedHttpServer = class(TEmbeddedHttpServer)
   20.   protected
   21.     function CreateRequest: TFPHTTPConnectionRequest; override;
   22.     function CreateResponse(ARequest: TFPHTTPConnectionRequest):
   23.       TFPHTTPConnectionResponse; override;
   24.   public
   25.     property Active;
   26.   end;
   27.
   28.   { TMyHttpServerHandler }
   29.
   30.   TMyHttpServerHandler = class(TFPHTTPServerHandler)
   31.   protected
   32.     function CreateServer: TEmbeddedHttpServer; override;
   33.   public
   34.     procedure HandleRequest(ARequest: TRequest; AResponse: TResponse)
   ; override;
   35.   end;
   36.
   37.   { TMyHttpApplication }
   38.
   39.   function TMyHttpApplication.InitializeWebHandler: TWebHandler;
   40.   begin
   41.     Result := TMyHttpServerHandler.Create(Self);
   42.   end;
   43.
   44.   { TMyEmbeddedHttpServer }
   45.
   46.   function TMyEmbeddedHttpServer.CreateRequest:
    TFPHTTPConnectionRequest;
   47.   begin
   48.     Result := TFPHTTPConnectionRequest.Create;
   49.   end;
   50.
   51.   function TMyEmbeddedHttpServer.CreateResponse(
   52.     ARequest: TFPHTTPConnectionRequest): TFPHTTPConnectionResponse;
   53.   begin
   54.     Result := TFPHTTPConnectionResponse.Create(ARequest);
   55.   end;
   56.
   57.   { TMyHttpServerHandler }
   58.
   59.   function TMyHttpServerHandler.CreateServer: TEmbeddedHttpServer;
   60.   begin
   61.     Result := TMyEmbeddedHttpServer.Create(Self);
   62.   end;
   63.
   64. var
   65.   App: TMyHttpApplication;
   66.
   67.   procedure TMyHttpServerHandler.HandleRequest(ARequest: TRequest;
   68.     AResponse: TResponse);
   69.   begin
   70.     if not App.Terminated then
   71.       App.Terminate;
   72.   end;
   73.
   74. begin
   75.   App := TMyHttpApplication.Create(nil);
   76.   try
   77.     App.Port := 5445;
   78.     App.Threaded := True;
   79.     App.Initialize;
   80.     App.Run;
   81.     DeleteFile('HEAP.TRC');
   82.     SetHeapTraceOutput('HEAP.TRC');
   83.   finally
   84.     App.Free;
   85.   end;
   86. end.

http://pastebin.com/503S2Nin

The error:

"Could not accept a client connection on socket: -1, error 10004."

Thank you!

Silvio Clécio My public projects - github.com/silvioprog
Michael Van Canneyt
to silvioprog
silvioprog wrote
Hello, I updated the fcl-net and fcl-web of my Free Pascal copy, but when I try to terminate my app via request, it return same error reported in this topic.

It works fine here.

Michael.

silvioprog
to Michael Van Canneyt

2013/10/18 Michael Van Canneyt

Show quoted text 12 lines
On Thu, 17 Oct 2013, silvioprog wrote: > Hello, > I updated the fcl-net and fcl-web of my Free Pascal copy, but when I try > to terminate my app via request, it return same error reported in this > topic. > It works fine here. Michael.

You're right. The problem is in my FPC copy, I'm waiting for the Lazarus team to create a snapshot of the current FPC.

Silvio Clécio My public projects - github.com/silvioprog
Michael Van Canneyt
to silvioprog
silvioprog wrote 13 lines
2013/10/18 Michael Van Canneyt On Thu, 17 Oct 2013, silvioprog wrote: Hello, I updated the fcl-net and fcl-web of my Free Pascal copy, but when I try to terminate my app via request, it return same error reported in this topic. It works fine here. Michael. You're right. The problem is in my FPC copy, I'm waiting for the Lazarus team to create a snapshot of the current FPC.

I would not wait for that.

A Lazarus built with the current trunk FPC is nearly unworkable. (I suspect the changes in string handling are to blame for that)

Michael.

Jonas Maebe
to Michael Van Canneyt
Michael Van Canneyt wrote
A Lazarus built with the current trunk FPC is nearly unworkable. (I suspect the changes in string handling are to blame for that)

There were severe stability problems with FPC trunk r24953 till r25684 because of an invalid optimisation for reference counted strings passed to const parameters, but that's the only thing I can think of and this has been fixed.

Jonas

Michael Van Canneyt
to Jonas Maebe
Jonas Maebe wrote 10 lines
On 22 Oct 2013, at 14:10, Michael Van Canneyt wrote: > A Lazarus built with the current trunk FPC is nearly unworkable. (I suspect > the changes in string handling are to blame for that) There were severe stability problems with FPC trunk r24953 till r25684 because of an invalid optimisation for reference counted strings passed to const parameters, but that's the only thing I can think of and this has been fixed.

Well. I don't know what exactly caused it.
I reverted to using a 2.6.2 version of FPC for my Lazarus work.

I can always test once more with a trunk version.

Michael.

LacaK
to Jonas Maebe: There were severe stability problems with FPC trunk r24953 till r25684 because of an…

Jonas Maebe wrote / napísal(a):

Show quoted text 11 lines
On 22 Oct 2013, at 14:10, Michael Van Canneyt wrote: > A Lazarus built with the current trunk FPC is nearly unworkable. (I > suspect the changes in string handling are to blame for that) There were severe stability problems with FPC trunk r24953 till r25684 because of an invalid optimisation for reference counted strings passed to const parameters, but that's the only thing I can think of and this has been fixed.

Hm , I do not know reason, but Lazarus snapshots at ftp://wiki.freepascal.org/pub/lazarus/snapshots/ for Win32,64 with FPC 2.6.3, 2.7.1
are not updated more than month.
-Laco.

Jonas Maebe
to LacaK
LacaK wrote
Hm , I do not know reason, but Lazarus snapshots at ftp://wiki.freepascal.org/pub/lazarus/snapshots/ for Win32,64 with FPC 2.6.3, 2.7.1 are not updated more than month.

At least for Linux, there's currently the problem that linking cairo has been broken for a while. That hasn't been the case for more than a month though. You'll have to ask the Lazarus developers in any case.

Jonas