| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | timEd message base locking (or lack thereof) in UNIX |
25 Oct 12 04:45, I wrote to all:
ac> Or I could just not use Squish format, I suppose. On modern PCs with
ac> new filesystems, having few thousand *.MSG files in a single directory
ac> is not a big deal.
Actually in hindsight with *.MSG there's still a window where a tosser can
overwrite a message editor's newly-created .MSG file. The problem is that
both programs need to find the highest numbered .MSG file first before
creating the new message, and the time this takes even on a modern PC that
could be quite high - in the order of several seconds if the CPU is loaded,
or the filesystem is on a remote machine. During this window it's possible
for the other program to generate a new message, so the "highest
message" counter can get out of sync between the two programs. The
higher the number of messages the more likely it is to occur.
Just out of curiosity I hacked together two short Python programs. One to
create the .msg files initially, and the other to look for the highest
numbered .msg file. On my system both of these programs take less than a
second to run, but this is on a fast CPU on a local filesystem.
#!/usr/bin/env python
# Create 5000 files named 1.msg to 5000.msg
for i in range(5000):
fn = '%d.msg' % (i + 1, )
fp = open(fn, 'w')
fp.close()
#!/usr/bin/env python
# Find the highest numbered .msg file in a directory
import os, os.path
highest = 0
dp = os.listdir('.')
for fn in dp:
filename, ext = os.path.splitext(fn)
if ext == '.msg':
n = 0
try:
n = int(filename)
except ValueError:
pass
if n > highest:
highest = n
print highest
--- GoldED+/BSD 1.1.5-b20110223-b20110223
* Origin: Blizzard of Ozz, Melbourne, Victoria, Australia (3:633/267)SEEN-BY: 633/267 712/848 @PATH: 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.