Close a stream */
| 232 | |
| 233 | /* Close a stream */ |
| 234 | int my_fclose(FILE *fd, myf MyFlags) |
| 235 | { |
| 236 | int err,file; |
| 237 | DBUG_ENTER("my_fclose"); |
| 238 | DBUG_PRINT("my",("stream: 0x%lx MyFlags: %d", (long) fd, MyFlags)); |
| 239 | |
| 240 | mysql_mutex_lock(&THR_LOCK_open); |
| 241 | file= my_fileno(fd); |
| 242 | #ifndef _WIN32 |
| 243 | err= fclose(fd); |
| 244 | #else |
| 245 | err= my_win_fclose(fd); |
| 246 | #endif |
| 247 | if(err < 0) |
| 248 | { |
| 249 | my_errno=errno; |
| 250 | if (MyFlags & (MY_FAE | MY_WME)) |
| 251 | { |
| 252 | char errbuf[MYSYS_STRERROR_SIZE]; |
| 253 | my_error(EE_BADCLOSE, MYF(ME_BELL+ME_WAITTANG), my_filename(file), |
| 254 | my_errno, my_strerror(errbuf, sizeof(errbuf), my_errno)); |
| 255 | } |
| 256 | } |
| 257 | else |
| 258 | my_stream_opened--; |
| 259 | if ((uint) file < my_file_limit && my_file_info[file].type != UNOPEN) |
| 260 | { |
| 261 | my_file_info[file].type = UNOPEN; |
| 262 | my_free(my_file_info[file].name); |
| 263 | } |
| 264 | mysql_mutex_unlock(&THR_LOCK_open); |
| 265 | DBUG_RETURN(err); |
| 266 | } /* my_fclose */ |
| 267 | |
| 268 | |
| 269 | /* Make a stream out of a file handle */ |
no test coverage detected