Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
Description
Change the following to statistic counters:
|
|
my_file_opened
|
my_file_total_opened
|
my_stream_opened
|
my_tmp_file_created
|
There is one non-statistics use of my_file_opened/my_stream_opened
|
in my_end which prints a warning if we shutdown and its still open.
|
It seems excessive to hold locks to prevent this warning.
|
|
A file descriptor is already a unique element - in Windows protection
|
occurs at fd allocation using THR_LOCK_open in my_win_fopen
|
and in other OSes, a unique fd to file map exists at the OS level.
|
So accesses to my_file_info[fd] don't need to be protected by the
|
THR_LOCK_open.
|
|
my_close/my_fclose where restructured to clear out the my_file_info
|
before the close/my_win_close. After these calls another thread could
|
gain the same file descriptor. Windows doesn't need THD_LOCK_open
|
into my_win_close as there is no conflict with the my_win_fopen in allocating a fd.
|
|
my_fclose also changed for non-Windows to retry closing if EINTR was
|
returned, same as my_close..
|
|
FYI @vaintroub
|
|
Pathological cases - two threads attempt to close the same file at same time at which there is a chance of double free. If there is this case, there's a equal failing that the file descriptor could have been reallocated before the second close call was complete, also leading to wrongness.
|