提交 92d726b9 authored 作者: Michael Jerris's avatar Michael Jerris

use int64_t internally for storage of time_t values in the scheduler because at…

use int64_t internally for storage of time_t values in the scheduler because at least then we know what format string to use to print them, and they are often that type anyways.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4802 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 6ba96a79
...@@ -171,7 +171,6 @@ AC_CHECK_SIZEOF(int, 4) ...@@ -171,7 +171,6 @@ AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long, 4) AC_CHECK_SIZEOF(long, 4)
AC_CHECK_SIZEOF(short, 2) AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(long long, 8) AC_CHECK_SIZEOF(long long, 8)
AC_CHECK_SIZEOF(time_t, 4)
AC_TYPE_SIZE_T AC_TYPE_SIZE_T
AC_CHECK_TYPE(ssize_t, int) AC_CHECK_TYPE(ssize_t, int)
...@@ -247,16 +246,6 @@ else ...@@ -247,16 +246,6 @@ else
size_t_fmt='#error Can not determine the proper size for size_t' size_t_fmt='#error Can not determine the proper size for size_t'
fi fi
if test "$ac_cv_sizeof_time_t" = "$ac_cv_sizeof_long"; then
time_t_fmt='#define TIME_T_FMT "ld"'
elif test "$ac_cv_sizeof_time_t" = "$ac_cv_sizeof_int"; then
time_t_fmt='#define TIME_T_FMT "d"'
elif test "$ac_cv_sizeof_time_t" = "$ac_cv_sizeof_long_long"; then
time_t_fmt='#define TIME_T_FMT "lld"'
else
time_t_fmt='#error Can not determine the proper format specifier for time_t of size $ac_cv_sizeof_time_t'
fi
# Basically, we have tried to figure out the correct format strings # Basically, we have tried to figure out the correct format strings
# for SWITCH types which vary between platforms, but we don't always get # for SWITCH types which vary between platforms, but we don't always get
# it right. If you find that we don't get it right for your platform, # it right. If you find that we don't get it right for your platform,
...@@ -305,7 +294,6 @@ AC_SUBST(int64_t_fmt) ...@@ -305,7 +294,6 @@ AC_SUBST(int64_t_fmt)
AC_SUBST(uint64_t_fmt) AC_SUBST(uint64_t_fmt)
AC_SUBST(ssize_t_fmt) AC_SUBST(ssize_t_fmt)
AC_SUBST(size_t_fmt) AC_SUBST(size_t_fmt)
AC_SUBST(time_t_fmt)
AC_PATH_PROGS(ZCAT, gunzip gzcat gzip zcat) AC_PATH_PROGS(ZCAT, gunzip gzcat gzip zcat)
AC_PATH_PROGS(TAR, gtar tar) AC_PATH_PROGS(TAR, gtar tar)
......
...@@ -15,6 +15,5 @@ ...@@ -15,6 +15,5 @@
@size_t_fmt@ @size_t_fmt@
@int64_t_fmt@ @int64_t_fmt@
@uint64_t_fmt@ @uint64_t_fmt@
@time_t_fmt@
#endif #endif
...@@ -201,12 +201,6 @@ typedef intptr_t switch_ssize_t; ...@@ -201,12 +201,6 @@ typedef intptr_t switch_ssize_t;
#define SWITCH_INT64_T_FMT "I64d" #define SWITCH_INT64_T_FMT "I64d"
#define SWITCH_UINT64_T_FMT "I64u" #define SWITCH_UINT64_T_FMT "I64u"
#ifdef _USE_32BIT_TIME_T
#define TIME_T_FMT "d"
#else
#define TIME_T_FMT SWITCH_INT64_T_FMT
#endif
#else #else
#ifndef SWITCH_SSIZE_T_FMT #ifndef SWITCH_SSIZE_T_FMT
#define SWITCH_SSIZE_T_FMT (sizeof (switch_ssize_t) == sizeof (long) ? "ld" : sizeof (switch_ssize_t) == sizeof (int) ? "d" : "lld") #define SWITCH_SSIZE_T_FMT (sizeof (switch_ssize_t) == sizeof (long) ? "ld" : sizeof (switch_ssize_t) == sizeof (int) ? "d" : "lld")
......
...@@ -40,8 +40,8 @@ SWITCH_BEGIN_EXTERN_C ...@@ -40,8 +40,8 @@ SWITCH_BEGIN_EXTERN_C
///\ingroup core1 ///\ingroup core1
///\{ ///\{
struct switch_scheduler_task { struct switch_scheduler_task {
time_t created; int64_t created;
time_t runtime; int64_t runtime;
uint32_t cmd_id; uint32_t cmd_id;
char *group; char *group;
void *cmd_arg; void *cmd_arg;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
struct switch_scheduler_task_container { struct switch_scheduler_task_container {
switch_scheduler_task_t task; switch_scheduler_task_t task;
time_t executed; int64_t executed;
int in_thread; int in_thread;
int destroyed; int destroyed;
switch_scheduler_func_t func; switch_scheduler_func_t func;
...@@ -35,7 +35,7 @@ static void switch_scheduler_execute(switch_scheduler_task_container_t * tp) ...@@ -35,7 +35,7 @@ static void switch_scheduler_execute(switch_scheduler_task_container_t * tp)
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-ID", "%u", tp->task.task_id); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-ID", "%u", tp->task.task_id);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Desc", "%s", tp->desc); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Desc", "%s", tp->desc);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Group", "%s", switch_str_nil(tp->task.group)); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Group", "%s", switch_str_nil(tp->task.group));
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Runtime", "%" TIME_T_FMT, tp->task.runtime); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Runtime", "%" SWITCH_INT64_T_FMT, tp->task.runtime);
switch_event_fire(&event); switch_event_fire(&event);
} }
} else { } else {
...@@ -43,7 +43,7 @@ static void switch_scheduler_execute(switch_scheduler_task_container_t * tp) ...@@ -43,7 +43,7 @@ static void switch_scheduler_execute(switch_scheduler_task_container_t * tp)
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-ID", "%u", tp->task.task_id); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-ID", "%u", tp->task.task_id);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Desc", "%s", tp->desc); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Desc", "%s", tp->desc);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Group", "%s", switch_str_nil(tp->task.group)); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Group", "%s", switch_str_nil(tp->task.group));
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Runtime", "%" TIME_T_FMT, tp->task.runtime); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Runtime", "%" SWITCH_INT64_T_FMT, tp->task.runtime);
switch_event_fire(&event); switch_event_fire(&event);
} }
tp->destroyed = 1; tp->destroyed = 1;
...@@ -75,7 +75,7 @@ static int task_thread_loop(int done) ...@@ -75,7 +75,7 @@ static int task_thread_loop(int done)
if (done) { if (done) {
tp->destroyed = 1; tp->destroyed = 1;
} else { } else {
time_t now = time(NULL); int64_t now = time(NULL);
if (now >= tp->task.runtime && !tp->in_thread) { if (now >= tp->task.runtime && !tp->in_thread) {
tp->executed = now; tp->executed = now;
if (switch_test_flag(tp, SSHF_OWN_THREAD)) { if (switch_test_flag(tp, SSHF_OWN_THREAD)) {
...@@ -174,14 +174,14 @@ SWITCH_DECLARE(uint32_t) switch_scheduler_add_task(time_t task_runtime, ...@@ -174,14 +174,14 @@ SWITCH_DECLARE(uint32_t) switch_scheduler_add_task(time_t task_runtime,
switch_mutex_unlock(globals.task_mutex); switch_mutex_unlock(globals.task_mutex);
tp = container; tp = container;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Added task %u %s (%s) to run at %" TIME_T_FMT "\n", switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Added task %u %s (%s) to run at %" SWITCH_INT64_T_FMT "\n",
tp->task.task_id, tp->desc, switch_str_nil(tp->task.group), task_runtime); tp->task.task_id, tp->desc, switch_str_nil(tp->task.group), tp->task.runtime);
if (switch_event_create(&event, SWITCH_EVENT_ADD_SCHEDULE) == SWITCH_STATUS_SUCCESS) { if (switch_event_create(&event, SWITCH_EVENT_ADD_SCHEDULE) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-ID", "%u", tp->task.task_id); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-ID", "%u", tp->task.task_id);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Desc", "%s", tp->desc); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Desc", "%s", tp->desc);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Group", "%s", switch_str_nil(tp->task.group)); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Group", "%s", switch_str_nil(tp->task.group));
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Runtime", "%" TIME_T_FMT, tp->task.runtime); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Runtime", "%" SWITCH_INT64_T_FMT, tp->task.runtime);
switch_event_fire(&event); switch_event_fire(&event);
} }
return container->task.task_id; return container->task.task_id;
...@@ -201,7 +201,7 @@ SWITCH_DECLARE(switch_status_t) switch_scheduler_del_task_id(uint32_t task_id) ...@@ -201,7 +201,7 @@ SWITCH_DECLARE(switch_status_t) switch_scheduler_del_task_id(uint32_t task_id)
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-ID", "%u", tp->task.task_id); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-ID", "%u", tp->task.task_id);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Desc", "%s", tp->desc); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Desc", "%s", tp->desc);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Group", "%s", switch_str_nil(tp->task.group)); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Group", "%s", switch_str_nil(tp->task.group));
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Runtime", "%" TIME_T_FMT, tp->task.runtime); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Runtime", "%" SWITCH_INT64_T_FMT, tp->task.runtime);
switch_event_fire(&event); switch_event_fire(&event);
} }
status = SWITCH_STATUS_SUCCESS; status = SWITCH_STATUS_SUCCESS;
...@@ -226,7 +226,7 @@ SWITCH_DECLARE(switch_status_t) switch_scheduler_del_task_group(char *group) ...@@ -226,7 +226,7 @@ SWITCH_DECLARE(switch_status_t) switch_scheduler_del_task_group(char *group)
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-ID", "%u", tp->task.task_id); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-ID", "%u", tp->task.task_id);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Desc", "%s", tp->desc); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Desc", "%s", tp->desc);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Group", "%s", switch_str_nil(tp->task.group)); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Group", "%s", switch_str_nil(tp->task.group));
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Runtime", "%" TIME_T_FMT, tp->task.runtime); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-Runtime", "%" SWITCH_INT64_T_FMT, tp->task.runtime);
switch_event_fire(&event); switch_event_fire(&event);
} }
tp->destroyed++; tp->destroyed++;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论