local %ENV doesn't remove the magic attached to %ENV, so changes to %ENV still affect every thread, so the race condition remains.
THREAD 1 THREAD 2
---------------------------------- ------------------------------
+----
{ T
local %ENV; i
-> Process's R_M remains undef m
$ENV{REQUEST_METHOD} = 'GET'; e
-> Process's R_M becomes GET |
| {
| local %ENV;
v -> Process's R_M becomes undef
$ENV{REQUEST_METHOD} = 'PUT';
-> Process's R_M becomes PUT
print($ENV{REQUEST_METHOD});
-> Prints process's R_M (PUT)
}
-> Process's R_M restored to undef
print($ENV{REQUEST_METHOD});
-> Prints process's R_M (undef
+)
}
-> Process's R_M restored to u
+ndef
That's why I suggested local *ENV instead. Then modifying %ENV doesn't change the processes environment.
Update: Added illustration of two race conditions.
|