From 0463541d617ac092a54341087d6e718042b9757d Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Sun, 25 Jan 2009 21:23:07 +0000 Subject: [PATCH] change low res sleep func api names git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11486 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_core.h | 4 +- .../applications/mod_commands/mod_commands.c | 16 ++++---- .../applications/mod_dptools/mod_dptools.c | 16 ++++---- src/mod/applications/mod_enum/mod_enum.c | 2 +- src/mod/applications/mod_esf/mod_esf.c | 4 +- src/mod/applications/mod_fifo/mod_fifo.c | 38 +++++++++---------- src/mod/applications/mod_fsv/mod_fsv.c | 2 +- src/mod/applications/mod_limit/mod_limit.c | 2 +- src/mod/applications/mod_rss/mod_rss.c | 2 +- .../mod_voicemail/mod_voicemail.c | 12 +++--- src/mod/endpoints/mod_alsa/mod_alsa.c | 6 +-- .../endpoints/mod_dingaling/mod_dingaling.c | 10 ++--- .../endpoints/mod_portaudio/mod_portaudio.c | 10 ++--- src/mod/endpoints/mod_sofia/mod_sofia.c | 6 +-- src/mod/endpoints/mod_sofia/sofia.c | 18 ++++----- src/mod/endpoints/mod_sofia/sofia_glue.c | 6 +-- src/mod/endpoints/mod_sofia/sofia_presence.c | 10 ++--- src/mod/endpoints/mod_sofia/sofia_reg.c | 6 +-- .../event_handlers/mod_cdr_csv/mod_cdr_csv.c | 2 +- .../mod_erlang_event/mod_erlang_event.c | 2 +- .../mod_event_socket/mod_event_socket.c | 10 ++--- .../mod_spidermonkey/mod_spidermonkey.c | 8 ++-- src/mod/loggers/mod_logfile/mod_logfile.c | 2 +- src/mod/say/mod_say_de/mod_say_de.c | 4 +- src/mod/say/mod_say_en/mod_say_en.c | 4 +- src/mod/say/mod_say_es/mod_say_es.c | 4 +- src/mod/say/mod_say_fr/mod_say_fr.c | 4 +- src/mod/say/mod_say_it/mod_say_it.c | 4 +- src/mod/say/mod_say_nl/mod_say_nl.c | 4 +- src/mod/say/mod_say_zh/mod_say_zh.c | 6 +-- src/switch_channel.c | 12 +++--- src/switch_console.c | 2 +- src/switch_core.c | 6 +-- src/switch_core_io.c | 6 +-- src/switch_core_port_allocator.c | 2 +- src/switch_core_session.c | 4 +- src/switch_core_sqldb.c | 4 +- src/switch_event.c | 2 +- src/switch_ivr.c | 30 +++++++-------- src/switch_ivr_async.c | 6 +-- src/switch_ivr_originate.c | 12 +++--- src/switch_ivr_play_say.c | 4 +- src/switch_log.c | 2 +- src/switch_resample.c | 2 +- src/switch_rtp.c | 18 ++++----- src/switch_scheduler.c | 4 +- src/switch_stun.c | 6 +-- src/switch_time.c | 10 ++--- src/switch_utils.c | 4 +- 49 files changed, 180 insertions(+), 180 deletions(-) diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 345337f928..1a63306387 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -1690,14 +1690,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_mime_add_type(const char *type, cons SWITCH_DECLARE(switch_loadable_module_interface_t *) switch_loadable_module_create_module_interface(switch_memory_pool_t *pool, const char *name); SWITCH_DECLARE(void *) switch_loadable_module_create_interface(switch_loadable_module_interface_t *mod, switch_module_interface_name_t iname); -SWITCH_DECLARE(switch_time_t) switch_timestamp_now(void); +SWITCH_DECLARE(switch_time_t) switch_micro_time_now(void); SWITCH_DECLARE(void) switch_core_memory_reclaim(void); SWITCH_DECLARE(void) switch_core_memory_reclaim_events(void); SWITCH_DECLARE(void) switch_core_memory_reclaim_logger(void); SWITCH_DECLARE(void) switch_core_memory_reclaim_all(void); SWITCH_DECLARE(void) switch_core_setrlimits(void); SWITCH_DECLARE(void) switch_time_sync(void); -SWITCH_DECLARE(time_t) switch_timestamp(time_t *t); +SWITCH_DECLARE(time_t) switch_epoch_time_now(time_t *t); SWITCH_DECLARE(switch_status_t) switch_strftime_tz(const char *tz, const char *format, char *date, size_t len, switch_time_t thetime); SWITCH_DECLARE(switch_status_t) switch_time_exp_tz_name(const char *tz, switch_time_exp_t *tm, switch_time_t thetime); SWITCH_DECLARE(void) switch_load_network_lists(switch_bool_t reload); diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 0fbd627fe7..d7176b2465 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -1384,13 +1384,13 @@ SWITCH_STANDARD_API(tone_detect_session_function) uint32_t mto; if (*argv[4] == '+') { if ((mto = atoi(argv[4] + 1)) > 0) { - to = switch_timestamp(NULL) + mto; + to = switch_epoch_time_now(NULL) + mto; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n"); goto done; } } else { - if ((to = atoi(argv[4])) < switch_timestamp(NULL)) { + if ((to = atoi(argv[4])) < switch_epoch_time_now(NULL)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n"); to = 0; goto done; @@ -1520,7 +1520,7 @@ SWITCH_STANDARD_API(sched_transfer_function) time_t when; if (*argv[0] == '+') { - when = switch_timestamp(NULL) + atol(argv[0] + 1); + when = switch_epoch_time_now(NULL) + atol(argv[0] + 1); } else { when = atol(argv[0]); } @@ -1558,7 +1558,7 @@ SWITCH_STANDARD_API(sched_hangup_function) switch_call_cause_t cause = SWITCH_CAUSE_ALLOTTED_TIMEOUT; if (*argv[0] == '+') { - when = switch_timestamp(NULL) + atol(argv[0] + 1); + when = switch_epoch_time_now(NULL) + atol(argv[0] + 1); } else { when = atol(argv[0]); } @@ -1665,7 +1665,7 @@ SWITCH_STANDARD_API(sched_broadcast_function) time_t when; if (*argv[0] == '+') { - when = switch_timestamp(NULL) + atol(argv[0] + 1); + when = switch_epoch_time_now(NULL) + atol(argv[0] + 1); } else { when = atol(argv[0]); } @@ -2205,7 +2205,7 @@ static void sch_api_callback(switch_scheduler_task_t *task) switch_safe_free(cmd); if (api_task->recur) { - task->runtime = switch_timestamp(NULL) + api_task->recur; + task->runtime = switch_epoch_time_now(NULL) + api_task->recur; } @@ -2252,10 +2252,10 @@ SWITCH_STANDARD_API(sched_api_function) if (*tm == '+') { - when = switch_timestamp(NULL) + atol(tm + 1); + when = switch_epoch_time_now(NULL) + atol(tm + 1); } else if (*tm == '@') { recur = (uint32_t) atol(tm + 1); - when = switch_timestamp(NULL) + recur; + when = switch_epoch_time_now(NULL) + recur; } else { when = atol(tm); } diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index 75db56fa9c..25e511d3f7 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -473,7 +473,7 @@ SWITCH_STANDARD_APP(sched_transfer_function) time_t when; if (*argv[0] == '+') { - when = switch_timestamp(NULL) + atol(argv[0] + 1); + when = switch_epoch_time_now(NULL) + atol(argv[0] + 1); } else { when = atol(argv[0]); } @@ -498,7 +498,7 @@ SWITCH_STANDARD_APP(sched_hangup_function) switch_bool_t bleg = SWITCH_FALSE; if (*argv[0] == '+') { - when = switch_timestamp(NULL) + atol(argv[0] + 1); + when = switch_epoch_time_now(NULL) + atol(argv[0] + 1); } else { when = atol(argv[0]); } @@ -530,7 +530,7 @@ SWITCH_STANDARD_APP(sched_broadcast_function) switch_media_flag_t flags = SMF_NONE; if (*argv[0] == '+') { - when = switch_timestamp(NULL) + atol(argv[0] + 1); + when = switch_epoch_time_now(NULL) + atol(argv[0] + 1); } else { when = atol(argv[0]); } @@ -981,7 +981,7 @@ SWITCH_STANDARD_APP(strftime_function) switch_time_exp_t tm; char date[80] = ""; - switch_time_exp_lt(&tm, switch_timestamp_now()); + switch_time_exp_lt(&tm, switch_micro_time_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(switch_core_session_get_channel(session), argv[0], date); @@ -993,7 +993,7 @@ SWITCH_STANDARD_API(strepoch_api_function) switch_time_t out; if (switch_strlen_zero(cmd)) { - out = switch_timestamp_now(); + out = switch_micro_time_now(); } else { out = switch_str_time(cmd); } @@ -1014,7 +1014,7 @@ SWITCH_STANDARD_API(strftime_api_function) thetime = switch_time_make(atoi(cmd), 0); cmd = p + 1; } else { - thetime = switch_timestamp_now(); + thetime = switch_micro_time_now(); } switch_time_exp_lt(&tm, thetime); if (switch_strlen_zero(cmd)) { @@ -1207,12 +1207,12 @@ SWITCH_STANDARD_APP(tone_detect_session_function) uint32_t mto; if (*argv[3] == '+') { if ((mto = atol(argv[3] + 1)) > 0) { - to = switch_timestamp(NULL) + mto; + to = switch_epoch_time_now(NULL) + mto; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n"); } } else { - if ((to = atol(argv[3])) < switch_timestamp(NULL)) { + if ((to = atol(argv[3])) < switch_epoch_time_now(NULL)) { if (to >= 1) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "INVALID Timeout!\n"); } diff --git a/src/mod/applications/mod_enum/mod_enum.c b/src/mod/applications/mod_enum/mod_enum.c index 5a3a3db154..fb80266c77 100644 --- a/src/mod/applications/mod_enum/mod_enum.c +++ b/src/mod/applications/mod_enum/mod_enum.c @@ -531,7 +531,7 @@ static switch_status_t enum_lookup(char *root, char *in, enum_record_t **results tv.tv_sec = i; tv.tv_usec = 0; i = select((int) (fd + 1), &fds, 0, 0, &tv); - now = switch_timestamp(NULL); + now = switch_epoch_time_now(NULL); if (i > 0) { dns_ioevent(nctx, now); } diff --git a/src/mod/applications/mod_esf/mod_esf.c b/src/mod/applications/mod_esf/mod_esf.c index 3240c7acfa..b61552f70a 100644 --- a/src/mod/applications/mod_esf/mod_esf.c +++ b/src/mod/applications/mod_esf/mod_esf.c @@ -205,7 +205,7 @@ SWITCH_STANDARD_APP(bcast_function) } } - control_packet.unique_id = htonl((u_long) switch_timestamp(NULL)); + control_packet.unique_id = htonl((u_long) switch_epoch_time_now(NULL)); control_packet.command = htonl(LS_START_BCAST); control_packet.ip = inet_addr(mcast_ip); control_packet.port = htonl(mcast_port); @@ -233,7 +233,7 @@ SWITCH_STANDARD_APP(bcast_function) } } - control_packet.unique_id = htonl((u_long) switch_timestamp(NULL)); + control_packet.unique_id = htonl((u_long) switch_epoch_time_now(NULL)); control_packet.command = htonl(LS_STOP_BCAST); bytes = 8; switch_socket_sendto(socket, control_packet_addr, 0, (void *) &control_packet, &bytes); diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index 68263a69e1..f536db75db 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -195,7 +195,7 @@ static switch_status_t caller_read_frame_callback(switch_core_session_t *session return SWITCH_STATUS_SUCCESS; } - if (cd->total && switch_timestamp(NULL) >= cd->next) { + if (cd->total && switch_epoch_time_now(NULL) >= cd->next) { if (cd->index == MAX_CHIME || cd->index == cd->total || !cd->list[cd->index]) { cd->index = 0; } @@ -213,10 +213,10 @@ static switch_status_t caller_read_frame_callback(switch_core_session_t *session cd->abort = 1; return SWITCH_STATUS_FALSE; } - cd->next = switch_timestamp(NULL) + cd->freq; + cd->next = switch_epoch_time_now(NULL) + cd->freq; cd->index++; } - } else if (cd->orbit_timeout && switch_timestamp(NULL) >= cd->orbit_timeout) { + } else if (cd->orbit_timeout && switch_epoch_time_now(NULL) >= cd->orbit_timeout) { cd->do_orbit = 1; return SWITCH_STATUS_FALSE; } @@ -418,7 +418,7 @@ static switch_status_t hanguphook(switch_core_session_t *session) if (state == CS_HANGUP || state == CS_ROUTING) { if ((uuid = switch_channel_get_variable(channel, "fifo_outbound_uuid"))) { switch_snprintf(sql, sizeof(sql), "update fifo_outbound set use_count=use_count-1, outbound_call_count=outbound_call_count+1, next_avail=%ld + lag where uuid='%s'", - (long)switch_timestamp(NULL), uuid); + (long)switch_epoch_time_now(NULL), uuid); fifo_execute_sql(sql, globals.sql_mutex); } @@ -451,7 +451,7 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj) if (switch_ivr_originate(NULL, &session, &cause, h->originate_string, h->timeout, NULL, NULL, NULL, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) { switch_snprintf(sql, sizeof(sql), "update fifo_outbound set use_count=use_count-1, outbound_fail_count=outbound_fail_count+1, next_avail=%ld + lag where uuid='%s'", - (long)switch_timestamp(NULL), h->uuid); + (long)switch_epoch_time_now(NULL), h->uuid); fifo_execute_sql(sql, globals.sql_mutex); goto end; } @@ -512,7 +512,7 @@ static void find_consumers(fifo_node_t *node) sql = switch_mprintf("select uuid, fifo_name, originate_string, simo_count, use_count, timeout, lag, " "next_avail, expires, static, outbound_call_count, outbound_fail_count, hostname " "from fifo_outbound where (use_count < simo_count) and (next_avail = 0 or next_avail <= %ld) order by outbound_call_count", - (long) switch_timestamp(NULL)); + (long) switch_epoch_time_now(NULL)); switch_assert(sql); fifo_execute_sql_callback(globals.sql_mutex, sql, place_call_callback, &need); free(sql); @@ -668,7 +668,7 @@ SWITCH_STANDARD_APP(fifo_function) switch_event_t *event = NULL; char date[80] = ""; switch_time_exp_t tm; - switch_time_t ts = switch_timestamp_now(); + switch_time_t ts = switch_micro_time_now(); switch_size_t retsize; char *list_string; int nlist_count; @@ -796,7 +796,7 @@ SWITCH_STANDARD_APP(fifo_function) to = 60; } } - cd.orbit_timeout = switch_timestamp(NULL) + to; + cd.orbit_timeout = switch_epoch_time_now(NULL) + to; } } @@ -823,7 +823,7 @@ SWITCH_STANDARD_APP(fifo_function) } if (!node_consumer_wait_count(node)) { - node->start_waiting = switch_timestamp_now(); + node->start_waiting = switch_micro_time_now(); } if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { @@ -843,7 +843,7 @@ SWITCH_STANDARD_APP(fifo_function) switch_mutex_unlock(node->mutex); - ts = switch_timestamp_now(); + ts = switch_micro_time_now(); switch_time_exp_lt(&tm, ts); switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm); switch_channel_set_variable(channel, "fifo_status", "WAITING"); @@ -856,7 +856,7 @@ SWITCH_STANDARD_APP(fifo_function) char *list_dup = switch_core_session_strdup(session, chime_list); cd.total = switch_separate_string(list_dup, ',', cd.list, (sizeof(cd.list) / sizeof(cd.list[0]))); cd.freq = freq; - cd.next = switch_timestamp(NULL) + cd.freq; + cd.next = switch_epoch_time_now(NULL) + cd.freq; } send_presence(node); @@ -930,7 +930,7 @@ SWITCH_STANDARD_APP(fifo_function) switch_channel_set_state(channel, CS_HIBERNATE); goto done; } else { - ts = switch_timestamp_now(); + ts = switch_micro_time_now(); switch_time_exp_lt(&tm, ts); switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm); switch_channel_set_variable(channel, "fifo_status", cd.do_orbit ? "TIMEOUT" : "ABORTED"); @@ -1027,7 +1027,7 @@ SWITCH_STANDARD_APP(fifo_function) switch_event_fire(&event); } - ts = switch_timestamp_now(); + ts = switch_micro_time_now(); switch_time_exp_lt(&tm, ts); switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm); switch_channel_set_variable(channel, "fifo_status", "WAITING"); @@ -1220,7 +1220,7 @@ SWITCH_STANDARD_APP(fifo_function) switch_assert(cloned_profile->next == NULL); switch_channel_set_originatee_caller_profile(channel, cloned_profile); - ts = switch_timestamp_now(); + ts = switch_micro_time_now(); switch_time_exp_lt(&tm, ts); switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm); switch_channel_set_variable(channel, "fifo_status", "TALKING"); @@ -1251,7 +1251,7 @@ SWITCH_STANDARD_APP(fifo_function) } } - ts = switch_timestamp_now(); + ts = switch_micro_time_now(); switch_time_exp_lt(&tm, ts); switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm); switch_channel_set_variable(channel, "fifo_status", "WAITING"); @@ -1300,7 +1300,7 @@ SWITCH_STANDARD_APP(fifo_function) } if (fifo_consumer_wrapup_time) { - wrapup_time_started = switch_timestamp_now(); + wrapup_time_started = switch_micro_time_now(); } if (!switch_strlen_zero(fifo_consumer_wrapup_key) && strcmp(buf, fifo_consumer_wrapup_key)) { @@ -1308,7 +1308,7 @@ SWITCH_STANDARD_APP(fifo_function) char terminator = 0; if (fifo_consumer_wrapup_time) { - wrapup_time_elapsed = (switch_timestamp_now() - wrapup_time_started) / 1000; + wrapup_time_elapsed = (switch_micro_time_now() - wrapup_time_started) / 1000; if (wrapup_time_elapsed > fifo_consumer_wrapup_time) { break; } else { @@ -1324,7 +1324,7 @@ SWITCH_STANDARD_APP(fifo_function) } } else if (fifo_consumer_wrapup_time && (switch_strlen_zero(fifo_consumer_wrapup_key) || !strcmp(buf, fifo_consumer_wrapup_key))) { while(switch_channel_ready(channel)) { - wrapup_time_elapsed = (switch_timestamp_now() - wrapup_time_started) / 1000; + wrapup_time_elapsed = (switch_micro_time_now() - wrapup_time_started) / 1000; if (wrapup_time_elapsed > fifo_consumer_wrapup_time) { break; } @@ -1949,7 +1949,7 @@ SWITCH_STANDARD_API(fifo_member_api_function) lag = atoi(argv[5]); } if (argc > 6) { - expires = switch_timestamp(NULL) + atoi(argv[6]); + expires = switch_epoch_time_now(NULL) + atoi(argv[6]); } if (simo_count < 0) { simo_count = 1; diff --git a/src/mod/applications/mod_fsv/mod_fsv.c b/src/mod/applications/mod_fsv/mod_fsv.c index 835c675916..9e53a98abe 100644 --- a/src/mod/applications/mod_fsv/mod_fsv.c +++ b/src/mod/applications/mod_fsv/mod_fsv.c @@ -140,7 +140,7 @@ SWITCH_STANDARD_APP(record_fsv_function) vid_codec = switch_core_session_get_video_read_codec(session); h.version = VERSION; - h.created = switch_timestamp_now(); + h.created = switch_micro_time_now(); switch_set_string(h.video_codec_name, vid_codec->implementation->iananame); if (vid_codec->fmtp_in) { switch_set_string(h.video_fmtp, vid_codec->fmtp_in); diff --git a/src/mod/applications/mod_limit/mod_limit.c b/src/mod/applications/mod_limit/mod_limit.c index e752632b33..36f011f66b 100644 --- a/src/mod/applications/mod_limit/mod_limit.c +++ b/src/mod/applications/mod_limit/mod_limit.c @@ -811,7 +811,7 @@ SWITCH_STANDARD_APP(limit_hash_function) char *szinterval = NULL; limit_hash_item_t *item = NULL; switch_channel_t *channel = switch_core_session_get_channel(session); - time_t now = switch_timestamp(NULL); + time_t now = switch_epoch_time_now(NULL); switch_hash_t *channel_hash = NULL; uint8_t increment = 1; uint8_t new_channel = 0; diff --git a/src/mod/applications/mod_rss/mod_rss.c b/src/mod/applications/mod_rss/mod_rss.c index ff55d98efa..64587d2c53 100644 --- a/src/mod/applications/mod_rss/mod_rss.c +++ b/src/mod/applications/mod_rss/mod_rss.c @@ -478,7 +478,7 @@ SWITCH_STANDARD_APP(rss_function) switch_size_t retsize; char dtmf[5] = ""; - switch_time_exp_lt(&tm, switch_timestamp_now()); + switch_time_exp_lt(&tm, switch_micro_time_now()); switch_strftime_nocheck(date, &retsize, sizeof(date), "%I:%M %p", &tm); diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index 353c50dba3..703906578c 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -1767,7 +1767,7 @@ static void voicemail_check_main(switch_core_session_t *session, const char *pro } } switch_snprintf(sql, sizeof(sql), "update voicemail_msgs set read_epoch=%ld where username='%s' and domain='%s' and flags='save'", - (long) switch_timestamp(NULL), myid, domain_name); + (long) switch_epoch_time_now(NULL), myid, domain_name); vm_execute_sql(profile, sql, profile->mutex); switch_snprintf(sql, sizeof(sql), "select file_path from voicemail_msgs where username='%s' and domain='%s' and flags='delete'", myid, domain_name); @@ -2309,11 +2309,11 @@ static switch_status_t deliver_vm(vm_profile_t *profile, switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "VM-Flags", read_flags); switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "VM-Folder", myfolder); switch_event_add_header(message_event, SWITCH_STACK_BOTTOM, "VM-Message-Len", "%u", message_len); - switch_event_add_header(message_event, SWITCH_STACK_BOTTOM, "VM-Timestamp", "%lu", (unsigned long) switch_timestamp(NULL)); + switch_event_add_header(message_event, SWITCH_STACK_BOTTOM, "VM-Timestamp", "%lu", (unsigned long) switch_epoch_time_now(NULL)); switch_event_fire(&message_event); - usql = switch_mprintf("insert into voicemail_msgs values(%ld,0,'%q','%q','%q','%q','%q','%q','%q','%u','','%q')", (long) switch_timestamp(NULL), + usql = switch_mprintf("insert into voicemail_msgs values(%ld,0,'%q','%q','%q','%q','%q','%q','%q','%u','','%q')", (long) switch_epoch_time_now(NULL), myid, domain_name, uuid_str, caller_id_name, caller_id_number, myfolder, file_path, message_len, read_flags); @@ -2346,7 +2346,7 @@ static switch_status_t deliver_vm(vm_profile_t *profile, &total_new_urgent_messages, &total_saved_urgent_messages); if (switch_strlen_zero(vm_timezone) || (switch_strftime_tz(vm_timezone, profile->date_fmt, date, sizeof(date), 0) != SWITCH_STATUS_SUCCESS)) { - switch_time_exp_lt(&tm, switch_timestamp_now()); + switch_time_exp_lt(&tm, switch_micro_time_now()); switch_strftime(date, &retsize, sizeof(date), profile->date_fmt, &tm); } @@ -2696,7 +2696,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, cons switch_time_exp_t tm; char date[80] = ""; switch_size_t retsize; - switch_time_t ts = switch_timestamp_now(); + switch_time_t ts = switch_micro_time_now(); char *dbuf = NULL; char *vm_storage_dir = NULL; char *record_macro = VM_RECORD_MESSAGE_MACRO; @@ -3271,7 +3271,7 @@ static void do_play(vm_profile_t *profile, char *user, char *domain, char *file, struct holder holder; sql = switch_mprintf("update voicemail_msgs set read_epoch=%ld where username='%s' and domain='%s' and file_path like '%%%s'", - (long) switch_timestamp(NULL), user, domain, file); + (long) switch_epoch_time_now(NULL), user, domain, file); vm_execute_sql(profile, sql, profile->mutex); free(sql); diff --git a/src/mod/endpoints/mod_alsa/mod_alsa.c b/src/mod/endpoints/mod_alsa/mod_alsa.c index ea2d9d85bd..9a00993e6c 100644 --- a/src/mod/endpoints/mod_alsa/mod_alsa.c +++ b/src/mod/endpoints/mod_alsa/mod_alsa.c @@ -180,7 +180,7 @@ static switch_status_t channel_on_init(switch_core_session_t *session) assert(channel != NULL); - last = switch_timestamp_now() - waitsec; + last = switch_micro_time_now() - waitsec; @@ -243,7 +243,7 @@ static switch_status_t channel_on_init(switch_core_session_t *session) switch_channel_mark_ring_ready(channel); while (switch_channel_get_state(channel) == CS_INIT && !switch_test_flag(tech_pvt, TFLAG_ANSWER)) { - if (switch_timestamp_now() - last >= waitsec) { + if (switch_micro_time_now() - last >= waitsec) { char buf[512]; switch_event_t *event; @@ -257,7 +257,7 @@ static switch_status_t channel_on_init(switch_core_session_t *session) } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s\n", buf); - last = switch_timestamp_now(); + last = switch_micro_time_now(); if (ring_file) { unsigned int pos = 0; switch_core_file_seek(&fh, &pos, 0, SEEK_SET); diff --git a/src/mod/endpoints/mod_dingaling/mod_dingaling.c b/src/mod/endpoints/mod_dingaling/mod_dingaling.c index b16087bd18..6ffd64c79f 100644 --- a/src/mod/endpoints/mod_dingaling/mod_dingaling.c +++ b/src/mod/endpoints/mod_dingaling/mod_dingaling.c @@ -1070,7 +1070,7 @@ static switch_status_t negotiate_media(switch_core_session_t *session) switch_set_flag_locked(tech_pvt, TFLAG_IO); - started = switch_timestamp_now(); + started = switch_micro_time_now(); /* jingle has no ringing indication so we will just pretend that we got one */ switch_core_session_queue_indication(session, SWITCH_MESSAGE_INDICATE_RINGING); @@ -1088,7 +1088,7 @@ static switch_status_t negotiate_media(switch_core_session_t *session) switch_test_flag(tech_pvt, TFLAG_RTP_READY) && switch_test_flag(tech_pvt, TFLAG_ANSWER) && switch_test_flag(tech_pvt, TFLAG_TRANSPORT_ACCEPT) && tech_pvt->remote_ip && tech_pvt->remote_port && switch_test_flag(tech_pvt, TFLAG_TRANSPORT))) { - now = switch_timestamp_now(); + now = switch_micro_time_now(); elapsed = (unsigned int) ((now - started) / 1000); if (switch_channel_get_state(channel) >= CS_HANGUP || switch_test_flag(tech_pvt, TFLAG_BYE)) { @@ -1340,7 +1340,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch #if 0 if (tech_pvt->last_read) { - elapsed = (unsigned int) ((switch_timestamp_now() - tech_pvt->last_read) / 1000); + elapsed = (unsigned int) ((switch_micro_time_now() - tech_pvt->last_read) / 1000); if (elapsed > 60000) { return SWITCH_STATUS_TIMEOUT; } @@ -1368,7 +1368,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch payload = tech_pvt->read_frame.payload; #if 0 - elapsed = (unsigned int) ((switch_timestamp_now() - started) / 1000); + elapsed = (unsigned int) ((switch_micro_time_now() - started) / 1000); if (timeout > -1) { if (elapsed >= (unsigned int) timeout) { @@ -1376,7 +1376,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch } } - elapsed = (unsigned int) ((switch_timestamp_now() - last_act) / 1000); + elapsed = (unsigned int) ((switch_micro_time_now() - last_act) / 1000); if (elapsed >= hard_timeout) { return SWITCH_STATUS_BREAK; } diff --git a/src/mod/endpoints/mod_portaudio/mod_portaudio.c b/src/mod/endpoints/mod_portaudio/mod_portaudio.c index 41811ae107..24c252f7f8 100644 --- a/src/mod/endpoints/mod_portaudio/mod_portaudio.c +++ b/src/mod/endpoints/mod_portaudio/mod_portaudio.c @@ -182,7 +182,7 @@ static switch_status_t channel_on_init(switch_core_session_t *session) switch_assert(tech_pvt != NULL); - last = switch_timestamp_now() - waitsec; + last = switch_micro_time_now() - waitsec; if ((val = switch_channel_get_variable(channel, "pa_hold_file"))) { hold_file = val; @@ -251,7 +251,7 @@ static switch_status_t channel_on_init(switch_core_session_t *session) while (switch_channel_get_state(channel) == CS_INIT && !switch_test_flag(tech_pvt, TFLAG_ANSWER)) { switch_size_t olen = globals.timer.samples; - if (switch_timestamp_now() - last >= waitsec) { + if (switch_micro_time_now() - last >= waitsec) { char buf[512]; switch_event_t *event; @@ -264,7 +264,7 @@ static switch_status_t channel_on_init(switch_core_session_t *session) switch_event_fire(&event); } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s\n", buf); - last = switch_timestamp_now(); + last = switch_micro_time_now(); } if (ring_file) { @@ -449,7 +449,7 @@ static void remove_pvt(private_t *tech_pvt) if (globals.call_list) { switch_set_flag_locked(globals.call_list, TFLAG_MASTER); } else { - globals.deactivate_timer = switch_timestamp(NULL) + 2; + globals.deactivate_timer = switch_epoch_time_now(NULL) + 2; deactivate_audio_device(); } @@ -1259,7 +1259,7 @@ static switch_status_t engage_device(int restart) int codec_ms = globals.codec_ms; switch_mutex_lock(globals.device_lock); - while (globals.deactivate_timer > switch_timestamp(NULL)) { + while (globals.deactivate_timer > switch_epoch_time_now(NULL)) { switch_yield(1000000); } switch_mutex_unlock(globals.device_lock); diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 891120efb6..793fd1ee9b 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -1650,7 +1650,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) { - time_t now = switch_timestamp(NULL); + time_t now = switch_epoch_time_now(NULL); if (gp->retry > now) { stream->write_function(stream, " (retry: %ds)", gp->retry - now); } else { @@ -1842,7 +1842,7 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl switch_assert(gp->state < REG_STATE_LAST); stream->write_function(stream, "\n%s\n%s\n%s\n%s\n\n", gp->name, "gateway", gp->register_to, sofia_state_names[gp->state]); if (gp->state == REG_STATE_FAILED || gp->state == REG_STATE_TRYING) { - time_t now = switch_timestamp(NULL); + time_t now = switch_epoch_time_now(NULL); if (gp->retry > now) { stream->write_function(stream, " (retry: %ds)", gp->retry - now); } else { @@ -2042,7 +2042,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 = 10; - int diff = (int) (switch_timestamp(NULL) - profile->started); + int diff = (int) (switch_epoch_time_now(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", diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 914003b6b1..07bff10657 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -284,11 +284,11 @@ void sofia_handle_sip_r_message(int status, sofia_profile_t *profile, nua_handle void sofia_wait_for_reply(struct private_object *tech_pvt, nua_event_t event, uint32_t timeout) { - time_t exp = switch_timestamp(NULL) + timeout; + time_t exp = switch_epoch_time_now(NULL) + timeout; tech_pvt->want_event = event; - while(switch_channel_ready(tech_pvt->channel) && tech_pvt->want_event && switch_timestamp(NULL) < exp) { + while(switch_channel_ready(tech_pvt->channel) && tech_pvt->want_event && switch_epoch_time_now(NULL) < exp) { switch_yield(100000); } @@ -522,7 +522,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) switch_timestamp(NULL); + long expires = (long) switch_epoch_time_now(NULL); char *profile_name = switch_event_get_header(event, "orig-profile-name"); char *to_user = switch_event_get_header(event, "orig-to-user"); char *presence_hosts = switch_event_get_header(event, "presence-hosts"); @@ -601,12 +601,12 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread if (++loops >= 100) { if (++ireg_loops >= IREG_SECONDS) { - sofia_reg_check_expire(profile, switch_timestamp(NULL), 0); + sofia_reg_check_expire(profile, switch_epoch_time_now(NULL), 0); ireg_loops = 0; } if (++gateway_loops >= GATEWAY_SECONDS) { - sofia_reg_check_gateway(profile, switch_timestamp(NULL)); + sofia_reg_check_gateway(profile, switch_epoch_time_now(NULL)); gateway_loops = 0; } sofia_sub_check_gateway(profile, time(NULL)); @@ -778,7 +778,7 @@ 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 = switch_timestamp(NULL); + profile->started = switch_epoch_time_now(NULL); sofia_set_pflag_locked(profile, PFLAG_RUNNING); launch_sofia_worker_thread(profile); @@ -1104,7 +1104,7 @@ static void parse_gateways(sofia_profile_t *profile, switch_xml_t gateways_tag) if (ping_freq) { if (ping_freq >= 5) { gateway->ping_freq = ping_freq; - gateway->ping = switch_timestamp(NULL) + ping_freq; + gateway->ping = switch_epoch_time_now(NULL) + ping_freq; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "ERROR: invalid ping!\n"); } @@ -2350,12 +2350,12 @@ static void sofia_handle_sip_r_options(switch_core_session_t *session, int statu gateway->state = REG_STATE_FAILED; } } - gateway->ping = switch_timestamp(NULL) + gateway->ping_freq; + gateway->ping = switch_epoch_time_now(NULL) + gateway->ping_freq; sofia_reg_release_gateway(gateway); gateway->pinging = 0; } else if ((profile->pflags & PFLAG_UNREG_OPTIONS_FAIL) && status != 200 && sip && sip->sip_to) { char *sql; - time_t now = switch_timestamp(NULL); + time_t now = switch_epoch_time_now(NULL); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Expire registration '%s@%s' due to options failure\n", sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host); diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index bcaecf7f7f..ba2f33aa94 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -55,7 +55,7 @@ void sofia_glue_set_image_sdp(private_object_t *tech_pvt, switch_t38_options_t * } if (!tech_pvt->owner_id) { - tech_pvt->owner_id = (uint32_t) switch_timestamp(NULL) - port; + tech_pvt->owner_id = (uint32_t) switch_epoch_time_now(NULL) - port; } if (!tech_pvt->session_id) { @@ -145,7 +145,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) switch_timestamp(NULL) - port; + tech_pvt->owner_id = (uint32_t) switch_epoch_time_now(NULL) - port; } if (!tech_pvt->session_id) { @@ -2902,7 +2902,7 @@ void sofia_glue_restart_all_profiles(void) switch_hash_this(hi, &var, NULL, &val); if ((pptr = (sofia_profile_t *) val)) { int rsec = 10; - int diff = (int) (switch_timestamp(NULL) - pptr->started); + int diff = (int) (switch_epoch_time_now(NULL) - pptr->started); int remain = rsec - diff; if (sofia_test_pflag(pptr, PFLAG_RESPAWN) || !sofia_test_pflag(pptr, PFLAG_RUNNING)) { continue; diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index b75511c008..7a424f6885 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -946,7 +946,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * char *open; char *prpid; const char *ct = "no/idea"; - time_t exptime = switch_timestamp(NULL) + 3600; + time_t exptime = switch_epoch_time_now(NULL) + 3600; int is_dialog = 0; sofia_profile_t *ext_profile = NULL, *profile = helper->profile; char sstr[128] = ""; @@ -990,7 +990,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * if (expires) { long tmp = atol(expires); if (tmp > 0) { - exptime = tmp - switch_timestamp(NULL) - SUB_OVERLAP; + exptime = tmp - switch_epoch_time_now(NULL) - SUB_OVERLAP; } else { exptime = tmp; } @@ -1281,7 +1281,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 - switch_timestamp(NULL)); + expire_sec = (int) (expire_sec - switch_epoch_time_now(NULL)); if (expire_sec < 0) { expire_sec = 3600; } @@ -1585,7 +1585,7 @@ void sofia_presence_handle_sip_i_subscribe(int status, exp_delta = profile->force_subscription_expires ? profile->force_subscription_expires : (sip->sip_expires ? sip->sip_expires->ex_delta : 3600); if (exp_delta) { - exp_abs = (long) switch_timestamp(NULL) + exp_delta; + exp_abs = (long) switch_epoch_time_now(NULL) + exp_delta; } else { exp_abs = 0; sub_state = nua_substate_terminated; @@ -1859,7 +1859,7 @@ void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, n } exp_delta = (sip->sip_expires ? sip->sip_expires->ex_delta : 3600); - exp = (long) switch_timestamp(NULL) + exp_delta; + exp = (long) switch_epoch_time_now(NULL) + exp_delta; if ((sql = switch_mprintf("delete from sip_presence where sip_user='%q' and sip_host='%q' " diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 3c59dab062..557bb867a2 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -612,7 +612,7 @@ void sofia_reg_auth_challenge(nua_t *nua, sofia_profile_t *profile, nua_handle_t switch_uuid_format(uuid_str, &uuid); sql = switch_mprintf("insert into sip_authentication (nonce,expires,profile_name,hostname) " - "values('%q', %ld, '%q', '%q')", uuid_str, switch_timestamp(NULL) + profile->nonce_ttl, profile->name, mod_sofia_globals.hostname); + "values('%q', %ld, '%q', '%q')", uuid_str, switch_epoch_time_now(NULL) + profile->nonce_ttl, profile->name, mod_sofia_globals.hostname); switch_assert(sql != NULL); sofia_glue_actually_execute_sql(profile, SWITCH_FALSE, sql, profile->ireg_mutex); switch_safe_free(sql); @@ -940,7 +940,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand "(call_id,sip_user,sip_host,presence_hosts,contact,status,rpid,expires,user_agent,server_user,server_host,profile_name,hostname) " "values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q')", call_id, to_user, reg_host, profile->presence_hosts ? profile->presence_hosts : reg_host, - contact_str, reg_desc, rpid, (long) switch_timestamp(NULL) + (long) exptime * 2, + contact_str, reg_desc, rpid, (long) switch_epoch_time_now(NULL) + (long) exptime * 2, agent, from_user, guess_ip4, profile->name, mod_sofia_globals.hostname); if (sql) { @@ -1091,7 +1091,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand } } - switch_rfc822_date(date, switch_timestamp_now()); + switch_rfc822_date(date, switch_micro_time_now()); nua_respond(nh, SIP_200_OK, SIPTAG_CONTACT(sip->sip_contact), TAG_IF(path_val, SIPTAG_PATH_STR(path_val)), NUTAG_WITH_THIS(nua), diff --git a/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c b/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c index d570ca599f..178e9307a8 100644 --- a/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c +++ b/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c @@ -99,7 +99,7 @@ static void do_rotate(cdr_fd_t *fd) fd->fd = -1; if (globals.rotate) { - switch_time_exp_lt(&tm, switch_timestamp_now()); + switch_time_exp_lt(&tm, switch_micro_time_now()); switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d-%H-%M-%S", &tm); len = strlen(fd->path) + strlen(date) + 2; diff --git a/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c b/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c index 684143b66d..0a632ba178 100644 --- a/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c +++ b/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c @@ -196,7 +196,7 @@ static void event_handler(switch_event_t *event) continue; } - if (switch_test_flag(l, LFLAG_STATEFUL) && l->timeout && switch_timestamp(NULL) - l->last_flush > l->timeout) { + if (switch_test_flag(l, LFLAG_STATEFUL) && l->timeout && switch_epoch_time_now(NULL) - l->last_flush > l->timeout) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Stateful Listener %u has expired\n", l->id); remove_listener(l); expire_listener(&l); diff --git a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c index c3ae1dfedd..b7ceea41c8 100644 --- a/src/mod/event_handlers/mod_event_socket/mod_event_socket.c +++ b/src/mod/event_handlers/mod_event_socket/mod_event_socket.c @@ -231,7 +231,7 @@ static void event_handler(switch_event_t *event) continue; } - if (switch_test_flag(l, LFLAG_STATEFUL) && l->timeout && switch_timestamp(NULL) - l->last_flush > l->timeout) { + if (switch_test_flag(l, LFLAG_STATEFUL) && l->timeout && switch_epoch_time_now(NULL) - l->last_flush > l->timeout) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Stateful Listener %u has expired\n", l->id); remove_listener(l); expire_listener(&l); @@ -718,7 +718,7 @@ SWITCH_STANDARD_API(event_sink_function) switch_thread_rwlock_create(&listener->rwlock, listener->pool); listener->id = next_id(); listener->timeout = 60; - listener->last_flush = switch_timestamp(NULL); + listener->last_flush = switch_epoch_time_now(NULL); if (events) { char delim = ','; @@ -820,7 +820,7 @@ SWITCH_STANDARD_API(event_sink_function) goto end; } - listener->last_flush = switch_timestamp(NULL); + listener->last_flush = switch_epoch_time_now(NULL); stream->write_function(stream, "\n Current Events Follow\n"); xmlize_listener(listener, stream); @@ -963,7 +963,7 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event, int clen = 0; *event = NULL; - start = switch_timestamp(NULL); + start = switch_epoch_time_now(NULL); ptr = mbuf; @@ -1074,7 +1074,7 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event, } if (timeout) { - elapsed = (uint32_t) (switch_timestamp(NULL) - start); + elapsed = (uint32_t) (switch_epoch_time_now(NULL) - start); if (elapsed >= timeout) { switch_clear_flag_locked(listener, LFLAG_RUNNING); return SWITCH_STATUS_FALSE; diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c index 9912ead2e2..24acf847c2 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c @@ -2118,7 +2118,7 @@ static JSBool session_wait_for_media(JSContext * cx, JSObject * obj, uintN argc, channel = switch_core_session_get_channel(jss->session); CHANNEL_MEDIA_SANITY_CHECK(); - started = switch_timestamp_now(); + started = switch_micro_time_now(); if (argc > 0) { JS_ValueToInt32(cx, argv[0], &timeout); @@ -2132,7 +2132,7 @@ static JSBool session_wait_for_media(JSContext * cx, JSObject * obj, uintN argc, } saveDepth = JS_SuspendRequest(cx); for (;;) { - if (((elapsed = (unsigned int) ((switch_timestamp_now() - started) / 1000)) > (switch_time_t) timeout) + if (((elapsed = (unsigned int) ((switch_micro_time_now() - started) / 1000)) > (switch_time_t) timeout) || switch_channel_get_state(channel) >= CS_HANGUP) { *rval = BOOLEAN_TO_JSVAL(JS_FALSE); break; @@ -2165,7 +2165,7 @@ static JSBool session_wait_for_answer(JSContext * cx, JSObject * obj, uintN argc METHOD_SANITY_CHECK(); channel = switch_core_session_get_channel(jss->session); - started = switch_timestamp_now(); + started = switch_micro_time_now(); if (argc > 0) { JS_ValueToInt32(cx, argv[0], &timeout); @@ -2180,7 +2180,7 @@ static JSBool session_wait_for_answer(JSContext * cx, JSObject * obj, uintN argc saveDepth = JS_SuspendRequest(cx); for (;;) { - if (((elapsed = (unsigned int) ((switch_timestamp_now() - started) / 1000)) > (switch_time_t) timeout) + if (((elapsed = (unsigned int) ((switch_micro_time_now() - started) / 1000)) > (switch_time_t) timeout) || switch_channel_get_state(channel) >= CS_HANGUP) { *rval = BOOLEAN_TO_JSVAL(JS_FALSE); break; diff --git a/src/mod/loggers/mod_logfile/mod_logfile.c b/src/mod/loggers/mod_logfile/mod_logfile.c index 2de93808d1..ab66c0c489 100644 --- a/src/mod/loggers/mod_logfile/mod_logfile.c +++ b/src/mod/loggers/mod_logfile/mod_logfile.c @@ -124,7 +124,7 @@ static switch_status_t mod_logfile_rotate(logfile_profile_t *profile) switch_mutex_lock(globals.mutex); - switch_time_exp_lt(&tm, switch_timestamp_now()); + switch_time_exp_lt(&tm, switch_micro_time_now()); switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d-%H-%M-%S", &tm); profile->log_size = 0; diff --git a/src/mod/say/mod_say_de/mod_say_de.c b/src/mod/say/mod_say_de/mod_say_de.c index b3ad8e5472..1ece47e940 100644 --- a/src/mod/say/mod_say_de/mod_say_de.c +++ b/src/mod/say/mod_say_de/mod_say_de.c @@ -303,7 +303,7 @@ static switch_status_t de_say_time(switch_core_session_t *session, char *tosay, } } else { if ((seconds = atoi(tosay)) <= 0) { - seconds = (int64_t) switch_timestamp(NULL); + seconds = (int64_t) switch_epoch_time_now(NULL); } if (seconds >= 60) { @@ -361,7 +361,7 @@ static switch_status_t de_say_time(switch_core_session_t *session, char *tosay, if ((t = atoi(tosay)) > 0) { target = switch_time_make(t, 0); } else { - target = switch_timestamp_now(); + target = switch_micro_time_now(); } switch_time_exp_lt(&tm, target); diff --git a/src/mod/say/mod_say_en/mod_say_en.c b/src/mod/say/mod_say_en/mod_say_en.c index 9906d201f0..46a4d8166a 100644 --- a/src/mod/say/mod_say_en/mod_say_en.c +++ b/src/mod/say/mod_say_en/mod_say_en.c @@ -294,7 +294,7 @@ static switch_status_t en_say_time(switch_core_session_t *session, char *tosay, } } else { if ((seconds = atol(tosay)) <= 0) { - seconds = (int64_t) switch_timestamp(NULL); + seconds = (int64_t) switch_epoch_time_now(NULL); } if (seconds >= 60) { @@ -352,7 +352,7 @@ static switch_status_t en_say_time(switch_core_session_t *session, char *tosay, if ((t = atol(tosay)) > 0) { target = switch_time_make(t, 0); } else { - target = switch_timestamp_now(); + target = switch_micro_time_now(); } if (tz) { diff --git a/src/mod/say/mod_say_es/mod_say_es.c b/src/mod/say/mod_say_es/mod_say_es.c index dea585740d..88b8c51496 100644 --- a/src/mod/say/mod_say_es/mod_say_es.c +++ b/src/mod/say/mod_say_es/mod_say_es.c @@ -292,7 +292,7 @@ static switch_status_t es_say_time(switch_core_session_t *session, char *tosay, } } else { if ((seconds = atoi(tosay)) <= 0) { - seconds = (int64_t) switch_timestamp(NULL); + seconds = (int64_t) switch_epoch_time_now(NULL); } if (seconds >= 60) { @@ -350,7 +350,7 @@ static switch_status_t es_say_time(switch_core_session_t *session, char *tosay, if ((t = atoi(tosay)) > 0) { target = switch_time_make(t, 0); } else { - target = switch_timestamp_now(); + target = switch_micro_time_now(); } switch_time_exp_lt(&tm, target); diff --git a/src/mod/say/mod_say_fr/mod_say_fr.c b/src/mod/say/mod_say_fr/mod_say_fr.c index 32304a4464..b94e60999e 100644 --- a/src/mod/say/mod_say_fr/mod_say_fr.c +++ b/src/mod/say/mod_say_fr/mod_say_fr.c @@ -292,7 +292,7 @@ static switch_status_t fr_say_time(switch_core_session_t *session, char *tosay, } } else { if ((seconds = atoi(tosay)) <= 0) { - seconds = (int64_t) switch_timestamp(NULL); + seconds = (int64_t) switch_epoch_time_now(NULL); } if (seconds >= 60) { @@ -350,7 +350,7 @@ static switch_status_t fr_say_time(switch_core_session_t *session, char *tosay, if ((t = atoi(tosay)) > 0) { target = switch_time_make(t, 0); } else { - target = switch_timestamp_now(); + target = switch_micro_time_now(); } switch_time_exp_lt(&tm, target); diff --git a/src/mod/say/mod_say_it/mod_say_it.c b/src/mod/say/mod_say_it/mod_say_it.c index b1bb4d0f47..74d16bc58c 100644 --- a/src/mod/say/mod_say_it/mod_say_it.c +++ b/src/mod/say/mod_say_it/mod_say_it.c @@ -292,7 +292,7 @@ static switch_status_t it_say_time(switch_core_session_t *session, char *tosay, } } else { if ((seconds = atoi(tosay)) <= 0) { - seconds = (int64_t) switch_timestamp(NULL); + seconds = (int64_t) switch_epoch_time_now(NULL); } if (seconds >= 60) { @@ -350,7 +350,7 @@ static switch_status_t it_say_time(switch_core_session_t *session, char *tosay, if ((t = atoi(tosay)) > 0) { target = switch_time_make(t, 0); } else { - target = switch_timestamp_now(); + target = switch_micro_time_now(); } switch_time_exp_lt(&tm, target); diff --git a/src/mod/say/mod_say_nl/mod_say_nl.c b/src/mod/say/mod_say_nl/mod_say_nl.c index 6342015351..f7a009a517 100644 --- a/src/mod/say/mod_say_nl/mod_say_nl.c +++ b/src/mod/say/mod_say_nl/mod_say_nl.c @@ -292,7 +292,7 @@ static switch_status_t nl_say_time(switch_core_session_t *session, char *tosay, } } else { if ((seconds = atoi(tosay)) <= 0) { - seconds = (int64_t) switch_timestamp(NULL); + seconds = (int64_t) switch_epoch_time_now(NULL); } if (seconds >= 60) { @@ -350,7 +350,7 @@ static switch_status_t nl_say_time(switch_core_session_t *session, char *tosay, if ((t = atoi(tosay)) > 0) { target = switch_time_make(t, 0); } else { - target = switch_timestamp_now(); + target = switch_micro_time_now(); } switch_time_exp_lt(&tm, target); diff --git a/src/mod/say/mod_say_zh/mod_say_zh.c b/src/mod/say/mod_say_zh/mod_say_zh.c index 49647508d2..b6bc39dc97 100644 --- a/src/mod/say/mod_say_zh/mod_say_zh.c +++ b/src/mod/say/mod_say_zh/mod_say_zh.c @@ -367,7 +367,7 @@ static switch_status_t zh_say_time(switch_core_session_t *session, } } else { if ((seconds = atoi(tosay)) <= 0) { - seconds = (int64_t) switch_timestamp(NULL); + seconds = (int64_t) switch_epoch_time_now(NULL); } if (seconds >= 60) { @@ -425,7 +425,7 @@ static switch_status_t zh_say_time(switch_core_session_t *session, if ((t = atoi(tosay)) > 0) target = switch_time_make(t, 0); else - target = switch_timestamp_now(); + target = switch_micro_time_now(); switch_time_exp_lt(&tm, target); switch (type) { @@ -455,7 +455,7 @@ static switch_status_t zh_say_time(switch_core_session_t *session, #if 0 tm = *localtime(&then); - this_morning = switch_timestamp_now(); + this_morning = switch_micro_time_now(); switch_time_exp_lt(&tm2, this_morning); tm2->tm_hour = 0; tm2->tm_min = 0; diff --git a/src/switch_channel.c b/src/switch_channel.c index 18cfaa0fb4..236f166921 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -1328,7 +1328,7 @@ SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel_t *channel } caller_profile->times = (switch_channel_timetable_t *) switch_core_session_alloc(channel->session, sizeof(*caller_profile->times)); - caller_profile->times->profile_created = switch_timestamp_now(); + caller_profile->times->profile_created = switch_micro_time_now(); if (channel->caller_profile && channel->caller_profile->times) { channel->caller_profile->times->transferred = caller_profile->times->profile_created; @@ -1341,7 +1341,7 @@ SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel_t *channel switch_caller_extension_clone(&caller_profile->caller_extension, channel->caller_profile->caller_extension, caller_profile->pool); } } else { - caller_profile->times->created = switch_timestamp_now(); + caller_profile->times->created = switch_micro_time_now(); } caller_profile->next = channel->caller_profile; @@ -1534,7 +1534,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_hangup(switch_chan if (channel->caller_profile && channel->caller_profile->times && !channel->caller_profile->times->hungup) { switch_mutex_lock(channel->profile_mutex); - channel->caller_profile->times->hungup = switch_timestamp_now(); + channel->caller_profile->times->hungup = switch_micro_time_now(); switch_mutex_unlock(channel->profile_mutex); } @@ -1580,7 +1580,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready(switch_ch switch_channel_set_flag(channel, CF_RING_READY); if (channel->caller_profile && channel->caller_profile->times) { switch_mutex_lock(channel->profile_mutex); - channel->caller_profile->times->progress = switch_timestamp_now(); + channel->caller_profile->times->progress = switch_micro_time_now(); if (channel->caller_profile->originator_caller_profile) { switch_core_session_t *other_session; if ((other_session = switch_core_session_locate(channel->caller_profile->originator_caller_profile->uuid))) { @@ -1638,7 +1638,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_pre_answered(switch_ if (channel->caller_profile && channel->caller_profile->times) { switch_mutex_lock(channel->profile_mutex); - channel->caller_profile->times->progress_media = switch_timestamp_now(); + channel->caller_profile->times->progress_media = switch_micro_time_now(); if (channel->caller_profile->originator_caller_profile) { switch_core_session_t *osession; if ((osession = switch_core_session_locate(channel->caller_profile->originator_caller_profile->uuid))) { @@ -1756,7 +1756,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_chan if (channel->caller_profile && channel->caller_profile->times) { switch_mutex_lock(channel->profile_mutex); - channel->caller_profile->times->answered = switch_timestamp_now(); + channel->caller_profile->times->answered = switch_micro_time_now(); switch_mutex_unlock(channel->profile_mutex); } diff --git a/src/switch_console.c b/src/switch_console.c index bde9ecc499..70f7d71c2a 100644 --- a/src/switch_console.c +++ b/src/switch_console.c @@ -296,7 +296,7 @@ SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, const goto done; } - switch_time_exp_lt(&tm, switch_timestamp_now()); + switch_time_exp_lt(&tm, switch_micro_time_now()); switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm); if (channel == SWITCH_CHANNEL_ID_LOG) { diff --git a/src/switch_core.c b/src/switch_core.c index e7348c72c3..dc42e72c50 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -136,7 +136,7 @@ SWITCH_STANDARD_SCHED_FUNC(heartbeat_callback) check_ip(); /* reschedule this task */ - task->runtime = switch_timestamp(NULL) + 20; + task->runtime = switch_epoch_time_now(NULL) + 20; } @@ -1088,7 +1088,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc switch_scheduler_task_thread_start(); runtime.initiated = switch_time_now(); - switch_scheduler_add_task(switch_timestamp(NULL), heartbeat_callback, "heartbeat", "core", 0, NULL, SSHF_NONE | SSHF_NO_DEL); + switch_scheduler_add_task(switch_epoch_time_now(NULL), heartbeat_callback, "heartbeat", "core", 0, NULL, SSHF_NONE | SSHF_NO_DEL); switch_uuid_get(&uuid); switch_uuid_format(runtime.uuid_str, &uuid); @@ -1323,7 +1323,7 @@ SWITCH_DECLARE(void) switch_core_measure_time(switch_time_t total_ms, switch_cor SWITCH_DECLARE(switch_time_t) switch_core_uptime(void) { - return switch_timestamp_now() - runtime.initiated; + return switch_micro_time_now() - runtime.initiated; } SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, int32_t *val) diff --git a/src/switch_core_io.c b/src/switch_core_io.c index bcc24c589f..0a87092e0f 100644 --- a/src/switch_core_io.c +++ b/src/switch_core_io.c @@ -353,7 +353,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi } } - if (bp->stop_time && bp->stop_time <= switch_timestamp(NULL)) { + if (bp->stop_time && bp->stop_time <= switch_epoch_time_now(NULL)) { ok = SWITCH_FALSE; } @@ -502,7 +502,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi switch_mutex_lock(bp->read_mutex); if (bp->callback) { if (bp->callback(bp, bp->user_data, SWITCH_ABC_TYPE_READ_PING) == SWITCH_FALSE - || (bp->stop_time && bp->stop_time <= switch_timestamp(NULL))) { + || (bp->stop_time && bp->stop_time <= switch_epoch_time_now(NULL))) { ok = SWITCH_FALSE; } } @@ -775,7 +775,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess } } - if (bp->stop_time && bp->stop_time <= switch_timestamp(NULL)) { + if (bp->stop_time && bp->stop_time <= switch_epoch_time_now(NULL)) { ok = SWITCH_FALSE; } diff --git a/src/switch_core_port_allocator.c b/src/switch_core_port_allocator.c index c4c3510587..ce84ac2a93 100644 --- a/src/switch_core_port_allocator.c +++ b/src/switch_core_port_allocator.c @@ -118,7 +118,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_port_allocator_request_port(switch_c int odd = switch_test_flag(alloc, SPF_ODD); switch_mutex_lock(alloc->mutex); - srand(getpid() + (unsigned) switch_timestamp(NULL)); + srand(getpid() + (unsigned) switch_epoch_time_now(NULL)); while (alloc->track_used < alloc->track_len) { uint32_t index; diff --git a/src/switch_core_session.c b/src/switch_core_session.c index f67d6a162d..8efd0bf4b7 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -874,7 +874,7 @@ SWITCH_STANDARD_SCHED_FUNC(sch_heartbeat_callback) switch_event_fire(&event); /* reschedule this task */ - task->runtime = switch_timestamp(NULL) + session->track_duration; + task->runtime = switch_epoch_time_now(NULL) + session->track_duration; switch_core_session_rwunlock(session); } @@ -892,7 +892,7 @@ SWITCH_DECLARE(void) switch_core_session_sched_heartbeat(switch_core_session_t * { switch_core_session_unsched_heartbeat(session); - session->track_id = switch_scheduler_add_task(switch_timestamp(NULL), sch_heartbeat_callback, (char *) __SWITCH_FUNC__, + session->track_id = switch_scheduler_add_task(switch_epoch_time_now(NULL), sch_heartbeat_callback, (char *) __SWITCH_FUNC__, switch_core_session_get_uuid(session), 0, strdup(switch_core_session_get_uuid(session)), SSHF_FREE_ARG); } diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index acac6b1f89..de64e9a819 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -278,7 +278,7 @@ static void core_event_handler(switch_event_t *event) sql = switch_mprintf("insert into channels (uuid,created,created_epoch, name,state,dialplan,context) values('%q','%q','%ld','%q','%q','%q','%q')", switch_event_get_header_nil(event, "unique-id"), switch_event_get_header_nil(event, "event-date-local"), - (long)switch_timestamp(NULL), + (long)switch_epoch_time_now(NULL), switch_event_get_header_nil(event, "channel-name"), switch_event_get_header_nil(event, "channel-state"), switch_event_get_header_nil(event, "caller-dialplan"), @@ -339,7 +339,7 @@ static void core_event_handler(switch_event_t *event) case SWITCH_EVENT_CHANNEL_BRIDGE: sql = switch_mprintf("insert into calls values ('%s', '%ld', '%s','%q','%q','%q','%q','%s','%q','%q','%q','%q','%s')", switch_event_get_header_nil(event, "event-date-local"), - (long)switch_timestamp(NULL), + (long)switch_epoch_time_now(NULL), switch_event_get_header_nil(event, "event-calling-function"), switch_event_get_header_nil(event, "caller-caller-id-name"), switch_event_get_header_nil(event, "caller-caller-id-number"), diff --git a/src/switch_event.c b/src/switch_event.c index 9c57da5620..2632adf989 100644 --- a/src/switch_event.c +++ b/src/switch_event.c @@ -1019,7 +1019,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_fire_detailed(const char *file, con switch_time_exp_t tm; char date[80] = ""; switch_size_t retsize; - switch_time_t ts = switch_timestamp_now(); + switch_time_t ts = switch_micro_time_now(); switch_assert(BLOCK != NULL); switch_assert(RUNTIME_POOL != NULL); diff --git a/src/switch_ivr.c b/src/switch_ivr.c index 175d5be8dc..73cd2db849 100644 --- a/src/switch_ivr.c +++ b/src/switch_ivr.c @@ -42,7 +42,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, { switch_channel_t *channel = switch_core_session_get_channel(session); switch_status_t status = SWITCH_STATUS_SUCCESS; - switch_time_t start = switch_timestamp_now(), now, done = switch_timestamp_now() + (ms * 1000); + switch_time_t start = switch_micro_time_now(), now, done = switch_micro_time_now() + (ms * 1000); switch_frame_t *read_frame, cng_frame = { 0 }; int32_t left, elapsed; char data[2] = ""; @@ -114,7 +114,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, } for (;;) { - now = switch_timestamp_now(); + now = switch_micro_time_now(); elapsed = (int32_t) ((now - start) / 1000); left = ms - elapsed; @@ -452,9 +452,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Command Execute %s(%s)\n", switch_channel_get_name(channel), app_name, switch_str_nil(app_arg)); - b4 = switch_timestamp_now(); + b4 = switch_micro_time_now(); switch_core_session_exec(session, application_interface, app_arg); - aftr = switch_timestamp_now(); + aftr = switch_micro_time_now(); if (!switch_channel_ready(channel) || switch_channel_test_flag(channel, CF_STOP_BROADCAST) || aftr - b4 < 500000) { break; } @@ -593,7 +593,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session, if ((timeout = atoi(to)) < 0) { timeout = 0; } else { - expires = switch_timestamp(NULL) + timeout; + expires = switch_epoch_time_now(NULL) + timeout; } } @@ -610,7 +610,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session, break; } - if (expires && switch_timestamp(NULL) >= expires) { + if (expires && switch_epoch_time_now(NULL) >= expires) { switch_channel_hangup(channel, SWITCH_CAUSE_RECOVERY_ON_TIMER_EXPIRE); break; } @@ -733,7 +733,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_s } if (timeout) { - started = switch_timestamp_now(); + started = switch_micro_time_now(); } while (switch_channel_ready(channel)) { @@ -748,7 +748,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_s } if (timeout) { - elapsed = (uint32_t) ((switch_timestamp_now() - started) / 1000); + elapsed = (uint32_t) ((switch_micro_time_now() - started) / 1000); if (elapsed >= timeout) { break; } @@ -855,7 +855,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess } if (abs_timeout) { - started = switch_timestamp_now(); + started = switch_micro_time_now(); } if (digit_timeout && first_timeout) { @@ -868,14 +868,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess if (eff_timeout) { - digit_started = switch_timestamp_now(); + digit_started = switch_micro_time_now(); } while (switch_channel_ready(channel)) { switch_frame_t *read_frame; if (abs_timeout) { - abs_elapsed = (uint32_t) ((switch_timestamp_now() - started) / 1000); + abs_elapsed = (uint32_t) ((switch_micro_time_now() - started) / 1000); if (abs_elapsed >= abs_timeout) { break; } @@ -887,7 +887,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess if (eff_timeout) { - digit_elapsed = (uint32_t) ((switch_timestamp_now() - digit_started) / 1000); + digit_elapsed = (uint32_t) ((switch_micro_time_now() - digit_started) / 1000); if (digit_elapsed >= eff_timeout) { status = SWITCH_STATUS_TIMEOUT; break; @@ -900,7 +900,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess if (eff_timeout) { eff_timeout = digit_timeout; - digit_started = switch_timestamp_now(); + digit_started = switch_micro_time_now(); } for (y = 0; y <= maxdigits; y++) { @@ -1476,12 +1476,12 @@ SWITCH_DECLARE(void *) switch_ivr_digit_stream_parser_feed(switch_ivr_digit_stre stream->digits = tmp; *(stream->digits + (len++)) = digit; *(stream->digits + len) = '\0'; - stream->last_digit_time = switch_timestamp_now() / 1000; + stream->last_digit_time = switch_micro_time_now() / 1000; } } } /* don't allow collected digit string testing if there are varying sized keys until timeout */ - if (parser->maxlen - parser->minlen > 0 && (switch_timestamp_now() / 1000) - stream->last_digit_time < parser->digit_timeout_ms) { + if (parser->maxlen - parser->minlen > 0 && (switch_micro_time_now() / 1000) - stream->last_digit_time < parser->digit_timeout_ms) { len = 0; } /* if we have digits to test */ diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index e90e0380ed..1367137021 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -378,7 +378,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_ switch_channel_pre_answer(channel); if (limit) { - to = switch_timestamp(NULL) + limit; + to = switch_epoch_time_now(NULL) + limit; } if (flags && strchr(flags, 'm')) { @@ -892,7 +892,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t } if (limit) { - to = switch_timestamp(NULL) + limit; + to = switch_epoch_time_now(NULL) + limit; } if ((status = switch_core_media_bug_add(session, record_callback, fh, to, flags, &bug)) != SWITCH_STATUS_SUCCESS) { @@ -1525,7 +1525,7 @@ static switch_status_t meta_on_dtmf(switch_core_session_t *session, const switch { switch_channel_t *channel = switch_core_session_get_channel(session); dtmf_meta_data_t *md = switch_channel_get_private(channel, SWITCH_META_VAR_KEY); - time_t now = switch_timestamp(NULL); + time_t now = switch_epoch_time_now(NULL); char digit[2] = ""; int dval; diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index d0c6e06b23..6b6186bbc9 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -219,7 +219,7 @@ static int check_per_channel_timeouts(originate_status_t *originate_status, time_t start) { int x = 0,i; - time_t elapsed = switch_timestamp(NULL) - start; + time_t elapsed = switch_epoch_time_now(NULL) - start; for (i = 0; i < max; i++) { if (originate_status[i].peer_channel && switch_channel_get_state(originate_status[i].peer_channel) < CS_HANGUP) { @@ -592,7 +592,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t } timelimit *= 1000000; - start = switch_timestamp_now(); + start = switch_micro_time_now(); if (caller_channel) { if (switch_channel_test_flag(caller_channel, CF_ANSWERED)) { @@ -708,7 +708,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t while (switch_channel_ready(peer_channel) && !(switch_channel_test_flag(peer_channel, CF_ANSWERED) || switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA))) { - int diff = (int) (switch_timestamp_now() - start); + int diff = (int) (switch_micro_time_now() - start); if (diff > timelimit) { status = SWITCH_STATUS_TIMEOUT; @@ -1486,7 +1486,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess } } - switch_timestamp(&start); + switch_epoch_time_now(&start); for (;;) { uint32_t valid_channels = 0; @@ -1514,7 +1514,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess goto notready; } - elapsed = switch_timestamp(NULL) - start; + elapsed = switch_epoch_time_now(NULL) - start; if (elapsed > (time_t) timelimit_sec) { to++; @@ -1653,7 +1653,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess } while ((!caller_channel || switch_channel_ready(caller_channel)) && check_channel_status(&oglobals, originate_status, and_argc)) { - time_t elapsed = switch_timestamp(NULL) - start; + time_t elapsed = switch_epoch_time_now(NULL) - start; if (caller_channel && !oglobals.sent_ring && oglobals.ring_ready && !oglobals.return_ring_ready) { switch_channel_ring_ready(caller_channel); oglobals.sent_ring = 1; diff --git a/src/switch_ivr_play_say.c b/src/switch_ivr_play_say.c index 63a9a4789c..f23e7347ab 100644 --- a/src/switch_ivr_play_say.c +++ b/src/switch_ivr_play_say.c @@ -497,7 +497,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se } if (limit) { - start = switch_timestamp(NULL); + start = switch_epoch_time_now(NULL); } if (fh->thresh) { @@ -531,7 +531,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se switch_ivr_parse_all_events(session); } - if (start && (switch_timestamp(NULL) - start) > limit) { + if (start && (switch_epoch_time_now(NULL) - start) > limit) { break; } diff --git a/src/switch_log.c b/src/switch_log.c index 27d1e089e1..8e1d47735a 100644 --- a/src/switch_log.c +++ b/src/switch_log.c @@ -246,7 +246,7 @@ SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, const char const char *filep = (file ? switch_cut_path(file) : ""); const char *funcp = (func ? func : ""); char *content = NULL; - switch_time_t now = switch_timestamp_now(); + switch_time_t now = switch_micro_time_now(); uint32_t len; const char *extra_fmt = "%s [%s] %s:%d %s()%c%s"; diff --git a/src/switch_resample.c b/src/switch_resample.c index 1ff98a251b..e174cdc121 100644 --- a/src/switch_resample.c +++ b/src/switch_resample.c @@ -206,7 +206,7 @@ SWITCH_DECLARE(void) switch_generate_sln_silence(int16_t *data, uint32_t samples int16_t x; uint32_t i; int sum_rnd = 0; - int16_t rnd2 = (int16_t) switch_timestamp_now(); + int16_t rnd2 = (int16_t) switch_micro_time_now(); assert(divisor); diff --git a/src/switch_rtp.c b/src/switch_rtp.c index 040d26d5f6..d9acbb5b58 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -228,7 +228,7 @@ static switch_status_t do_stun_ping(switch_rtp_t *rtp_session) #if 0 if (rtp_session->last_stun) { - elapsed = (unsigned int) ((switch_timestamp_now() - rtp_session->last_stun) / 1000); + elapsed = (unsigned int) ((switch_micro_time_now() - rtp_session->last_stun) / 1000); if (elapsed > 30000) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No stun for a long time (PUNT!)\n"); @@ -282,7 +282,7 @@ static switch_status_t ice_out(switch_rtp_t *rtp_session) } if (rtp_session->last_stun) { - elapsed = (unsigned int) ((switch_timestamp_now() - rtp_session->last_stun) / 1000); + elapsed = (unsigned int) ((switch_micro_time_now() - rtp_session->last_stun) / 1000); if (elapsed > 30000) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No stun for a long time (PUNT!)\n"); @@ -310,7 +310,7 @@ static void handle_stun_ping_reply(switch_rtp_t *rtp_session, void *data, switch return; } - rtp_session->last_stun = switch_timestamp_now(); + rtp_session->last_stun = switch_micro_time_now(); } static void handle_ice(switch_rtp_t *rtp_session, void *data, switch_size_t len) @@ -346,7 +346,7 @@ static void handle_ice(switch_rtp_t *rtp_session, void *data, switch_size_t len) } end_buf = buf + ((sizeof(buf) > packet->header.length) ? packet->header.length : sizeof(buf)); - rtp_session->last_stun = switch_timestamp_now(); + rtp_session->last_stun = switch_micro_time_now(); switch_stun_packet_first_attribute(packet, attr); @@ -830,7 +830,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session rtp_session->seq = (uint16_t) rand(); - rtp_session->ssrc = (uint32_t) ((intptr_t) &rtp_session + (uint32_t) switch_timestamp(NULL)); + rtp_session->ssrc = (uint32_t) ((intptr_t) &rtp_session + (uint32_t) switch_epoch_time_now(NULL)); rtp_session->send_msg.header.ssrc = htonl(rtp_session->ssrc); rtp_session->send_msg.header.ts = 0; rtp_session->send_msg.header.m = 0; @@ -1967,7 +1967,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session, } if (!rtp_session->timer.interval && - ((unsigned)((switch_timestamp_now() - rtp_session->last_write_timestamp))) > (rtp_session->ms_per_packet *2)) { + ((unsigned)((switch_micro_time_now() - rtp_session->last_write_timestamp))) > (rtp_session->ms_per_packet *2)) { m++; } @@ -1995,7 +1995,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session, uint32_t rate = 0; uint32_t codec_flags = 0; uint32_t len = sizeof(decoded); - time_t now = switch_timestamp(NULL); + time_t now = switch_epoch_time_now(NULL); send = 0; if (rtp_session->vad_data.scan_freq && rtp_session->vad_data.next_scan <= now) { @@ -2132,7 +2132,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session, if (rtp_session->timer.interval) { rtp_session->last_write_samplecount = rtp_session->timer.samplecount; } else { - rtp_session->last_write_timestamp = (uint32_t) switch_timestamp_now(); + rtp_session->last_write_timestamp = (uint32_t) switch_micro_time_now(); } rtp_session->last_write_ts = this_ts; @@ -2209,7 +2209,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_enable_vad(switch_rtp_t *rtp_session, rtp_session->vad_data.cng_freq = 50; rtp_session->vad_data.ts = 1; rtp_session->vad_data.start = 0; - rtp_session->vad_data.next_scan = switch_timestamp(NULL); + rtp_session->vad_data.next_scan = switch_epoch_time_now(NULL); rtp_session->vad_data.scan_freq = 0; switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_VAD); switch_set_flag(&rtp_session->vad_data, SWITCH_VAD_FLAG_CNG); diff --git a/src/switch_scheduler.c b/src/switch_scheduler.c index 1ec9ef6b02..e31fe3f577 100644 --- a/src/switch_scheduler.c +++ b/src/switch_scheduler.c @@ -107,7 +107,7 @@ static int task_thread_loop(int done) if (done) { tp->destroyed = 1; } else { - int64_t now = switch_timestamp(NULL); + int64_t now = switch_epoch_time_now(NULL); if (now >= tp->task.runtime && !tp->in_thread) { int32_t diff = (int32_t) (now - tp->task.runtime); if (diff > 1) { @@ -190,7 +190,7 @@ SWITCH_DECLARE(uint32_t) switch_scheduler_add_task(time_t task_runtime, switch_zmalloc(container, sizeof(*container)); switch_assert(func); container->func = func; - container->task.created = switch_timestamp(NULL); + container->task.created = switch_epoch_time_now(NULL); container->task.runtime = task_runtime; container->task.group = strdup(group ? group : "none"); container->task.cmd_id = cmd_id; diff --git a/src/switch_stun.c b/src/switch_stun.c index bc8e540d04..7e9a694fa7 100644 --- a/src/switch_stun.c +++ b/src/switch_stun.c @@ -105,7 +105,7 @@ SWITCH_DECLARE(void) switch_stun_random_string(char *buf, uint16_t len, char *se max = (int) strlen(set); - srand((unsigned int) switch_timestamp_now()); + srand((unsigned int) switch_micro_time_now()); for (x = 0; x < len; x++) { int j = (int) (max * 1.0 * rand() / (RAND_MAX + 1.0)); @@ -510,7 +510,7 @@ SWITCH_DECLARE(switch_status_t) switch_stun_lookup(char **ip, } switch_socket_sendto(sock, remote_addr, 0, (void *) packet, &bytes); - started = switch_timestamp_now(); + started = switch_micro_time_now(); *ip = NULL; *port = 0; @@ -522,7 +522,7 @@ SWITCH_DECLARE(switch_status_t) switch_stun_lookup(char **ip, break; } - if ((elapsed = (unsigned int) ((switch_timestamp_now() - started) / 1000)) > 5000) { + if ((elapsed = (unsigned int) ((switch_micro_time_now() - started) / 1000)) > 5000) { *err = "Timeout"; switch_socket_shutdown(sock, SWITCH_SHUTDOWN_READWRITE); switch_socket_close(sock); diff --git a/src/switch_time.c b/src/switch_time.c index 94370f0b8d..3937a38a22 100644 --- a/src/switch_time.c +++ b/src/switch_time.c @@ -111,15 +111,15 @@ static void do_sleep(switch_interval_time_t t) } -SWITCH_DECLARE(switch_time_t) switch_timestamp_now(void) +SWITCH_DECLARE(switch_time_t) switch_micro_time_now(void) { return runtime.timestamp ? runtime.timestamp : switch_time_now(); } -SWITCH_DECLARE(time_t) switch_timestamp(time_t *t) +SWITCH_DECLARE(time_t) switch_epoch_time_now(time_t *t) { - time_t now = switch_timestamp_now() / APR_USEC_PER_SEC; + time_t now = switch_micro_time_now() / APR_USEC_PER_SEC; if (t) { *t = now; } @@ -671,7 +671,7 @@ SWITCH_DECLARE(switch_status_t) switch_time_exp_tz_name(const char *tz, switch_t time_t timep; if (!thetime) { - thetime = switch_timestamp_now(); + thetime = switch_micro_time_now(); } timep = (thetime) / (int64_t) (1000000); @@ -707,7 +707,7 @@ SWITCH_DECLARE(switch_status_t) switch_strftime_tz(const char *tz, const char *f switch_time_exp_t stm; if (!thetime) { - thetime = switch_timestamp_now(); + thetime = switch_micro_time_now(); } timep = (thetime) / (int64_t) (1000000); diff --git a/src/switch_utils.c b/src/switch_utils.c index 52f103397c..1894df94db 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -377,7 +377,7 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to, const char *fr unsigned char in[B64BUFFLEN]; unsigned char out[B64BUFFLEN + 512]; - switch_snprintf(filename, 80, "%smail.%d%04x", SWITCH_GLOBAL_dirs.temp_dir, (int) switch_timestamp(NULL), rand() & 0xffff); + switch_snprintf(filename, 80, "%smail.%d%04x", SWITCH_GLOBAL_dirs.temp_dir, (int) switch_epoch_time_now(NULL), rand() & 0xffff); if ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644))) { if (file) { @@ -828,7 +828,7 @@ SWITCH_DECLARE(switch_time_t) switch_str_time(const char *in) switch_time_t ret = 0; char *pattern = "^(\\d+)-(\\d+)-(\\d+)\\s*(\\d*):{0,1}(\\d*):{0,1}(\\d*)"; - switch_time_exp_lt(&tm, switch_timestamp_now()); + switch_time_exp_lt(&tm, switch_micro_time_now()); tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = 0; if ((proceed = switch_regex_perform(in, pattern, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {