summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
Diffstat (limited to 'mysys')
-rw-r--r--mysys/default.c19
-rw-r--r--mysys/my_copy.c30
-rw-r--r--mysys/my_getopt.c4
-rw-r--r--mysys/my_lib.c2
-rw-r--r--mysys/my_tempnam.c10
-rw-r--r--mysys/thr_lock.c48
6 files changed, 98 insertions, 15 deletions
diff --git a/mysys/default.c b/mysys/default.c
index 0ae409f1015..83dd177f6b4 100644
--- a/mysys/default.c
+++ b/mysys/default.c
@@ -38,6 +38,7 @@
#include "mysys_priv.h"
#include "m_string.h"
#include "m_ctype.h"
+#include <my_dir.h>
char *defaults_extra_file=0;
@@ -61,13 +62,13 @@ DATADIR,
NullS,
};
-#define default_ext ".cnf" /* extension for config file */
+#define default_ext ".cnf" /* extension for config file */
#ifdef __WIN__
#include <winbase.h>
#define windows_ext ".ini"
#endif
-static my_bool search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc,
+static my_bool search_default_file(DYNAMIC_ARRAY *args,MEM_ROOT *alloc,
const char *dir, const char *config_file,
const char *ext, TYPELIB *group);
@@ -242,6 +243,20 @@ static my_bool search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc,
{
strmov(name,config_file);
}
+ fn_format(name,name,"","",4);
+#if !defined(__WIN__) && !defined(OS2)
+ {
+ MY_STAT stat_info;
+ if (!my_stat(name,&stat_info,MYF(0)))
+ return 0;
+ if (stat_info.st_mode & S_IWOTH) /* ignore world-writeable files */
+ {
+ fprintf(stderr, "warning: World-writeable config file %s is ignored\n",
+ name);
+ return 0;
+ }
+ }
+#endif
if (!(fp = my_fopen(fn_format(name,name,"","",4),O_RDONLY,MYF(0))))
return 0; /* Ignore wrong files */
diff --git a/mysys/my_copy.c b/mysys/my_copy.c
index 012eaec4ea8..84eda781a09 100644
--- a/mysys/my_copy.c
+++ b/mysys/my_copy.c
@@ -31,17 +31,29 @@ struct utimbuf {
#endif
- /*
- Ordinary ownership and accesstimes are copied from 'from-file'
- if MyFlags & MY_HOLD_ORIGINAL_MODES is set and to-file exists then
- the modes of to-file isn't changed
- Dont set MY_FNABP or MY_NABP bits on when calling this function !
- */
+/*
+ int my_copy(const char *from, const char *to, myf MyFlags)
+
+ NOTES
+ Ordinary ownership and accesstimes are copied from 'from-file'
+ If MyFlags & MY_HOLD_ORIGINAL_MODES is set and to-file exists then
+ the modes of to-file isn't changed
+ If MyFlags & MY_DONT_OVERWRITE_FILE is set, we will give an error
+ if the file existed.
+
+ WARNING
+ Don't set MY_FNABP or MY_NABP bits on when calling this function !
+
+ RETURN
+ 0 ok
+ # Error
+
+*/
int my_copy(const char *from, const char *to, myf MyFlags)
{
uint Count;
- int new_file_stat;
+ int new_file_stat, create_flag;
File from_file,to_file;
char buff[IO_SIZE];
struct stat stat_buff,new_stat_buff;
@@ -62,8 +74,10 @@ int my_copy(const char *from, const char *to, myf MyFlags)
}
if (MyFlags & MY_HOLD_ORIGINAL_MODES && !new_file_stat)
stat_buff=new_stat_buff;
+ create_flag= (MyFlags & MY_DONT_OVERWRITE_FILE) ? O_EXCL : O_TRUNC;
+
if ((to_file= my_create(to,(int) stat_buff.st_mode,
- O_WRONLY | O_TRUNC | O_BINARY | O_SHARE,
+ O_WRONLY | create_flag | O_BINARY | O_SHARE,
MyFlags)) < 0)
goto err;
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index c6fe606eaaf..759c96462f6 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -431,8 +431,8 @@ int handle_options(int *argc, char ***argv,
Will set the option value to given value
*/
-static int setval (const struct my_option *opts, char *argument,
- my_bool set_maximum_value)
+static int setval(const struct my_option *opts, char *argument,
+ my_bool set_maximum_value)
{
int err= 0;
diff --git a/mysys/my_lib.c b/mysys/my_lib.c
index a06120894c5..035bafd07b9 100644
--- a/mysys/my_lib.c
+++ b/mysys/my_lib.c
@@ -103,7 +103,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags)
char dirent_tmp[sizeof(struct dirent)+_POSIX_PATH_MAX+1];
#endif
DBUG_ENTER("my_dir");
- DBUG_PRINT("my",("path: '%s' stat: %d MyFlags: %d",path,MyFlags));
+ DBUG_PRINT("my",("path: '%s' MyFlags: %d",path,MyFlags));
#if defined(THREAD) && !defined(HAVE_READDIR_R)
pthread_mutex_lock(&THR_LOCK_open);
diff --git a/mysys/my_tempnam.c b/mysys/my_tempnam.c
index a652fae3574..d079b9f66a5 100644
--- a/mysys/my_tempnam.c
+++ b/mysys/my_tempnam.c
@@ -115,13 +115,19 @@ my_string my_tempnam(const char *dir, const char *pfx,
old_env=(char**)environ;
if (dir)
{ /* Don't use TMPDIR if dir is given */
- ((char**) environ)=(char**) temp_env;
+ /*
+ The following strange cast is required because the IBM compiler on AIX
+ doesn't allow us to cast the value of environ.
+ The cast of environ is needed as some systems doesn't allow us to
+ update environ with a char ** pointer. (const mismatch)
+ */
+ (*(char***) &environ)=(char**) temp_env;
temp_env[0]=0;
}
#endif
res=tempnam((char*) dir,(my_string) pfx); /* Use stand. dir with prefix */
#if !defined(OS2) && !defined(__NETWARE__)
- ((char**) environ)=(char**) old_env;
+ (*(char***) &environ)=(char**) old_env;
#endif
if (!res)
DBUG_PRINT("error",("Got error: %d from tempnam",errno));
diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c
index c796bd1956a..b6e7cb47234 100644
--- a/mysys/thr_lock.c
+++ b/mysys/thr_lock.c
@@ -945,6 +945,54 @@ void thr_abort_locks(THR_LOCK *lock)
}
+/*
+ Abort all locks for specific table/thread combination
+
+ This is used to abort all locks for a specific thread
+*/
+
+void thr_abort_locks_for_thread(THR_LOCK *lock, pthread_t thread)
+{
+ THR_LOCK_DATA *data;
+ DBUG_ENTER("thr_abort_locks_for_thread");
+
+ pthread_mutex_lock(&lock->mutex);
+ for (data= lock->read_wait.data; data ; data= data->next)
+ {
+ if (pthread_equal(thread, data->thread))
+ {
+ DBUG_PRINT("info",("Aborting read-wait lock"));
+ data->type= TL_UNLOCK; /* Mark killed */
+ pthread_cond_signal(data->cond);
+ data->cond= 0; /* Removed from list */
+
+ if (((*data->prev)= data->next))
+ data->next->prev= data->prev;
+ else
+ lock->read_wait.last= data->prev;
+ }
+ }
+ for (data= lock->write_wait.data; data ; data= data->next)
+ {
+ if (pthread_equal(thread, data->thread))
+ {
+ DBUG_PRINT("info",("Aborting write-wait lock"));
+ data->type= TL_UNLOCK;
+ pthread_cond_signal(data->cond);
+ data->cond= 0;
+
+ if (((*data->prev)= data->next))
+ data->next->prev= data->prev;
+ else
+ lock->write_wait.last= data->prev;
+ }
+ }
+ pthread_mutex_unlock(&lock->mutex);
+ DBUG_VOID_RETURN;
+}
+
+
+
/* Upgrade a WRITE_DELAY lock to a WRITE_LOCK */
my_bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data)