parent
e5c48a4132
commit
5680a7fab8
2
make.sh
2
make.sh
|
|
@ -6,7 +6,7 @@ TARGET_SYSTEMD_PATH=$DESTDIR/usr/lib/systemd/system
|
||||||
|
|
||||||
WITH_LINUX_SERVICE=1
|
WITH_LINUX_SERVICE=1
|
||||||
|
|
||||||
DEBUG_FLAG=1
|
DEBUG_FLAG=0
|
||||||
|
|
||||||
export CC=gcc
|
export CC=gcc
|
||||||
CFLAGS='-Wall'
|
CFLAGS='-Wall'
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,9 @@ typedef struct file_id_info {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
FileIdInfo **buckets;
|
FileIdInfo **buckets;
|
||||||
uint32_t capacity;
|
uint32_t capacity;
|
||||||
|
#if defined(DEBUG_FLAG)
|
||||||
volatile uint32_t count;
|
volatile uint32_t count;
|
||||||
|
#endif
|
||||||
} FileIdHashtable;
|
} FileIdHashtable;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
@ -53,7 +55,7 @@ typedef struct {
|
||||||
} FileIdHTableContext;
|
} FileIdHTableContext;
|
||||||
|
|
||||||
static FileIdHTableContext file_id_ctx = {
|
static FileIdHTableContext file_id_ctx = {
|
||||||
{NULL, NULL}, {NULL, 0, 0}, {NULL, 0}
|
{NULL, NULL}, {NULL, 0}, {NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int clear_expired_file_id_func(void *args);
|
static int clear_expired_file_id_func(void *args);
|
||||||
|
|
@ -102,8 +104,8 @@ int file_id_hashtable_init()
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
FAST_ALLOCATOR_INIT_REGION(regions[0], 0, 48, 48, 8 * 1024);
|
FAST_ALLOCATOR_INIT_REGION(regions[0], 0, 48, 48, 16 * 1024);
|
||||||
FAST_ALLOCATOR_INIT_REGION(regions[1], 48, 128, 8, 8 * 1024);
|
FAST_ALLOCATOR_INIT_REGION(regions[1], 48, 128, 8, 8 * 1024);
|
||||||
if ((result=fast_allocator_init_ex(&file_id_ctx.acontext, "file-id",
|
if ((result=fast_allocator_init_ex(&file_id_ctx.acontext, "file-id",
|
||||||
obj_size, NULL, regions, 2, 0, 0.00, 0, true)) != 0)
|
obj_size, NULL, regions, 2, 0, 0.00, 0, true)) != 0)
|
||||||
{
|
{
|
||||||
|
|
@ -211,7 +213,10 @@ int file_id_hashtable_add(const string_t *file_id)
|
||||||
finfo->nexts.htable = current;
|
finfo->nexts.htable = current;
|
||||||
previous->nexts.htable = finfo;
|
previous->nexts.htable = finfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(DEBUG_FLAG)
|
||||||
FC_ATOMIC_INC(file_id_ctx.htable.count);
|
FC_ATOMIC_INC(file_id_ctx.htable.count);
|
||||||
|
#endif
|
||||||
|
|
||||||
} while (0);
|
} while (0);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -248,7 +253,9 @@ static int file_id_hashtable_del(FileIdInfo *finfo)
|
||||||
fc_string_equal(&finfo->file_id, &(*bucket)->file_id))
|
fc_string_equal(&finfo->file_id, &(*bucket)->file_id))
|
||||||
{
|
{
|
||||||
*bucket = (*bucket)->nexts.htable;
|
*bucket = (*bucket)->nexts.htable;
|
||||||
|
#if defined(DEBUG_FLAG)
|
||||||
FC_ATOMIC_DEC(file_id_ctx.htable.count);
|
FC_ATOMIC_DEC(file_id_ctx.htable.count);
|
||||||
|
#endif
|
||||||
result = 0;
|
result = 0;
|
||||||
} else {
|
} else {
|
||||||
result = ENOENT;
|
result = ENOENT;
|
||||||
|
|
@ -260,7 +267,9 @@ static int file_id_hashtable_del(FileIdInfo *finfo)
|
||||||
fc_string_equal(&finfo->file_id, ¤t->file_id))
|
fc_string_equal(&finfo->file_id, ¤t->file_id))
|
||||||
{
|
{
|
||||||
previous->nexts.htable = current->nexts.htable;
|
previous->nexts.htable = current->nexts.htable;
|
||||||
|
#if defined(DEBUG_FLAG)
|
||||||
FC_ATOMIC_DEC(file_id_ctx.htable.count);
|
FC_ATOMIC_DEC(file_id_ctx.htable.count);
|
||||||
|
#endif
|
||||||
result = 0;
|
result = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5299,7 +5299,7 @@ static int storage_upload_slave_file(struct fast_task_info *pTask)
|
||||||
store_path_index, filename);
|
store_path_index, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(pFileContext->filename, sizeof(pFileContext->filename), \
|
snprintf(pFileContext->filename, sizeof(pFileContext->filename),
|
||||||
"%s/data/%s", g_fdfs_store_paths.paths[store_path_index].path, filename);
|
"%s/data/%s", g_fdfs_store_paths.paths[store_path_index].path, filename);
|
||||||
if (fileExists(pFileContext->filename))
|
if (fileExists(pFileContext->filename))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue