NetTalk Central

Author Topic: Cleaning up temporary files  (Read 3797 times)

Koen Tjoa

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • Email
Cleaning up temporary files
« on: November 24, 2011, 10:18:26 AM »

Hi all,

I have a  temporary TPS file which stores the SessionID and some other fields. The records of a particular session are deleted in the DeleteSession method of the WebHandler procedure when the user’s session ends. This works fine except in situations that the web server is stopped prematurely. Then there are remainders in the temporary file of old sessions.

My first guess is to empty the file in the Init method of the WebServer procedure as there cannot be active sessions when the web server starts. But will this also work when my application is compiled as a DLL for use on the Multi Site Host? I cannot test it right now, I want just to be prepared for Multi Site Host.


Devan

  • Full Member
  • ***
  • Posts: 230
    • View Profile
    • Email
Re: Cleaning up temporary files
« Reply #1 on: November 24, 2011, 01:55:50 PM »
Why don't you just use an In-Memory table to store the information instead of a TopSpeed file?  Automatically gets cleaned up every time the Web Server app is terminated for any reason...

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11275
    • View Profile
Re: Cleaning up temporary files
« Reply #2 on: November 24, 2011, 07:42:50 PM »
>> My first guess is to empty the file in the Init method of the WebServer procedure as there cannot be active sessions when the web server starts. But will this also work when my application is compiled as a DLL for use on the Multi Site Host?

yes. The Init method in the web server is the only bit of code that runs under multi-host, when the DLL loads.

cheers
Bruce

Koen Tjoa

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • Email
Re: Cleaning up temporary files
« Reply #3 on: November 25, 2011, 05:53:57 AM »

Hi Bruce,

Thanks for confirming.

@Devan: You are right and I own the IM driver. However during development time I would like to observe what is written to it. Just opening the TPS file is the most easiest especially when the web server crashes due to erroneous writing to that file.

Cheers,
Koen