}
}
- g_tree_foreach (input, classify_callback, &data);
+ if (data.file != NULL) {
+ statfile_pool_lock_file (pool, data.file);
+ g_tree_foreach (input, classify_callback, &data);
+ statfile_pool_unlock_file (pool, data.file);
+ }
if (data.count != 0) {
*res = (data.sum / data.count);
case STATE_COMMAND:
s = fstrcstr (in, session->session_pool);
params = g_strsplit (s, " ", -1);
+
+ memory_pool_add_destructor (session->session_pool, (pool_destruct_func)g_strfreev, params);
+
len = g_strv_length (params);
if (len > 0) {
cmd = g_strstrip (params[0]);
}
}
- g_strfreev (params);
break;
case STATE_LEARN:
session->learn_buf = in;
}
- /* XXX: this is temporary copy of name to avoid strdup early */
- new_file->filename = filename;
+ g_strlcpy (new_file->filename, filename, sizeof (new_file->filename));
new_file->len = st.st_size;
if (statfile_pool_check (new_file) == -1) {
pool->opened --;
}
pool->occupied += st.st_size;
- new_file->filename = memory_pool_strdup (pool->pool, filename);
new_file->open_time = time (NULL);
new_file->access_time = new_file->open_time;
new_file->lock = memory_pool_get_mutex (pool->pool);
statfile_pool_is_open (statfile_pool_t *pool, char *filename)
{
static stat_file_t f, *ret;
- f.filename = filename;
+ g_strlcpy (f.filename, filename, sizeof (f.filename));
ret = bsearch (&f, pool->files, pool->opened, sizeof (stat_file_t), cmpstatfile);
return ret;
}
* Section header
*/
struct stat_file_section {
- uint32_t code; /**< section's code */
+ uint64_t code; /**< section's code */
uint64_t length; /**< section's length in blocks */
};
struct stat_file_block {
uint32_t hash1; /**< hash1 (also acts as index) */
uint32_t hash2; /**< hash2 */
- float value; /**< float value */
uint32_t last_access; /**< last access to block since create time of file */
+ float value; /**< float value */
};
/**
* Common view of statfile object
*/
typedef struct stat_file_s {
- char *filename; /**< name of file */
+#ifdef HAVE_PATH_MAX
+ char filename[PATH_MAX]; /**< name of file */
+#else
+ char filename[MAXPATHLEN]; /**< name of file */
+#endif
int fd; /**< descriptor */
void *map; /**< mmaped area */
off_t seek_pos; /**< current seek position */