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
This commit is contained in:
Michael Jerris 2007-03-30 01:40:50 +00:00
parent 6ba96a7913
commit 92d726b995
5 changed files with 11 additions and 30 deletions

View File

@ -171,7 +171,6 @@ AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long, 4)
AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(long long, 8)
AC_CHECK_SIZEOF(time_t, 4)
AC_TYPE_SIZE_T
AC_CHECK_TYPE(ssize_t, int)
@ -247,16 +246,6 @@ else
size_t_fmt='#error Can not determine the proper size for size_t'
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
# 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,
@ -305,7 +294,6 @@ AC_SUBST(int64_t_fmt)
AC_SUBST(uint64_t_fmt)
AC_SUBST(ssize_t_fmt)
AC_SUBST(size_t_fmt)
AC_SUBST(time_t_fmt)
AC_PATH_PROGS(ZCAT, gunzip gzcat gzip zcat)
AC_PATH_PROGS(TAR, gtar tar)

View File

@ -15,6 +15,5 @@
@size_t_fmt@
@int64_t_fmt@
@uint64_t_fmt@
@time_t_fmt@
#endif

View File

@ -201,12 +201,6 @@ typedef intptr_t switch_ssize_t;
#define SWITCH_INT64_T_FMT "I64d"
#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
#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")

View File

@ -40,8 +40,8 @@ SWITCH_BEGIN_EXTERN_C
///\ingroup core1
///\{
struct switch_scheduler_task {
time_t created;
time_t runtime;
int64_t created;
int64_t runtime;
uint32_t cmd_id;
char *group;
void *cmd_arg;

View File

@ -2,7 +2,7 @@
struct switch_scheduler_task_container {
switch_scheduler_task_t task;
time_t executed;
int64_t executed;
int in_thread;
int destroyed;
switch_scheduler_func_t func;
@ -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-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-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);
}
} else {
@ -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-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-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);
}
tp->destroyed = 1;
@ -75,7 +75,7 @@ static int task_thread_loop(int done)
if (done) {
tp->destroyed = 1;
} else {
time_t now = time(NULL);
int64_t now = time(NULL);
if (now >= tp->task.runtime && !tp->in_thread) {
tp->executed = now;
if (switch_test_flag(tp, SSHF_OWN_THREAD)) {
@ -174,14 +174,14 @@ SWITCH_DECLARE(uint32_t) switch_scheduler_add_task(time_t task_runtime,
switch_mutex_unlock(globals.task_mutex);
tp = container;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Added task %u %s (%s) to run at %" TIME_T_FMT "\n",
tp->task.task_id, tp->desc, switch_str_nil(tp->task.group), task_runtime);
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), tp->task.runtime);
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-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-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);
}
return container->task.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-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-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);
}
status = SWITCH_STATUS_SUCCESS;
@ -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-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-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);
}
tp->destroyed++;