try to use clock_gettime to make sure we don't care if the system time changes

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7165 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale committed 2008-01-11 00:43:49 +00:00
1 parent 886f99735a
commit 143bed09a3
38 files changed
+174 -104

No files matched your search

@@ -600,11 +600,16 @@ SWITCH_STANDARD_API(ctl_function)
}
switch_core_session_ctl(SCSC_SPS, &arg);
stream->write_function(stream, "+OK sessions per second: %d\n", arg);
} else if (!strcasecmp(argv[0], "sync_clock")) {
arg = 0;
switch_core_session_ctl(SCSC_SYNC_CLOCK, &arg);
stream->write_function(stream, "+OK clock syncronized\n");
} else {
stream->write_function(stream, "-ERR INVALID COMMAND\nUSAGE: fsctl %s", CTL_SYNTAX);
goto end;
}
}
stream->write_function(stream, "+OK\n");
end:
free(mydata);
@@ -830,13 +835,13 @@ SWITCH_STANDARD_API(tone_detect_session_function)
uint32_t mto;
if (*argv[4] == '+') {
if ((mto = atoi(argv[4]+1)) > 0) {
to = time(NULL) + mto;
to = switch_timestamp(NULL) + mto;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
goto done;
}
} else {
if ((to = atoi(argv[4])) < time(NULL)) {
if ((to = atoi(argv[4])) < switch_timestamp(NULL)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
to = 0;
goto done;
@@ -930,7 +935,7 @@ SWITCH_STANDARD_API(sched_transfer_function)
time_t when;
if (*argv[0] == '+') {
when = time(NULL) + atol(argv[0] + 1);
when = switch_timestamp(NULL) + atol(argv[0] + 1);
} else {
when = atol(argv[0]);
}
@@ -972,7 +977,7 @@ SWITCH_STANDARD_API(sched_hangup_function)
switch_call_cause_t cause = SWITCH_CAUSE_ALLOTTED_TIMEOUT;
if (*argv[0] == '+') {
when = time(NULL) + atol(argv[0] + 1);
when = switch_timestamp(NULL) + atol(argv[0] + 1);
} else {
when = atol(argv[0]);
}
@@ -1091,7 +1096,7 @@ SWITCH_STANDARD_API(sched_broadcast_function)
time_t when;
if (*argv[0] == '+') {
when = time(NULL) + atol(argv[0] + 1);
when = switch_timestamp(NULL) + atol(argv[0] + 1);
} else {
when = atol(argv[0]);
}
@@ -1603,7 +1608,7 @@ SWITCH_STANDARD_API(sched_api_function)
*dcmd++ = '\0';
if (*tm == '+') {
when = time(NULL) + atol(tm + 1);
when = switch_timestamp(NULL) + atol(tm + 1);
} else {
when = atol(tm);
}
@@ -220,7 +220,7 @@ SWITCH_STANDARD_APP(sched_transfer_function)
time_t when;
if (*argv[0] == '+') {
when = time(NULL) + atol(argv[0] + 1);
when = switch_timestamp(NULL) + atol(argv[0] + 1);
} else {
when = atol(argv[0]);
}
@@ -245,7 +245,7 @@ SWITCH_STANDARD_APP(sched_hangup_function)
switch_bool_t bleg = SWITCH_FALSE;
if (*argv[0] == '+') {
when = time(NULL) + atol(argv[0] + 1);
when = switch_timestamp(NULL) + atol(argv[0] + 1);
} else {
when = atol(argv[0]);
}
@@ -277,7 +277,7 @@ SWITCH_STANDARD_APP(sched_broadcast_function)
switch_media_flag_t flags = SMF_NONE;
if (*argv[0] == '+') {
when = time(NULL) + atol(argv[0] + 1);
when = switch_timestamp(NULL) + atol(argv[0] + 1);
} else {
when = atol(argv[0]);
}
@@ -749,7 +749,7 @@ SWITCH_STANDARD_APP(strftime_function)
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
switch_time_exp_lt(&tm, switch_time_now());
switch_time_exp_lt(&tm, switch_timestamp_now());
switch_strftime(date, &retsize, sizeof(date), argv[1], &tm);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SET [%s]=[%s]\n", argv[0], date);
switch_channel_set_variable(channel, argv[0], date);
@@ -761,7 +761,7 @@ SWITCH_STANDARD_API(strepoch_api_function)
switch_time_t out;
if (switch_strlen_zero(cmd)) {
out = switch_time_now();
out = switch_timestamp_now();
} else {
out = switch_str_time(cmd);
}
@@ -782,7 +782,7 @@ SWITCH_STANDARD_API(strftime_api_function)
thetime = switch_time_make(atoi(cmd),0);
cmd = p+1;
} else {
thetime = switch_time_now();
thetime = switch_timestamp_now();
}
switch_time_exp_lt(&tm, thetime);
switch_strftime(date, &retsize, sizeof(date), switch_strlen_zero(cmd) ? "%Y-%m-%d %T" : cmd, &tm);
@@ -969,12 +969,12 @@ SWITCH_STANDARD_APP(tone_detect_session_function)
uint32_t mto;
if (*argv[3] == '+') {
if ((mto = atol(argv[3]+1)) > 0) {
to = time(NULL) + mto;
to = switch_timestamp(NULL) + mto;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
}
} else {
if ((to = atol(argv[3])) < time(NULL)) {
if ((to = atol(argv[3])) < switch_timestamp(NULL)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n");
to = 0;
}
+1 -1
View File
@@ -510,7 +510,7 @@ static switch_status_t enum_lookup(char *root, char *in, enum_record_t ** result
tv.tv_sec = i;
tv.tv_usec = 0;
i = select((int) (fd + 1), &fds, 0, 0, &tv);
now = time(NULL);
now = switch_timestamp(NULL);
if (i > 0) {
dns_ioevent(nctx, now);
}
+2 -2
View File
@@ -182,7 +182,7 @@ SWITCH_STANDARD_APP(bcast_function)
}
}
control_packet.unique_id = htonl((u_long)time(NULL));
control_packet.unique_id = htonl((u_long)switch_timestamp(NULL));
control_packet.command = htonl(LS_START_BCAST);
control_packet.ip = inet_addr(mcast_ip);
control_packet.port = htonl(mcast_port);
@@ -211,7 +211,7 @@ SWITCH_STANDARD_APP(bcast_function)
control_packet.unique_id = htonl((u_long)time(NULL));
control_packet.unique_id = htonl((u_long)switch_timestamp(NULL));
control_packet.command = htonl(LS_STOP_BCAST);
bytes = 8;
switch_socket_sendto(socket, control_packet_addr, 0, (void *)&control_packet, &bytes);
+1 -1
View File
@@ -484,7 +484,7 @@ SWITCH_STANDARD_APP(rss_function)
switch_size_t retsize;
char dtmf[5] = "";
switch_time_exp_lt(&tm, switch_time_now());
switch_time_exp_lt(&tm, switch_timestamp_now());
switch_strftime(date, &retsize, sizeof(date), "%I:%M %p", &tm);
@@ -1380,7 +1380,7 @@ default:
}
}
switch_snprintf(sql, sizeof(sql), "update voicemail_data set read_epoch=%ld where user='%s' and domain='%s' and flags='save'",
(long)time(NULL), myid, domain_name);
(long)switch_timestamp(NULL), myid, domain_name);
vm_execute_sql(profile, sql, profile->mutex);
switch_snprintf(sql, sizeof(sql), "select file_path from voicemail_data where user='%s' and domain='%s' and flags='delete'", myid, domain_name);
vm_execute_sql_callback(profile, profile->mutex, sql, unlink_callback, NULL);
@@ -1891,7 +1891,7 @@ greet:
int total_new_urgent_messages = 0;
int total_saved_urgent_messages = 0;
usql = switch_mprintf("insert into voicemail_data values(%ld,0,'%q','%q','%q','%q','%q','%q','%q','%u','','%q')", (long)time(NULL),
usql = switch_mprintf("insert into voicemail_data values(%ld,0,'%q','%q','%q','%q','%q','%q','%q','%u','','%q')", (long)switch_timestamp(NULL),
id, domain_name, uuid, caller_profile->caller_id_name, caller_profile->caller_id_number,
myfolder, file_path, message_len, read_flags);
vm_execute_sql(profile, usql, profile->mutex);
@@ -1936,7 +1936,7 @@ end:
message_count(profile, id, domain_name, myfolder, &total_new_messages, &total_saved_messages,
&total_new_urgent_messages, &total_saved_urgent_messages);
switch_time_exp_lt(&tm, switch_time_now());
switch_time_exp_lt(&tm, switch_timestamp_now());
switch_strftime(date, &retsize, sizeof(date), profile->date_fmt, &tm);
switch_channel_set_variable(channel, "voicemail_current_folder", myfolder);
@@ -2255,7 +2255,7 @@ static void do_play(vm_profile_t *profile, char *user, char *domain, char *file,
struct holder holder;
sql = switch_mprintf("update voicemail_data set read_epoch=%ld where user='%s' and domain='%s' and file_path like '%%%s'",
(long)time(NULL), user, domain, file);
(long)switch_timestamp(NULL), user, domain, file);
vm_execute_sql(profile, sql, profile->mutex);
free(sql);