|
2026-10-22
| ||
| 17:19 | • Ticket [4f322b9d21] Impossibility to create an unique path in Tcl (e. g. using f... artifact: ba33e60b4b user: serhiy.storchaka | |
|
2026-10-15
| ||
| 11:39 | • Closed ticket [4f322b9d21]. artifact: 6ca8405452 user: serhiy.storchaka | |
|
2018-10-10
| ||
| 22:41 | • Ticket [4f322b9d21]: 3 changes artifact: 8c357b4f90 user: sebres | |
|
2018-07-12
| ||
| 13:51 | • New ticket [3f7af0e21e] win: file delete could sporadic fail with "permissi... artifact: b079f464c5 user: sebres | |
| 09:43 | • Ticket [4f322b9d21] Impossibility to create an unique path in Tcl (e. g. using f... artifact: c7fe9f4d49 user: aspect | |
|
2018-07-11
| ||
| 00:22 | • Ticket [270f78ca95] file mkdir: race condition if two workers creates same direc... artifact: 3a4e4e651b user: sebres | |
|
2018-07-09
| ||
| 17:38 | • Closed ticket [270f78ca95]. artifact: 3bc605cd57 user: sebres | |
|
2018-07-02
| ||
| 15:05 | • Pending ticket [4f322b9d21]: Impossibility to create an unique path in Tcl (e. g... artifact: 46d09e9de4 user: sebres | |
| 14:46 | Closes RFE [4f322b9d21]: provide return value for `file mkdir` to recognize the directories are real... check-in: 7e5504fecf user: sebres tags: rfe-4f322b9d21 | |
| 12:12 | • New ticket [4f322b9d21] Impossibility to create an unique path in Tcl (e. g. usi... artifact: 51847a2a1a user: sebres | |
Impossibility to create an unique path in Tcl (e. g. using file mkdir)
proc get_unique_dir {} {
while 1 {
set p [file join $GLOB_PATH [some_uuid_algo]]
if {![file exists $p]} {
file mkdir $p
break
}
}
return $p
}
But it's affected by the race condition (firstly not exists for both workers, then one creates sub-path, another returns with no error in `file mkdir` on same existing path), if some_uuid_algo cannot guarantee a system-wide unique path.
So the creation of a safe construct for that is impossible in Tcl currently.
Suggestion:
Currently `file mkdir` returns no result at all.
If `TclFileMakeDirsCmd` will be extended with return value as counter (of created tail-directories), one may use it to avoid race condition in above-mentioned script, like here:
proc get_unique_dir {} {
while 1 {
set p [file join $GLOB_PATH [some_uuid_algo]]
if {[file mkdir $p]} {
break
}
}
return $p
}
This is race condition safe.
The only one backwards-incompatibility in this case would be usage like this:
But I believe the way like this is very rarely (or almost never) used.
set some_var "when [file mkdir $some_path]was used in substitution"
b079f464c5New ticket [3f7af0e21e] win: file delete could sporadic fail with "permission denied". ticket2018-07-12 13:51:213a4e4e651bTicket [270f78ca95] file mkdir: race condition if two workers creates same directory and one worker deletes it immediately status still Closed with 5 other changes ticket2018-07-11 00:22:243bc605cd57Closed ticket [270f78ca95]: file mkdir: race condition if two workers creates same directory and one worker deletes it immediately plus 6 other changes ticket2018-07-09 17:38:037e5504fecfCloses RFE [4f322b9d21]: provide return value for `file mkdir` to recognize the directories are really created, that can be used to avoid race condition by creating system-wide unique path (with multiple workers). See https://core.tcl-lang.org/tcl/info/4f322b9d2112772a for example. check-in2018-07-02 14:46:12
Implemented in branch rfe-4f322b9d21 for >= 8.5th.
Although I think, it could be accepted as it's, adding a short changelog entry with small incompatibility note like: command `file mkdir` returns integer now vs. nothing previously... But TCT should decide about it.
So pending as implemented.
I approve of this change. Can we afford to break code that relies on the empty result from [file mkdir]? See also https://core.tcl.tk/tips/doc/trunk/tip/431.md and the ensuing wiki discussion at https://wiki.tcl.tk/40609 https://core.tcl.tk/tcl/info/270f78ca95b642fb is also relevant.
So [270f78ca95b642fb] is definitely closed, well it is time to "close" another race-condition (this RFE fixed).
Someone with an idea to bring this thing further?
I spoke to several people: no one has used [file mkdir] to get/check empty return value / or somehow expected empty values in string like "...[file mkdir]..." or similar imaginable substitutions.
Any suggetions, proposals, etc?
Never merged (the return value change would need a TIP); in Tcl 9.0 [file tempdir] from TIP 431 creates a unique directory atomically.