diff options
author | monty@donna.mysql.com <> | 2000-09-12 03:02:33 +0300 |
---|---|---|
committer | monty@donna.mysql.com <> | 2000-09-12 03:02:33 +0300 |
commit | 2776500c220c92bb78df03513cc3dd33588f40e5 (patch) | |
tree | 051686baf31e5363765879f2437ada3abea6b71b /mysys/my_open.c | |
parent | 497007e2bd9cb127d54a4fdb02253301f404ce7f (diff) | |
download | mariadb-git-2776500c220c92bb78df03513cc3dd33588f40e5.tar.gz |
Update to new root alloc, OPTIMIZE TABLE and some other changes
Diffstat (limited to 'mysys/my_open.c')
-rw-r--r-- | mysys/my_open.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/mysys/my_open.c b/mysys/my_open.c index ef1db41e3f5..1f9d5cc3bae 100644 --- a/mysys/my_open.c +++ b/mysys/my_open.c @@ -48,12 +48,27 @@ File my_open(const char *FileName, int Flags, myf MyFlags) if ((int) fd >= 0) { if ((int) fd >= MY_NFILE) + { +#if defined(THREAD) && !defined(HAVE_PREAD) + (void) my_close(fd,MyFlags); + my_errno=EMFILE; + if (MyFlags & (MY_FFNF | MY_FAE | MY_WME)) + my_error(EE_OUT_OF_FILERESOURCES, MYF(ME_BELL+ME_WAITTANG), + FileName, my_errno); + DBUG_RETURN(-1); +#else + thread_safe_increment(my_file_opened,&THR_LOCK_open); +#endif DBUG_RETURN(fd); /* safeguard */ + } pthread_mutex_lock(&THR_LOCK_open); if ((my_file_info[fd].name = (char*) my_strdup(FileName,MyFlags))) { my_file_opened++; my_file_info[fd].type = FILE_BY_OPEN; +#if defined(THREAD) && !defined(HAVE_PREAD) + pthread_mutex_init(&my_file_info[fd].mutex,NULL); +#endif pthread_mutex_unlock(&THR_LOCK_open); DBUG_PRINT("exit",("fd: %d",fd)); DBUG_RETURN(fd); @@ -80,7 +95,7 @@ int my_close(File fd, myf MyFlags) DBUG_PRINT("my",("fd: %d MyFlags: %d",fd, MyFlags)); pthread_mutex_lock(&THR_LOCK_open); - if ((err = close(fd)) != 0) + if ((err = close(fd))) { my_errno=errno; if (MyFlags & (MY_FAE | MY_WME)) @@ -88,9 +103,12 @@ int my_close(File fd, myf MyFlags) } if ((uint) fd < MY_NFILE && my_file_info[fd].type != UNOPEN) { - my_file_opened--; my_free(my_file_info[fd].name, MYF(0)); +#if defined(THREAD) && !defined(HAVE_PREAD) + pthread_mutex_destroy(&my_file_info[fd].mutex); +#endif my_file_info[fd].type = UNOPEN; + my_file_opened--; } pthread_mutex_unlock(&THR_LOCK_open); DBUG_RETURN(err); |