[MDEV-15635] mysys: THR_LOCK_open reduce usage Created: 2018-03-22  Updated: 2019-02-06  Resolved: 2018-05-19

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Fix Version/s: 10.3.7

Type: Task Priority: Major
Reporter: Sergey Vojtovich Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: contribution, foundation


 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.


Generated at Thu Feb 08 08:22:53 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.