Fix to bug #506, http://bugs.skysql.com/show_bug.cgi?id=506
If debug and/or trace log is stored to shared memory, the absolute path to file is now /dev/shm/<pid>/skygw_[trace1|debug1].log
This commit is contained in:
parent
fa47bf760a
commit
686d28a1f0
@ -75,7 +75,7 @@ int lm_enabled_logfiles_bitmask = 0;
|
||||
* Path to directory in which all files are stored to shared memory
|
||||
* by the OS.
|
||||
*/
|
||||
const char* shm_pathname = "/dev/shm";
|
||||
const char* shm_pathname_prefix = "/dev/shm/";
|
||||
|
||||
/** Logfile ids from call argument '-s' */
|
||||
char* shmem_id_str = NULL;
|
||||
@ -2064,7 +2064,31 @@ static bool logfile_init(
|
||||
* directory.
|
||||
*/
|
||||
if (store_shmem) {
|
||||
#if 1
|
||||
char* c;
|
||||
pid_t pid = getpid();
|
||||
int len = strlen(shm_pathname_prefix)+
|
||||
get_decimal_len((size_t)pid);
|
||||
|
||||
c = (char *)calloc(len, sizeof(char));
|
||||
|
||||
if (c == NULL)
|
||||
{
|
||||
succp = false;
|
||||
goto file_create_fail;
|
||||
}
|
||||
sprintf(c, "%s%d", shm_pathname_prefix, pid);
|
||||
logfile->lf_filepath = c;
|
||||
|
||||
if (mkdir(c, S_IRWXU | S_IRWXG) != 0 &&
|
||||
errno != EEXIST)
|
||||
{
|
||||
succp = false;
|
||||
goto file_create_fail;
|
||||
}
|
||||
#else
|
||||
logfile->lf_filepath = strdup(shm_pathname);
|
||||
#endif
|
||||
logfile->lf_linkpath = strdup(fn->fn_logpath);
|
||||
logfile->lf_linkpath = add_slash(logfile->lf_linkpath);
|
||||
} else {
|
||||
@ -2146,7 +2170,7 @@ static bool logfile_init(
|
||||
}
|
||||
}
|
||||
}
|
||||
file_create_fail:
|
||||
file_create_fail:
|
||||
if (namecreatefail || nameconflicts)
|
||||
{
|
||||
logfile->lf_name_seqno += 1;
|
||||
@ -2161,7 +2185,7 @@ static bool logfile_init(
|
||||
free(logfile->lf_full_link_name);
|
||||
logfile->lf_full_link_name = NULL;
|
||||
}
|
||||
|
||||
goto return_with_succp;
|
||||
}
|
||||
} while (namecreatefail || nameconflicts);
|
||||
/**
|
||||
|
@ -1955,7 +1955,19 @@ retblock:
|
||||
return newstr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calculate the number of decimal numbers from a size_t value.
|
||||
*
|
||||
* @param value value
|
||||
*
|
||||
* @return number of decimal numbers of which the value consists of
|
||||
* value==123 returns 3, for example.
|
||||
*/
|
||||
size_t get_decimal_len(
|
||||
size_t value)
|
||||
{
|
||||
return value > 0 ? (size_t) log10 ((double) value) + 1 : 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -192,6 +192,7 @@ int skygw_rwlock_unlock(skygw_rwlock_t* rwlock);
|
||||
int skygw_rwlock_init(skygw_rwlock_t** rwlock);
|
||||
|
||||
int atomic_add(int *variable, int value);
|
||||
size_t get_decimal_len(size_t s);
|
||||
|
||||
EXTERN_C_BLOCK_BEGIN
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user