|-----tracker_mem_init
|-----init_pthread_lock(mem_thread_lock)
|-----init_pthread_lock(mem_file_lock)
|-----tracker_open_changlog_file
|-----tracker_mem_init_groups
|------
tracker_load_data
|-----tracker_load_groups_new
|-----tracker_load_storage_new
|-----tracker_malloc_all_group_path_mbs
|-----tracker_load_sync_timestamps
-
//从配置文件中加载group与storage的信息
-
static int tracker_load_data(FDFSGroups *pGroups)
-
{
-
char data_path[MAX_PATH_SIZE];
-
int result;
-
-
// base_path/data
-
snprintf(data_path, sizeof(data_path), "%s/data", g_fdfs_base_path);
-
if (!fileExists(data_path))//判断data目录是否存在
-
{
-
if (mkdir(data_path, 0755) != 0) //不存在,创建data目录
-
{
-
logError("file: "__FILE__", line: %d, " \
-
"mkdir \"%s\" fail, " \
-
"errno: %d, error info: %s", \
-
__LINE__, data_path, errno, STRERROR(errno));
-
return errno != 0 ? errno : ENOENT;
-
}
-
-
TRACKER_CHOWN(data_path, geteuid(), getegid())//修改data目录的属性,使目录的uid与gid为程序的执行的有效用户
-
}
-
-
if (chdir(data_path) != 0)//进入data目录
-
{
-
logError("file: "__FILE__", line: %d, " \
-
"chdir \"%s\" fail, " \
-
"errno: %d, error info: %s", \
-
__LINE__, data_path, errno, STRERROR(errno));
-
return errno != 0 ? errno : ENOENT;
-
}
-
-
if (!fileExists(STORAGE_GROUPS_LIST_FILENAME_OLD) && \
-
!fileExists(STORAGE_GROUPS_LIST_FILENAME_NEW))//判断storge_groups.dat与storge_groups_new.dat是否存在
-
{//若都不存在,则直接返回
-
return 0;
-
}
-
-
//从storage_groups_new.dat文件中获取group数据
-
if ((result=tracker_load_groups_new(pGroups, data_path)) != 0)
-
{
-
return result;
-
}
-
-
//从storage_servers_new.dat文件中获取server数据
-
if ((result=tracker_load_storages_new(pGroups, data_path)) != 0)
-
{
-
return result;
-
}
-
//为所有group中的store_path分配空间
-
if ((result=tracker_malloc_all_group_path_mbs(pGroups)) != 0)
-
{
-
return result;
-
}
-
//加载同步时间戳
-
if ((result=tracker_load_sync_timestamps(pGroups, data_path)) != 0)
-
{
-
return result;
-
}
-
-
return 0;
-
}
tracker_load_data函数中主要执行了四个函数,在下面的文章中,将依次对每个函数进行详细分析
阅读(664) | 评论(0) | 转发(0) |