Re: [fpc-pascal] RTL Thread.ExecuteInThread interface and implementation wrong

2018-03-21 Thread Michael Van Canneyt



On Tue, 20 Mar 2018, Anthony Walter wrote:


Okay, but the problem with the current implementation in Classes.pas is
that Status cannot be used, Terminated cannot be checked, and there is no
access to Synchronize.


All wrong. See below.


As such OnStatus is pointless, and the semantics of
checking Terminated doesn't work. If that's how the these
ExecuteInThread class methods on TThread are going work then they should be
removed because they don't have significant function and likely would
confuse users.

Eg. of confusion when trying to use ExecuteInThread Q: How does OnStatus
work? A: It doesn't.


And why doesn't it ?

You must obviously pass a callback. Just as in asynchronous programming. 
Of course your function must call it from time to time.



Q: How can I check if my thread method is terminated?


By passing aOnTerminate ?

If you mean inside the thread, use TThread.CheckTerminated. 
This is a class function.


or use TThread.CurrentThread.Terminated;



A: Forget about Thread.Terminated, you'll need to set a flag somewhere or
create you own solution. Q: How can I suspend my method and safely join the
main thread, because I normally use Synchronize? A: You'll have to do
without Synchronize or maybe figure out a workaround.


You can perfectly call Synchronize. It is a class method:

Procedure MyThreadHandlerFunction ;

begin
  TThread.Synchronize(CurrentThreead,SomeMethod);
end;



So IMO ExecuteInThread should either be removed or these problems should be
fixed.



IMO you should check the documentation a little more thorough.

https://www.freepascal.org/docs-html/current/rtl/classes/tthread.executeinthread.html

It contains 4 examples that show how things work.

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] What changed in fcl-web?

2018-03-21 Thread Luca Olivetti
I have a standalone web application (fphttpapp) with a main module and a 
couple of additional modules.

I developed it a while ago with fpc-2.6.4 and it works quite well.

If I compile it with fpc 3.0.4 it stops working:

1) the second time I load a page I get an error

Error: Duplicate name: A component named "MainModule" already exists

If I change the Kind of the web module from wkPooled to wkOneShot it 
doesn't happen, but why do I have to change it and what other side 
effects will it have?



2) all the requests are passed to the main module and not to the 
additional ones, e.g. the request


 http://myserver:8085/files/test.html


with 2.6.4 would be dispatched to the module where I did a

  RegisterHTTPModule('files',TFiles)

with 3.0.4 it doesn't


Bye
--
Luca
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] What changed in fcl-web?

2018-03-21 Thread Luca Olivetti

El 21/03/18 a les 16:32, Luca Olivetti ha escrit:
I have a standalone web application (fphttpapp) with a main module and a 
couple of additional modules.

I developed it a while ago with fpc-2.6.4 and it works quite well.

If I compile it with fpc 3.0.4 it stops working:


Never mind, meanwhile I found this (I remember reading it but I didn't 
give it too much thought at the time)


http://lists.freepascal.org/pipermail/fpc-pascal/2017-January/049852.html

Application.LegacyRouting:=true

fixes it

Bye
--
Luca
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] [FCL-WEB] Multiple Modules - On Session

2018-03-21 Thread leledumbo via fpc-pascal
> It seems that session management create one separate session by each module

That's right but should be OK, as the session is created based on cookie,
which if already exists, will be loaded instead of created. If memory serves
right, I remember you should set one or a few of these:
* fphttp.SessionFactory.SessionCookie
* fphttp.SessionFactory.SessionCookiePath

optionally, to easily check the created session files, you might want to
also set:
* (fphttp.SessionFactory as iniwebsession.TIniSessionFactory).SessionDir




--
Sent from: http://free-pascal-general.1045716.n5.nabble.com/
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal