ソースを参照

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

+ 4 - 2
modules_s/auth/nonce.c

@@ -53,6 +53,7 @@
 #include "../../ip_addr.h"
 #include "nonce.h"
 #include "../../globals.h"
+#include "../../ser_time.h"
 #include <assert.h>
 #ifdef USE_NC
 #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.
  * @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.
 		   checks)..  Therefore we force credentials to be rebuilt by UAC
 		   without prompting for password */
-		return 3;
+		return 4;
 	}
 	b_nonce2=b_nonce; /*pre-fill it with the values from the received nonce*/
 	b_nonce2.n.expire=b_nonce.n.expire;

+ 2 - 1
modules_s/registrar/regtime.c

@@ -29,6 +29,7 @@
 
 
 #include "regtime.h"
+#include "../../ser_time.h"
 
 
 time_t act_time;
@@ -40,5 +41,5 @@ time_t act_time;
  */
 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 "../../script_cb.h"
 #include "../../select_buf.h"
+#include "../../ser_time.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -691,7 +692,7 @@ static int append_time_f(struct sip_msg* msg, char* p1, char *p2)
 	time_t now;
 	struct tm *bd_time;
 
-	now=time(0);
+	now=ser_time(0);
 
 	bd_time=gmtime(&now);
 	if (bd_time==NULL) {

+ 2 - 1
modules_s/usrloc/ucontact.c

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

+ 2 - 1
modules_s/usrloc/utime.c

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