[m-dev.] for review: fix io__tmpnam race condition

Thomas Charles CONWAY conway at cs.mu.OZ.AU
Thu Jun 25 09:00:58 AEST 1998


Fergus Henderson, you write:
> Fix race condition problems with io__tmpnam.
> 
> library/io.m:
> 	Add io__make_temp, which is like io__tmpnam except that it
> 	actually creates the file rather than just choosing its name.
> 	This avoids a race condition where some other process could
> 	create a file with the same name in between the call to
> 	io__tmpnam and the call to io__open_output.
> 	Add `pragma obsolete' declarations for io__tmpnam (both versions)
> 	and document that their use is deprecated.
> 	Reimplement io__tmpnam by calling io__make_temp and then
> 	io__remove_file.
> 
> 	Also, use six hex digits rather than 3 decimal ones, and
> 	add `1 << num_tries' rather than `1' to the counter each time.
> 	This should hopefully reduce contention.
> 
> 	The race condition was being triggered when you started up
> 	multiple processes each of which created multiple temp files
> 	(e.g. when doing `mmake -j8 depend' in the various `tests'
> 	subdirectories).

This looks fine, thanks.

Thomas
-- 
Thomas Conway <conway at cs.mu.oz.au>
Nail here [] for new monitor.  )O+



More information about the developers mailing list