mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-23 12:42:02 +00:00
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:
@@ -1242,7 +1242,7 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
|
||||
switch_assert(gp->state < REG_STATE_LAST);
|
||||
stream->write_function(stream, "%25s\t%s\t %32s\t%s", gp->name, "gateway", gp->register_to, sofia_state_names[gp->state]);
|
||||
if (gp->state == REG_STATE_FAILED || gp->state == REG_STATE_TRYING) {
|
||||
stream->write_function(stream, " (retry: %ds)", gp->retry - time(NULL));
|
||||
stream->write_function(stream, " (retry: %ds)", gp->retry - switch_timestamp(NULL));
|
||||
}
|
||||
stream->write_function(stream, "\n");
|
||||
}
|
||||
@@ -1348,7 +1348,7 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
|
||||
|
||||
if (!strcasecmp(argv[1], "stop") || !strcasecmp(argv[1], "restart")) {
|
||||
int rsec = 3;
|
||||
int diff = (int) (time(NULL) - profile->started);
|
||||
int diff = (int) (switch_timestamp(NULL) - profile->started);
|
||||
int remain = rsec - diff;
|
||||
if (diff < rsec) {
|
||||
stream->write_function(stream, "Profile %s must be up for at least %d seconds to stop/restart.\nPlease wait %d second%s\n",
|
||||
|
||||
@@ -345,7 +345,7 @@ void event_handler(switch_event_t *event)
|
||||
char *rpid = switch_event_get_header(event, "orig-rpid");
|
||||
char *call_id = switch_event_get_header(event, "orig-call-id");
|
||||
char *user_agent = switch_event_get_header(event, "user-agent");
|
||||
long expires = (long) time(NULL) + atol(exp_str);
|
||||
long expires = (long) switch_timestamp(NULL) + atol(exp_str);
|
||||
char *profile_name = switch_event_get_header(event, "orig-profile-name");
|
||||
sofia_profile_t *profile = NULL;
|
||||
|
||||
@@ -512,19 +512,19 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Starting thread for %s\n", profile->name);
|
||||
|
||||
profile->started = time(NULL);
|
||||
profile->started = switch_timestamp(NULL);
|
||||
switch_yield(1000000);
|
||||
|
||||
sofia_set_pflag_locked(profile, PFLAG_RUNNING);
|
||||
|
||||
while (mod_sofia_globals.running == 1 && sofia_test_pflag(profile, PFLAG_RUNNING)) {
|
||||
if (++ireg_loops >= IREG_SECONDS) {
|
||||
sofia_reg_check_expire(profile, time(NULL));
|
||||
sofia_reg_check_expire(profile, switch_timestamp(NULL));
|
||||
ireg_loops = 0;
|
||||
}
|
||||
|
||||
if (++gateway_loops >= GATEWAY_SECONDS) {
|
||||
sofia_reg_check_gateway(profile, time(NULL));
|
||||
sofia_reg_check_gateway(profile, switch_timestamp(NULL));
|
||||
gateway_loops = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ void sofia_glue_set_local_sdp(private_object_t *tech_pvt, const char *ip, uint32
|
||||
}
|
||||
|
||||
if (!tech_pvt->owner_id) {
|
||||
tech_pvt->owner_id = (uint32_t) time(NULL) - port;
|
||||
tech_pvt->owner_id = (uint32_t) switch_timestamp(NULL) - port;
|
||||
}
|
||||
|
||||
if (!tech_pvt->session_id) {
|
||||
@@ -1468,7 +1468,8 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
|
||||
}
|
||||
|
||||
if (match) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Our existing codec is still good, let's keep it\n");
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Our existing codec [%s] is still good, let's keep it\n",
|
||||
tech_pvt->rm_encoding);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -608,13 +608,13 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
||||
char *prpid;
|
||||
int done = 0;
|
||||
const char *ct;
|
||||
time_t exptime = time(NULL) + 3600;
|
||||
time_t exptime = switch_timestamp(NULL) + 3600;
|
||||
char exp[80] = "";
|
||||
|
||||
if (expires) {
|
||||
long tmp = atol(expires);
|
||||
if (tmp > 0) {
|
||||
exptime = tmp - time(NULL);
|
||||
exptime = tmp - switch_timestamp(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -855,7 +855,7 @@ static int sofia_presence_mwi_callback(void *pArg, int argc, char **argv, char *
|
||||
}
|
||||
|
||||
id = switch_mprintf("sip:%s@%s", sub_to_user, sub_to_host);
|
||||
expire_sec = (int)(expire_sec - time(NULL));
|
||||
expire_sec = (int)(expire_sec - switch_timestamp(NULL));
|
||||
if (expire_sec < 0) {
|
||||
expire_sec = 3600;
|
||||
}
|
||||
@@ -1047,7 +1047,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
||||
full_via = sip_header_as_string(profile->home, (void *) sip->sip_via);
|
||||
|
||||
exp_raw = (sip->sip_expires ? sip->sip_expires->ex_delta : 3600);
|
||||
exp = (long) time(NULL) + exp_raw;
|
||||
exp = (long) switch_timestamp(NULL) + exp_raw;
|
||||
|
||||
switch_mutex_lock(profile->ireg_mutex);
|
||||
|
||||
|
||||
@@ -302,7 +302,7 @@ void sofia_reg_auth_challange(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
||||
|
||||
switch_mutex_lock(profile->ireg_mutex);
|
||||
sql = switch_mprintf("insert into sip_authentication (nonce, expires) values('%q', %ld)",
|
||||
uuid_str, time(NULL) + profile->nonce_ttl);
|
||||
uuid_str, switch_timestamp(NULL) + profile->nonce_ttl);
|
||||
switch_assert(sql != NULL);
|
||||
sofia_glue_execute_sql(profile, SWITCH_FALSE, sql, NULL);
|
||||
switch_safe_free(sql);
|
||||
@@ -495,7 +495,7 @@ uint8_t sofia_reg_handle_register(nua_t * nua, sofia_profile_t *profile, nua_han
|
||||
|
||||
sql = switch_mprintf("insert into sip_registrations values ('%q', '%q','%q','%q','%q', '%q', %ld, '%q')", call_id,
|
||||
to_user, to_host, contact_str, cd ? "Registered(NATHACK)" : "Registered",
|
||||
rpid, (long) time(NULL) + (long) exptime * 2, agent);
|
||||
rpid, (long) switch_timestamp(NULL) + (long) exptime * 2, agent);
|
||||
|
||||
|
||||
if (sql) {
|
||||
|
||||
Reference in New Issue
Block a user