diff options
author | Sergei Golubchik <serg@mariadb.org> | 2018-05-19 10:07:21 +0200 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2018-05-21 16:34:11 +0000 |
commit | a1d57ca1abe1b5a681e58c199afdbcf47db5f5bb (patch) | |
tree | c3c984de419ac82e4fe277d3a97027d9900327c6 /mysys/my_init.c | |
parent | 5c81cb880a054f34803e2821489533274ebf6c4e (diff) | |
download | mariadb-git-a1d57ca1abe1b5a681e58c199afdbcf47db5f5bb.tar.gz |
bugfix: EE_OPEN_WARNING could be statistically wrong
don't rely on imprecise my_file_opened | my_stream_opened,
scan the array for open handles instead.
also, remove my_print_open_files() and embed it in my_end()
to have one array scan instead of two.
Diffstat (limited to 'mysys/my_init.c')
-rw-r--r-- | mysys/my_init.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/mysys/my_init.c b/mysys/my_init.c index aebcb3c1b8a..972750da0ff 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -158,17 +158,33 @@ void my_end(int infoflag) } if ((infoflag & MY_CHECK_ERROR) || print_info) + { /* Test if some file is left open */ + char ebuff[512]; + uint i, open_files, open_streams; - { /* Test if some file is left open */ - if (my_file_opened | my_stream_opened) + for (open_streams= open_files= i= 0 ; i < my_file_limit ; i++) + { + if (my_file_info[i].type == UNOPEN) + continue; + if (my_file_info[i].type == STREAM_BY_FOPEN || + my_file_info[i].type == STREAM_BY_FDOPEN) + open_streams++; + else + open_files++; + +#ifdef EXTRA_DEBUG + fprintf(stderr, EE(EE_FILE_NOT_CLOSED), my_file_info[i].name, i); + fputc('\n', stderr); +#endif + } + if (open_files || open_streams) { - char ebuff[512]; my_snprintf(ebuff, sizeof(ebuff), EE(EE_OPEN_WARNING), - my_file_opened, my_stream_opened); + open_files, open_streams); my_message_stderr(EE_OPEN_WARNING, ebuff, ME_BELL); DBUG_PRINT("error", ("%s", ebuff)); - my_print_open_files(); } + #ifdef CHECK_UNLIKELY end_my_likely(info_file); #endif |