瀏覽代碼

- replaced time(0) w/ ser_time(0) (=> less syscalls, ser_time is more
then 10 times faster)

Andrei Pelinescu-Onciul 17 年之前
父節點
當前提交
840211e9d3

+ 2 - 1
modules_s/auth/challenge.c

@@ -42,6 +42,7 @@
 #include "../../parser/digest/digest.h"
 #include "../../parser/digest/digest.h"
 #include "../../usr_avp.h"
 #include "../../usr_avp.h"
 #include "../../ut.h"
 #include "../../ut.h"
+#include "../../ser_time.h"
 #include "auth_mod.h"
 #include "auth_mod.h"
 #include "challenge.h"
 #include "challenge.h"
 #include "nonce.h"
 #include "nonce.h"
@@ -152,7 +153,7 @@ int build_challenge_hf(struct sip_msg* msg, int stale, str* realm, str* nonce, s
     }
     }
     else {
     else {
         l=nonce_len;
         l=nonce_len;
-		t=time(0);
+		t=ser_time(0);
 #if defined USE_NC || defined USE_OT_NONCE
 #if defined USE_NC || defined USE_OT_NONCE
 		if (nc_enabled || otn_enabled){
 		if (nc_enabled || otn_enabled){
 			pool=nid_get_pool();
 			pool=nid_get_pool();

+ 4 - 2
modules_s/auth/nonce.c

@@ -53,6 +53,7 @@
 #include "../../ip_addr.h"
 #include "../../ip_addr.h"
 #include "nonce.h"
 #include "nonce.h"
 #include "../../globals.h"
 #include "../../globals.h"
+#include "../../ser_time.h"
 #include <assert.h>
 #include <assert.h>
 #ifdef USE_NC
 #ifdef USE_NC
 #include "nc.h"
 #include "nc.h"
@@ -268,7 +269,8 @@ int calc_nonce(char* nonce, int *nonce_len, int cfg, int since, int expires,
  * @param b_nonce a pointer to a union bin_nonce to be checked.
  * @param b_nonce a pointer to a union bin_nonce to be checked.
  * @return 1 the nonce is stale, 0 the nonce is not stale.
  * @return 1 the nonce is stale, 0 the nonce is not stale.
  */
  */
-#define is_bin_nonce_stale(b_nonce) (get_bin_nonce_expire(b_nonce) < time(0))
+#define is_bin_nonce_stale(b_nonce)\
+	(get_bin_nonce_expire(b_nonce) < ser_time(0))
 
 
 
 
 
 
@@ -347,7 +349,7 @@ int check_nonce(auth_body_t* auth, str* secret1, str* secret2,
 		   different length (for example because of different auth.
 		   different length (for example because of different auth.
 		   checks)..  Therefore we force credentials to be rebuilt by UAC
 		   checks)..  Therefore we force credentials to be rebuilt by UAC
 		   without prompting for password */
 		   without prompting for password */
-		return 3;
+		return 4;
 	}
 	}
 	b_nonce2=b_nonce; /*pre-fill it with the values from the received nonce*/
 	b_nonce2=b_nonce; /*pre-fill it with the values from the received nonce*/
 	b_nonce2.n.expire=b_nonce.n.expire;
 	b_nonce2.n.expire=b_nonce.n.expire;

+ 2 - 1
modules_s/registrar/regtime.c

@@ -29,6 +29,7 @@
 
 
 
 
 #include "regtime.h"
 #include "regtime.h"
+#include "../../ser_time.h"
 
 
 
 
 time_t act_time;
 time_t act_time;
@@ -40,5 +41,5 @@ time_t act_time;
  */
  */
 void get_act_time(void)
 void get_act_time(void)
 {
 {
-	act_time = time(0);
+	act_time = ser_time(0);
 }
 }

+ 2 - 1
modules_s/textops/textops.c

@@ -77,6 +77,7 @@
 #include "../xlog/xl_lib.h"
 #include "../xlog/xl_lib.h"
 #include "../../script_cb.h"
 #include "../../script_cb.h"
 #include "../../select_buf.h"
 #include "../../select_buf.h"
+#include "../../ser_time.h"
 #include <stdio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
@@ -691,7 +692,7 @@ static int append_time_f(struct sip_msg* msg, char* p1, char *p2)
 	time_t now;
 	time_t now;
 	struct tm *bd_time;
 	struct tm *bd_time;
 
 
-	now=time(0);
+	now=ser_time(0);
 
 
 	bd_time=gmtime(&now);
 	bd_time=gmtime(&now);
 	if (bd_time==NULL) {
 	if (bd_time==NULL) {

+ 2 - 1
modules_s/usrloc/ucontact.c

@@ -44,6 +44,7 @@
 #include "../../db/db.h"
 #include "../../db/db.h"
 #include "../../ip_addr.h"
 #include "../../ip_addr.h"
 #include "../../globals.h"
 #include "../../globals.h"
+#include "../../ser_time.h"
 #include "ul_mod.h"
 #include "ul_mod.h"
 #include "ul_callback.h"
 #include "ul_callback.h"
 #include "reg_avps.h"
 #include "reg_avps.h"
@@ -172,7 +173,7 @@ void free_ucontact(ucontact_t* _c)
  */
  */
 void print_ucontact(FILE* _f, ucontact_t* _c)
 void print_ucontact(FILE* _f, ucontact_t* _c)
 {
 {
-	time_t t = time(0);
+	time_t t = ser_time(0);
 	char* st;
 	char* st;
 
 
 	switch(_c->state) {
 	switch(_c->state) {

+ 2 - 1
modules_s/usrloc/utime.c

@@ -29,6 +29,7 @@
 
 
 
 
 #include "utime.h"
 #include "utime.h"
+#include "../../ser_time.h"
 
 
 
 
 time_t act_time;
 time_t act_time;
@@ -37,5 +38,5 @@ time_t act_time;
 void get_act_time(void)
 void get_act_time(void)
 {
 {
 
 
-	act_time = time(0);
+	act_time = ser_time(0);
 }
 }