On Friday 20 May 2011, Dovid Bender wrote: > I had issue with call files. They would lock up the system (this was 5 > years ago so maybe things have changed.....)
Whenever you open a file for writing, a link is created in the containing folder's directory (which says where on the disk the file is located) pretty much straight away -- so other processes can see the file. And files are written to disk, not one character at a time, but in blocks whose size depends on the filesystem, one full block at a time. The last block may well be incomplete, and so contain junk after the file proper; but the directory entry gives the actual file size, so the junk can be ignored.# This creates a race condition: Asterisk may try to parse a call file which is still in an incomplete state (empty or just the first block of several), and get its knickers in a twist. The *proper* way to avoid this situation, is to create the call file in a temporary location first; then `mv` it to the /var/spool/asterisk/outgoing/ folder. Moving a file within a filesystem just entails putting a new link in the destination folder's directory, and removing the one from the old directory. Moving a file across filesystems entails a copy operation; but either way, the important thing is that *the link to the destination file won't be placed in the folder's directory until the data is actually there*. The *bodgy* way to avoid this situation, is to make sure the file is smaller than one logical block on the filesystem where .../outgoing/ resides; turn off buffer autoflushing in the scripting language; and cross your fingers that the file will already be complete in the cache when the directory is updated. And even if it works on your system today, you might find that an upgrade to Asterisk, your scripting language, whatever invoked the script, the filesystem driver in the kernel, or even a change in RAM or disk usage on your server, breaks it tomorrow. -- AJS Answers come *after* questions. -- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
