call sf_load_config_ex instead of sf_load_config
parent
8f538108ce
commit
bf3bfa68f6
|
|
@ -49,6 +49,7 @@ CLIENT_SHARED_LIBS = libfdfsclient.so
|
||||||
ALL_LIBS = $(STATIC_LIBS) $(SHARED_LIBS)
|
ALL_LIBS = $(STATIC_LIBS) $(SHARED_LIBS)
|
||||||
|
|
||||||
all: $(ALL_OBJS) $(ALL_PRGS) $(ALL_LIBS)
|
all: $(ALL_OBJS) $(ALL_PRGS) $(ALL_LIBS)
|
||||||
|
|
||||||
libfdfsclient.so:
|
libfdfsclient.so:
|
||||||
$(COMPILE) -o $@ $< -shared $(FDFS_SHARED_OBJS) $(LIB_PATH)
|
$(COMPILE) -o $@ $< -shared $(FDFS_SHARED_OBJS) $(LIB_PATH)
|
||||||
libfdfsclient.a:
|
libfdfsclient.a:
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,9 @@ ALL_OBJS = $(SHARED_OBJS)
|
||||||
ALL_PRGS = fdfs_storaged
|
ALL_PRGS = fdfs_storaged
|
||||||
|
|
||||||
all: $(ALL_OBJS) $(ALL_PRGS)
|
all: $(ALL_OBJS) $(ALL_PRGS)
|
||||||
|
|
||||||
|
$(ALL_PRGS): $(ALL_OBJS)
|
||||||
|
|
||||||
.o:
|
.o:
|
||||||
$(COMPILE) -o $@ $< $(SHARED_OBJS) $(LIB_PATH) $(INC_PATH)
|
$(COMPILE) -o $@ $< $(SHARED_OBJS) $(LIB_PATH) $(INC_PATH)
|
||||||
.c:
|
.c:
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,9 @@ ALL_OBJS = $(SHARED_OBJS)
|
||||||
ALL_PRGS = fdfs_trackerd
|
ALL_PRGS = fdfs_trackerd
|
||||||
|
|
||||||
all: $(ALL_OBJS) $(ALL_PRGS)
|
all: $(ALL_OBJS) $(ALL_PRGS)
|
||||||
|
|
||||||
|
$(ALL_PRGS): $(ALL_OBJS)
|
||||||
|
|
||||||
.o:
|
.o:
|
||||||
$(COMPILE) -o $@ $< $(SHARED_OBJS) $(LIB_PATH) $(INC_PATH)
|
$(COMPILE) -o $@ $< $(SHARED_OBJS) $(LIB_PATH) $(INC_PATH)
|
||||||
.c:
|
.c:
|
||||||
|
|
|
||||||
|
|
@ -58,19 +58,74 @@ static void sigUsrHandler(int sig);
|
||||||
static void sigAlarmHandler(int sig);
|
static void sigAlarmHandler(int sig);
|
||||||
|
|
||||||
#if defined(DEBUG_FLAG)
|
#if defined(DEBUG_FLAG)
|
||||||
/*
|
|
||||||
#if defined(OS_LINUX)
|
|
||||||
static void sigSegvHandler(int signum, siginfo_t *info, void *ptr);
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void sigDumpHandler(int sig);
|
static void sigDumpHandler(int sig);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SCHEDULE_ENTRIES_COUNT 5
|
static int setup_signal_handlers()
|
||||||
|
{
|
||||||
|
struct sigaction act;
|
||||||
|
|
||||||
|
memset(&act, 0, sizeof(act));
|
||||||
|
sigemptyset(&act.sa_mask);
|
||||||
|
act.sa_handler = sigUsrHandler;
|
||||||
|
if(sigaction(SIGUSR1, &act, NULL) < 0 || \
|
||||||
|
sigaction(SIGUSR2, &act, NULL) < 0)
|
||||||
|
{
|
||||||
|
logCrit("file: "__FILE__", line: %d, " \
|
||||||
|
"call sigaction fail, errno: %d, error info: %s", \
|
||||||
|
__LINE__, errno, STRERROR(errno));
|
||||||
|
return errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
act.sa_handler = sigHupHandler;
|
||||||
|
if(sigaction(SIGHUP, &act, NULL) < 0)
|
||||||
|
{
|
||||||
|
logCrit("file: "__FILE__", line: %d, " \
|
||||||
|
"call sigaction fail, errno: %d, error info: %s", \
|
||||||
|
__LINE__, errno, STRERROR(errno));
|
||||||
|
return errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
act.sa_handler = SIG_IGN;
|
||||||
|
if(sigaction(SIGPIPE, &act, NULL) < 0)
|
||||||
|
{
|
||||||
|
logCrit("file: "__FILE__", line: %d, " \
|
||||||
|
"call sigaction fail, errno: %d, error info: %s", \
|
||||||
|
__LINE__, errno, STRERROR(errno));
|
||||||
|
return errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
act.sa_handler = sigQuitHandler;
|
||||||
|
if(sigaction(SIGINT, &act, NULL) < 0 || \
|
||||||
|
sigaction(SIGTERM, &act, NULL) < 0 || \
|
||||||
|
sigaction(SIGQUIT, &act, NULL) < 0)
|
||||||
|
{
|
||||||
|
logCrit("file: "__FILE__", line: %d, " \
|
||||||
|
"call sigaction fail, errno: %d, error info: %s", \
|
||||||
|
__LINE__, errno, STRERROR(errno));
|
||||||
|
return errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(DEBUG_FLAG)
|
||||||
|
memset(&act, 0, sizeof(act));
|
||||||
|
sigemptyset(&act.sa_mask);
|
||||||
|
act.sa_handler = sigDumpHandler;
|
||||||
|
if(sigaction(SIGUSR1, &act, NULL) < 0 || \
|
||||||
|
sigaction(SIGUSR2, &act, NULL) < 0)
|
||||||
|
{
|
||||||
|
logCrit("file: "__FILE__", line: %d, " \
|
||||||
|
"call sigaction fail, errno: %d, error info: %s", \
|
||||||
|
__LINE__, errno, STRERROR(errno));
|
||||||
|
return errno;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int setup_schedule_tasks()
|
static int setup_schedule_tasks()
|
||||||
{
|
{
|
||||||
|
#define SCHEDULE_ENTRIES_COUNT 5
|
||||||
ScheduleEntry scheduleEntries[SCHEDULE_ENTRIES_COUNT];
|
ScheduleEntry scheduleEntries[SCHEDULE_ENTRIES_COUNT];
|
||||||
ScheduleArray scheduleArray;
|
ScheduleArray scheduleArray;
|
||||||
|
|
||||||
|
|
@ -99,7 +154,6 @@ int main(int argc, char *argv[])
|
||||||
int result;
|
int result;
|
||||||
int wait_count;
|
int wait_count;
|
||||||
pthread_t schedule_tid;
|
pthread_t schedule_tid;
|
||||||
struct sigaction act;
|
|
||||||
char pidFilename[MAX_PATH_SIZE];
|
char pidFilename[MAX_PATH_SIZE];
|
||||||
bool stop;
|
bool stop;
|
||||||
|
|
||||||
|
|
@ -206,85 +260,13 @@ int main(int argc, char *argv[])
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&act, 0, sizeof(act));
|
if ((result=setup_signal_handlers()) != 0)
|
||||||
sigemptyset(&act.sa_mask);
|
|
||||||
|
|
||||||
act.sa_handler = sigUsrHandler;
|
|
||||||
if(sigaction(SIGUSR1, &act, NULL) < 0 || \
|
|
||||||
sigaction(SIGUSR2, &act, NULL) < 0)
|
|
||||||
{
|
{
|
||||||
logCrit("file: "__FILE__", line: %d, " \
|
|
||||||
"call sigaction fail, errno: %d, error info: %s", \
|
|
||||||
__LINE__, errno, STRERROR(errno));
|
|
||||||
logCrit("exit abnormally!\n");
|
logCrit("exit abnormally!\n");
|
||||||
return errno;
|
log_destroy();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
act.sa_handler = sigHupHandler;
|
|
||||||
if(sigaction(SIGHUP, &act, NULL) < 0)
|
|
||||||
{
|
|
||||||
logCrit("file: "__FILE__", line: %d, " \
|
|
||||||
"call sigaction fail, errno: %d, error info: %s", \
|
|
||||||
__LINE__, errno, STRERROR(errno));
|
|
||||||
logCrit("exit abnormally!\n");
|
|
||||||
return errno;
|
|
||||||
}
|
|
||||||
|
|
||||||
act.sa_handler = SIG_IGN;
|
|
||||||
if(sigaction(SIGPIPE, &act, NULL) < 0)
|
|
||||||
{
|
|
||||||
logCrit("file: "__FILE__", line: %d, " \
|
|
||||||
"call sigaction fail, errno: %d, error info: %s", \
|
|
||||||
__LINE__, errno, STRERROR(errno));
|
|
||||||
logCrit("exit abnormally!\n");
|
|
||||||
return errno;
|
|
||||||
}
|
|
||||||
|
|
||||||
act.sa_handler = sigQuitHandler;
|
|
||||||
if(sigaction(SIGINT, &act, NULL) < 0 || \
|
|
||||||
sigaction(SIGTERM, &act, NULL) < 0 || \
|
|
||||||
sigaction(SIGQUIT, &act, NULL) < 0)
|
|
||||||
{
|
|
||||||
logCrit("file: "__FILE__", line: %d, " \
|
|
||||||
"call sigaction fail, errno: %d, error info: %s", \
|
|
||||||
__LINE__, errno, STRERROR(errno));
|
|
||||||
logCrit("exit abnormally!\n");
|
|
||||||
return errno;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(DEBUG_FLAG)
|
|
||||||
/*
|
|
||||||
#if defined(OS_LINUX)
|
|
||||||
memset(&act, 0, sizeof(act));
|
|
||||||
sigemptyset(&act.sa_mask);
|
|
||||||
act.sa_sigaction = sigSegvHandler;
|
|
||||||
act.sa_flags = SA_SIGINFO;
|
|
||||||
if (sigaction(SIGSEGV, &act, NULL) < 0 || \
|
|
||||||
sigaction(SIGABRT, &act, NULL) < 0)
|
|
||||||
{
|
|
||||||
logCrit("file: "__FILE__", line: %d, " \
|
|
||||||
"call sigaction fail, errno: %d, error info: %s", \
|
|
||||||
__LINE__, errno, STRERROR(errno));
|
|
||||||
logCrit("exit abnormally!\n");
|
|
||||||
return errno;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
|
|
||||||
memset(&act, 0, sizeof(act));
|
|
||||||
sigemptyset(&act.sa_mask);
|
|
||||||
act.sa_handler = sigDumpHandler;
|
|
||||||
if(sigaction(SIGUSR1, &act, NULL) < 0 || \
|
|
||||||
sigaction(SIGUSR2, &act, NULL) < 0)
|
|
||||||
{
|
|
||||||
logCrit("file: "__FILE__", line: %d, " \
|
|
||||||
"call sigaction fail, errno: %d, error info: %s", \
|
|
||||||
__LINE__, errno, STRERROR(errno));
|
|
||||||
logCrit("exit abnormally!\n");
|
|
||||||
return errno;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WITH_HTTPD
|
#ifdef WITH_HTTPD
|
||||||
if (!g_http_params.disabled)
|
if (!g_http_params.disabled)
|
||||||
{
|
{
|
||||||
|
|
@ -362,18 +344,7 @@ int main(int argc, char *argv[])
|
||||||
wait_count = 0;
|
wait_count = 0;
|
||||||
while ((SF_G_ALIVE_THREAD_COUNT != 0) || g_schedule_flag)
|
while ((SF_G_ALIVE_THREAD_COUNT != 0) || g_schedule_flag)
|
||||||
{
|
{
|
||||||
|
fc_sleep_ms(10);
|
||||||
/*
|
|
||||||
#if defined(DEBUG_FLAG) && defined(OS_LINUX)
|
|
||||||
if (bSegmentFault)
|
|
||||||
{
|
|
||||||
sleep(5);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
|
|
||||||
usleep(10000);
|
|
||||||
if (++wait_count > 3000)
|
if (++wait_count > 3000)
|
||||||
{
|
{
|
||||||
logWarning("waiting timeout, exit!");
|
logWarning("waiting timeout, exit!");
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,7 @@ static int tracker_load_storage_id_info(const char *config_filename, \
|
||||||
int tracker_load_from_conf_file(const char *filename)
|
int tracker_load_from_conf_file(const char *filename)
|
||||||
{
|
{
|
||||||
const int task_buffer_extra_size = 0;
|
const int task_buffer_extra_size = 0;
|
||||||
|
const bool need_set_run_by = false;
|
||||||
char *pSlotMinSize;
|
char *pSlotMinSize;
|
||||||
char *pSlotMaxSize;
|
char *pSlotMaxSize;
|
||||||
char *pSpaceThreshold;
|
char *pSpaceThreshold;
|
||||||
|
|
@ -136,6 +137,7 @@ int tracker_load_from_conf_file(const char *filename)
|
||||||
char *pHttpCheckType;
|
char *pHttpCheckType;
|
||||||
#endif
|
#endif
|
||||||
IniContext iniContext;
|
IniContext iniContext;
|
||||||
|
SFContextIniConfig config;
|
||||||
int result;
|
int result;
|
||||||
int64_t trunk_file_size;
|
int64_t trunk_file_size;
|
||||||
int64_t slot_min_size;
|
int64_t slot_min_size;
|
||||||
|
|
@ -168,16 +170,17 @@ int tracker_load_from_conf_file(const char *filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
sf_set_current_time();
|
sf_set_current_time();
|
||||||
if ((result=sf_load_config("trackerd", filename, &iniContext,
|
|
||||||
"service", FDFS_TRACKER_SERVER_DEF_PORT,
|
SF_SET_CONTEXT_INI_CONFIG(config, filename, &iniContext,
|
||||||
FDFS_TRACKER_SERVER_DEF_PORT,
|
NULL, FDFS_TRACKER_SERVER_DEF_PORT,
|
||||||
task_buffer_extra_size)) != 0)
|
FDFS_TRACKER_SERVER_DEF_PORT, DEFAULT_WORK_THREADS);
|
||||||
|
if ((result=sf_load_config_ex("trackerd", &config,
|
||||||
|
task_buffer_extra_size, need_set_run_by)) != 0)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((result=tracker_load_store_lookup(filename, \
|
if ((result=tracker_load_store_lookup(filename, &iniContext)) != 0)
|
||||||
&iniContext)) != 0)
|
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -587,4 +590,3 @@ int tracker_load_from_conf_file(const char *filename)
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,12 @@ static void task_finish_clean_up(struct fast_task_info *pTask)
|
||||||
int tracker_service_init()
|
int tracker_service_init()
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
if ((result=init_pthread_lock(&lb_thread_lock)) != 0)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
result = sf_service_init("fdfs_trackerd", NULL, NULL, NULL,
|
result = sf_service_init("fdfs_trackerd", NULL, NULL, NULL,
|
||||||
fdfs_set_body_length, tracker_deal_task, task_finish_clean_up,
|
fdfs_set_body_length, tracker_deal_task, task_finish_clean_up,
|
||||||
NULL, 1000, sizeof(TrackerHeader), sizeof(TrackerClientInfo));
|
NULL, 1000, sizeof(TrackerHeader), sizeof(TrackerClientInfo));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue