summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2003-12-11 06:24:32 +0200
committerunknown <monty@mysql.com>2003-12-11 06:24:32 +0200
commit28b1f63aa7f6ed40d68c932cfe33420c12c7347d (patch)
tree35f5e63ae1da09573a4496dfd0ced99b9d70ae97 /mysys
parent7cfbc5e9336099d4b850e6a7e8282ade3e7aef19 (diff)
parent287661e66cc1fea6730b357bb56d48c6d065ef43 (diff)
downloadmariadb-git-28b1f63aa7f6ed40d68c932cfe33420c12c7347d.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-4.0
into mysql.com:/my/mysql-4.0 mysys/my_thr_init.c: Auto merged
Diffstat (limited to 'mysys')
-rw-r--r--mysys/mf_pack.c27
-rw-r--r--mysys/my_init.c20
-rw-r--r--mysys/my_lib.c6
-rw-r--r--mysys/my_thr_init.c26
4 files changed, 53 insertions, 26 deletions
diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c
index b3aa347006e..e2e811fe89a 100644
--- a/mysys/mf_pack.c
+++ b/mysys/mf_pack.c
@@ -210,13 +210,13 @@ uint cleanup_dirname(register my_string to, const char *from)
} /* cleanup_dirname */
- /*
- On system where you don't have symbolic links, the following
- code will allow you to create a file:
- directory-name.lnk that should contain the real path
- to the directory. This will be used if the directory name
- doesn't exists
- */
+/*
+ On system where you don't have symbolic links, the following
+ code will allow you to create a file:
+ directory-name.sym that should contain the real path
+ to the directory. This will be used if the directory name
+ doesn't exists
+*/
my_bool my_use_symdir=0; /* Set this if you want to use symdirs */
@@ -228,16 +228,17 @@ void symdirget(char *dir)
char *pos=strend(dir);
if (dir[0] && pos[-1] != FN_DEVCHAR && access(dir, F_OK))
{
- FILE *fp;
+ File file;
+ uint length;
char temp= *(--pos); /* May be "/" or "\" */
strmov(pos,".sym");
- fp = my_fopen(dir, O_RDONLY,MYF(0));
+ file= my_open(dir, O_RDONLY, MYF(0));
*pos++=temp; *pos=0; /* Restore old filename */
- if (fp)
+ if (file >= 0)
{
- if (fgets(buff, sizeof(buff)-1, fp))
+ if ((length= my_read(file, buff, sizeof(buff), MYF(0))) > 0)
{
- for (pos=strend(buff);
+ for (pos= buff + length ;
pos > buff && (iscntrl(pos[-1]) || isspace(pos[-1])) ;
pos --);
@@ -247,7 +248,7 @@ void symdirget(char *dir)
strmake(dir,buff, (uint) (pos-buff));
}
- my_fclose(fp,MYF(0));
+ my_close(file, MYF(0));
}
}
}
diff --git a/mysys/my_init.c b/mysys/my_init.c
index a8a184a2cb4..8d4ba2c97b6 100644
--- a/mysys/my_init.c
+++ b/mysys/my_init.c
@@ -62,13 +62,22 @@ static ulong atoi_octal(const char *str)
}
- /* Init my_sys functions and my_sys variabels */
+/*
+ Init my_sys functions and my_sys variabels
+
+ SYNOPSIS
+ my_init()
-void my_init(void)
+ RETURN
+ 0 ok
+ 1 Couldn't initialize environment
+*/
+
+my_bool my_init(void)
{
my_string str;
if (my_init_done)
- return;
+ return 0;
my_init_done=1;
#if defined(THREAD) && defined(SAFE_MUTEX)
safe_mutex_global_init(); /* Must be called early */
@@ -78,7 +87,8 @@ void my_init(void)
#if defined(HAVE_PTHREAD_INIT)
pthread_init(); /* Must be called before DBUG_ENTER */
#endif
- my_thread_global_init();
+ if (my_thread_global_init())
+ return 1;
#if !defined( __WIN__) && !defined(OS2) && !defined(__NETWARE__)
sigfillset(&my_signals); /* signals blocked by mf_brkhant */
#endif
@@ -110,7 +120,7 @@ void my_init(void)
#ifdef __WIN__
win32_init_tcp_ip();
#endif
- DBUG_VOID_RETURN;
+ DBUG_RETURN(0);
}
} /* my_init */
diff --git a/mysys/my_lib.c b/mysys/my_lib.c
index 035bafd07b9..426acedc646 100644
--- a/mysys/my_lib.c
+++ b/mysys/my_lib.c
@@ -602,9 +602,11 @@ MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags)
if ((m_used= (stat_area == NULL)))
if (!(stat_area = (MY_STAT *) my_malloc(sizeof(MY_STAT), my_flags)))
goto error;
- if ( ! stat((my_string) path, (struct stat *) stat_area) )
+ if (! stat((my_string) path, (struct stat *) stat_area) )
DBUG_RETURN(stat_area);
- my_errno=errno;
+
+ DBUG_PRINT("error",("Got errno: %d from stat", errno));
+ my_errno= errno;
if (m_used) /* Free if new area */
my_free((gptr) stat_area,MYF(0));
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c
index 3196256facc..57eecd7b746 100644
--- a/mysys/my_thr_init.c
+++ b/mysys/my_thr_init.c
@@ -44,12 +44,23 @@ pthread_mutexattr_t my_fast_mutexattr;
pthread_mutexattr_t my_errchk_mutexattr;
#endif
+/*
+ initialize thread environment
+
+ SYNOPSIS
+ my_thread_global_init()
+
+ RETURN
+ 0 ok
+ 1 error (Couldn't create THR_KEY_mysys)
+*/
+
my_bool my_thread_global_init(void)
{
- if (pthread_key_create(&THR_KEY_mysys,free))
+ if (pthread_key_create(&THR_KEY_mysys,0))
{
fprintf(stderr,"Can't initialize threads: error %d\n",errno);
- exit(1);
+ return 1;
}
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
pthread_mutexattr_init(&my_fast_mutexattr);
@@ -79,15 +90,18 @@ my_bool my_thread_global_init(void)
#ifndef HAVE_GETHOSTBYNAME_R
pthread_mutex_init(&LOCK_gethostbyname_r,MY_MUTEX_INIT_SLOW);
#endif
- return my_thread_init();
+ if (my_thread_init())
+ {
+ my_thread_global_end(); /* Clean up */
+ return 1;
+ }
+ return 0;
}
void my_thread_global_end(void)
{
-#if defined(USE_TLS)
- (void) TlsFree(THR_KEY_mysys);
-#endif
+ pthread_key_delete(THR_KEY_mysys);
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
pthread_mutexattr_destroy(&my_fast_mutexattr);
#endif