Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Antwort: How does one persist data? Re:

From: sharriff:aina:med-iq at: 12-Oct-2000 7:33

Thank you Mr. Kracik! If only I undersatood completely whats going on in the script. Please correct me if I´m wrong: 1.Files in use are flagged with "semaphore" 2. The files in use are renamed as "%lock.locked" The script loops, continues to "Try" to rename, if it encounters an error then it "waits". Wonßt I get an error anyway if the file is directly renamed when I CGI script user requests a file? Excuse my newbie question Best regards Sharriff Aina med.iq information & quality in healthcare AG Gutenbergstr. 42 [kracik--mbox--d] km.cz An: [list--rebol--com] Kopie: 11.10.00 Thema: [REBOL] How does one persist data? Re: 21:56 Bitte antworten an list Hi Sharriff, be careful when saving to a file and reading it later, as many users may run your CGI programs simultaneously. You should use some form of inter-process synchronization to serialize access to your file. AFAIK from REBOL you can reliably synchronize by opening TCP sockets or renaming a file. I use these two functions: obtain-semaphore: func [] [ loop 100 [ if not error? try [ rename %lockdir/lock %lock.locked ] [ return ] wait ( random 5 ) / 10 ] print "Could not obtain semaphore" quit ] release-semaphore: func [] [ loop 100 [ if not error? try [ rename %lockdir/lock.locked %lock ] [ return ] wait ( random 5 ) / 10 ] print "Could not release semaphore" quit ] -- Michal Kracik [Sharriff--Aina--med-iq--de] wrote: