log_manager.cc

renamed file_exists to file_exists_and_is_writable, added missing file open flags.

gateway.c	
	Removed command-line parameter '-m' because setting LD_LIBRARY_PATH after the program has started has no effect.
	Corrected some comments.
This commit is contained in:
vraatikka 2013-11-26 16:52:48 +02:00
parent 973a9a34d7
commit 4057ae0b0f
2 changed files with 24 additions and 10 deletions

View File

@ -258,7 +258,7 @@ static void blockbuf_register(blockbuf_t* bb);
static void blockbuf_unregister(blockbuf_t* bb);
static bool logfile_set_enabled(logfile_id_t id, bool val);
static char* add_slash(char* str);
static bool file_exists(char* filename);
static bool file_exists_and_is_writable(char* filename);
static bool file_is_symlink(char* filename);
@ -1800,9 +1800,11 @@ static char* add_slash(
*
*
* @details Note, that an space character is written to the end of file.
* TODO: recall what was the reason for not succeeding with simply
* calling access, and fstat. vraa 26.11.13
*
*/
static bool file_exists(
static bool file_exists_and_is_writable(
char* filename,
bool* writable)
{
@ -1815,7 +1817,7 @@ static bool file_exists(
}
else
{
fd = open(filename, O_CREAT|O_EXCL);
fd = open(filename, O_CREAT|O_EXCL, S_IRWXU);
/** file exist */
if (fd == -1)
@ -1979,7 +1981,8 @@ static bool logfile_init(
* If file exists but is different type, create fails and
* new, increased sequence number is added to file name.
*/
if (file_exists(logfile->lf_full_file_name, &writable))
if (file_exists_and_is_writable(logfile->lf_full_file_name,
&writable))
{
if (!writable ||
file_is_symlink(logfile->lf_full_file_name))
@ -1993,7 +1996,9 @@ static bool logfile_init(
{
writable = false;
if (file_exists(logfile->lf_full_link_name, &writable))
if (file_exists_and_is_writable(
logfile->lf_full_link_name,
&writable))
{
if (!writable ||
!file_is_symlink(logfile->lf_full_link_name))

View File

@ -514,8 +514,11 @@ int main(int argc, char **argv)
goto return_main;
}
}
#if 0
while ((opt = getopt(argc, argv, "dc:m:")) != -1)
#else
while ((opt = getopt(argc, argv, "dc:")) != -1)
#endif
{
bool succp = true;
@ -555,7 +558,7 @@ int main(int argc, char **argv)
print_log_n_stderr(true, true, logerr, logerr, 0);
}
break;
#if 0
case 'm':
{
char* ldlib_env = getenv("LD_LIBRARY_PATH");
@ -611,11 +614,17 @@ int main(int argc, char **argv)
free(abs_path);
}
break;
#endif
default:
#if 0
fprintf(stderr,
"*\n* Usage : maxscale [-d] [-c <home "
"directory>] [-m <modules directory>]\n*\n");
#else
fprintf(stderr,
"*\n* Usage : maxscale [-d] [-c <home "
"directory>]\n*\n");
#endif
succp = false;
break;
}
@ -780,7 +789,7 @@ int main(int argc, char **argv)
}
/**
* 2. if home dir wasn't specified in MAXSCALE_HOME,
* try access /etc/MaxScale.cnf.
* try access /etc/MaxScale/MaxScale.cnf.
*/
if (home_dir == NULL)
{
@ -788,7 +797,7 @@ int main(int argc, char **argv)
cnf_file = get_config_filename(&home_dir, tmp);
}
/**
* 3. if /etc/MaxScale.cnf didn't exist or wasn't accessible, home
* 3. if /etc/MaxScale/MaxScale.cnf didn't exist or wasn't accessible, home
* isn't specified. Thus, try to access $PWD/MaxScale.cnf .
*/
if (home_dir == NULL)