Skip to content

Conversation

grooverdan
Copy link

By considering my_*_opened as statistical counters and file descriptors as unique with a little restructuring we can eliminate lots of THR_LOCK_open usage.

Change the following to statistic counters:
* my_file_opened
* my_file_total_opened
* my_stream_opened
* my_tmp_file_created

A file descriptor is already a unique element per process - in Windows,
protection occurs at fd allocation using THR_LOCK_open in my_win_{,f}open
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/my_win_fclose. After these calls another
thread could gain the same file descriptor. So for Windows this
the file_info elements available to the my_win_{,f}_open are released
during the invalidate_fd call within my_win_close. No locking is needed
as the my_win_{,f}open is searching for a invalidate entry which is
determined by a single value change.

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.
my_file_opened are now my_stream_opened incremented without locks
so there is a small chance that they will not be statisticly accurate.

As my_end error messages should be accurate, lets not take a chance and
iterate the array, displaying each open file under EXTRA_DEBUG, and
display a warning if a mismatch of files/streams opened occurred.
@grooverdan
Copy link
Author

I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

@mysql-oca-bot
Copy link

Hi, thank you for your contribution. Please confirm this code is submitted under the terms of the OCA (Oracle's Contribution Agreement) you have previously signed by cutting and pasting the following text as a comment:
"I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it."
Thanks

@mysql-oca-bot
Copy link

Hi, thank you for your contribution. Your code has been assigned to an internal queue. Please follow
bug http://bugs.mysql.com/bug.php?id=93934 for updates.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants