| 118 | */ |
| 119 | |
| 120 | int my_close(File fd, myf MyFlags) |
| 121 | { |
| 122 | int err; |
| 123 | DBUG_ENTER("my_close"); |
| 124 | DBUG_PRINT("my",("fd: %d MyFlags: %d",fd, MyFlags)); |
| 125 | |
| 126 | mysql_mutex_lock(&THR_LOCK_open); |
| 127 | #ifndef _WIN32 |
| 128 | do |
| 129 | { |
| 130 | err= close(fd); |
| 131 | } while (err == -1 && errno == EINTR); |
| 132 | #else |
| 133 | err= my_win_close(fd); |
| 134 | #endif |
| 135 | if (err) |
| 136 | { |
| 137 | DBUG_PRINT("error",("Got error %d on close",err)); |
| 138 | my_errno=errno; |
| 139 | if (MyFlags & (MY_FAE | MY_WME)) |
| 140 | { |
| 141 | char errbuf[MYSYS_STRERROR_SIZE]; |
| 142 | my_error(EE_BADCLOSE, MYF(ME_BELL+ME_WAITTANG), my_filename(fd), |
| 143 | my_errno, my_strerror(errbuf, sizeof(errbuf), my_errno)); |
| 144 | } |
| 145 | } |
| 146 | if ((uint) fd < my_file_limit && my_file_info[fd].type != UNOPEN) |
| 147 | { |
| 148 | my_free(my_file_info[fd].name); |
| 149 | #if !defined(HAVE_PREAD) && !defined(_WIN32) |
| 150 | mysql_mutex_destroy(&my_file_info[fd].mutex); |
| 151 | #endif |
| 152 | my_file_info[fd].type = UNOPEN; |
| 153 | } |
| 154 | my_file_opened--; |
| 155 | mysql_mutex_unlock(&THR_LOCK_open); |
| 156 | DBUG_RETURN(err); |
| 157 | } /* my_close */ |
| 158 | |
| 159 | |
| 160 | /* |
no test coverage detected