Recent

Author Topic: Synapse Http Server  (Read 1213 times)

fjabouley

  • Full Member
  • ***
  • Posts: 128
Synapse Http Server
« on: June 04, 2020, 02:56:10 pm »
Hello all,
I'm trying to port my former http server using synapse libraries, just to see which one is the more stable.
May I have your opinion on what I coded if I'm doing totally wrong, or if it is OK ?
It has currently worked for many days without issues, but I don't know if there is a better way coding it...
Best regards

yus

  • Jr. Member
  • **
  • Posts: 57
Re: Synapse Http Server
« Reply #1 on: June 04, 2020, 08:25:46 pm »
Synapse have examples with HTTP and HTTPS server.
I using synapse http server, work perfect.


I have a question about using the critical section?
I think to use correctly
Code: Pascal  [Select][+][-]
  1. locksection.Enter
  2. try
  3.   /// some critical code
  4. finally
  5.   locksection.Leave
  6. end

And i use TRTLCriticalSection

https://www.freepascal.org/docs-html/rtl/system/trtlcriticalsection.html

You code will be

Code: Pascal  [Select][+][-]
  1. var
  2.   locksection: TRTLCriticalSection;
  3.  
  4. TSomeClass.Create;
  5. begin
  6.  ///  some code
  7.  InitCriticalSection(locksection);
  8. end;
  9.  
  10. TSomeClass.Destroy;
  11. begin
  12.  ///  some code
  13.  DoneCriticalSection(locksection);
  14. end;




Code: Pascal  [Select][+][-]
  1. EnterCriticalsection(locksection);
  2. try
  3.   /// some critical code
  4. finally
  5.   LeaveCriticalsection(locksection);
  6. end

« Last Edit: June 04, 2020, 08:55:35 pm by yus »

fjabouley

  • Full Member
  • ***
  • Posts: 128
Re: Synapse Http Server
« Reply #2 on: June 05, 2020, 07:52:05 am »
Thanks for you reply.
Actually I used critical section in the thread's procedures, mainly while loading files from hard drive (don't know if it is useful, but I thought that 2 threads reading the same file at the same time would be an issue) and to update/read the sessions which are stored in a global variable, outside the main thread. But there must be another way to do that (or not ?)
Regards

 

TinyPortal © 2005-2018