From: Tanaka Akira Date: 2009-09-03T19:46:43+09:00 Subject: [ruby-dev:39223] Re: [ruby-cvs:31917] Ruby:r24699 (trunk): * lib/tmpdir.rb (Dir.mktmpdir): removed thread race condition. In article <4a9f873c.22035a0a.40fb.2740@mx.google.com>, Nobuyoshi Nakada writes: > O_EXCL自体がサポートされていないということは、既存のファイルを上 > 書きしてしまうということじゃないでしょうか。 なかださんが [ruby-dev:39210] で引用したマニュアルの記述は、 単に O_EXCL が無視されるっていうニュアンスではないように思い ます。「競合状態 (race condition) に出会う可能性がある」とい う話なので、競合が起きなければ動くんじゃないでしょうか。 テンポラリファイルの場合、成功すべきところで失敗するだけなら ごみファイルができるだけで済みますが、失敗すべきところで成功 すると上書きされる可能性が出てきます。 UDP で response が落ちるというだけなら前者で済むと思うんです が、それ以外にもなにか問題があると上書きしちゃうかもしれない ですね。 いちおう、RFC 1094 には | 2.2.10. Create File | | struct createargs { | diropargs where; | sattr attributes; | }; | | diropres | NFSPROC_CREATE(createargs) = 9; | | The file "name" is created in the directory given by "dir". The | initial attributes of the new file are given by "attributes". A | reply "status" of NFS_OK indicates that the file was created, and | reply "file" and reply "attributes" are its file handle and | attributes. Any other reply "status" means that the operation failed | and no file was created. | | Notes: This routine should pass an exclusive create flag, meaning | "create the file only if it is not already there". とあって、Notes のところで O_EXCL を渡すと読めるような気がし ないでもない記述があるんですが。 -- [田中 哲][たなか あきら][Tanaka Akira]