@ -75,7 +75,7 @@ int lm_enabled_logfiles_bitmask = 0;
|
|||||||
* Path to directory in which all files are stored to shared memory
|
* Path to directory in which all files are stored to shared memory
|
||||||
* by the OS.
|
* by the OS.
|
||||||
*/
|
*/
|
||||||
const char* shm_pathname = "/dev/shm";
|
const char* shm_pathname_prefix = "/dev/shm/";
|
||||||
|
|
||||||
/** Logfile ids from call argument '-s' */
|
/** Logfile ids from call argument '-s' */
|
||||||
char* shmem_id_str = NULL;
|
char* shmem_id_str = NULL;
|
||||||
@ -2063,11 +2063,34 @@ static bool logfile_init(
|
|||||||
* pointing to shm file is created and located to the file
|
* pointing to shm file is created and located to the file
|
||||||
* directory.
|
* directory.
|
||||||
*/
|
*/
|
||||||
if (store_shmem) {
|
if (store_shmem)
|
||||||
logfile->lf_filepath = strdup(shm_pathname);
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
logfile->lf_linkpath = strdup(fn->fn_logpath);
|
logfile->lf_linkpath = strdup(fn->fn_logpath);
|
||||||
logfile->lf_linkpath = add_slash(logfile->lf_linkpath);
|
logfile->lf_linkpath = add_slash(logfile->lf_linkpath);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
logfile->lf_filepath = strdup(fn->fn_logpath);
|
logfile->lf_filepath = strdup(fn->fn_logpath);
|
||||||
}
|
}
|
||||||
logfile->lf_filepath = add_slash(logfile->lf_filepath);
|
logfile->lf_filepath = add_slash(logfile->lf_filepath);
|
||||||
@ -2146,7 +2169,7 @@ static bool logfile_init(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_create_fail:
|
file_create_fail:
|
||||||
if (namecreatefail || nameconflicts)
|
if (namecreatefail || nameconflicts)
|
||||||
{
|
{
|
||||||
logfile->lf_name_seqno += 1;
|
logfile->lf_name_seqno += 1;
|
||||||
@ -2161,7 +2184,7 @@ static bool logfile_init(
|
|||||||
free(logfile->lf_full_link_name);
|
free(logfile->lf_full_link_name);
|
||||||
logfile->lf_full_link_name = NULL;
|
logfile->lf_full_link_name = NULL;
|
||||||
}
|
}
|
||||||
|
goto return_with_succp;
|
||||||
}
|
}
|
||||||
} while (namecreatefail || nameconflicts);
|
} while (namecreatefail || nameconflicts);
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1955,7 +1955,19 @@ retblock:
|
|||||||
return newstr;
|
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 skygw_rwlock_init(skygw_rwlock_t** rwlock);
|
||||||
|
|
||||||
int atomic_add(int *variable, int value);
|
int atomic_add(int *variable, int value);
|
||||||
|
size_t get_decimal_len(size_t s);
|
||||||
|
|
||||||
EXTERN_C_BLOCK_BEGIN
|
EXTERN_C_BLOCK_BEGIN
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user