소스 검색

acc: new parameter to allow usage of insert delayed

- db_insert_mode can be set to 1 in order to use INSERT DELAYED when
  adding the acc records to database
Daniel-Constantin Mierla 14 년 전
부모
커밋
9bd65819c8
4개의 변경된 파일488개의 추가작업 그리고 229개의 파일을 삭제
  1. 448 223
      modules_k/acc/README
  2. 21 6
      modules_k/acc/acc.c
  3. 2 0
      modules_k/acc/acc_mod.c
  4. 17 0
      modules_k/acc/doc/acc_admin.xml

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 448 - 223
modules_k/acc/README


+ 21 - 6
modules_k/acc/acc.c

@@ -91,6 +91,7 @@ extern struct acc_extra *dia_extra;
 static db_func_t acc_dbf;
 static db1_con_t* db_handle=0;
 extern struct acc_extra *db_extra;
+extern int acc_db_insert_mode;
 #endif
 
 /* arrays used to collect the values before being
@@ -394,18 +395,32 @@ int acc_db_request( struct sip_msg *rq)
 
 	/* multi-leg columns */
 	if ( !leg_info ) {
-		if (acc_dbf.insert(db_handle, db_keys, db_vals, m) < 0) {
-			LM_ERR("failed to insert into database\n");
-			return -1;
+		if(acc_db_insert_mode==1 && acc_dbf.insert_delayed!=NULL) {
+			if (acc_dbf.insert_delayed(db_handle, db_keys, db_vals, m) < 0) {
+				LM_ERR("failed to insert delayed into database\n");
+				return -1;
+			}
+		} else {
+			if (acc_dbf.insert(db_handle, db_keys, db_vals, m) < 0) {
+				LM_ERR("failed to insert into database\n");
+				return -1;
+			}
 		}
 	} else {
   	        n = legs2strar(leg_info,rq,val_arr+m,int_arr+m,type_arr+m,1);
 		do {
 			for (i=m; i<m+n; i++)
 				VAL_STR(db_vals+i)=val_arr[i];
-			if (acc_dbf.insert(db_handle, db_keys, db_vals, m+n) < 0) {
-				LM_ERR("failed to insert into database\n");
-				return -1;
+			if(acc_db_insert_mode==1 && acc_dbf.insert_delayed!=NULL) {
+				if(acc_dbf.insert_delayed(db_handle,db_keys,db_vals,m+n)<0) {
+					LM_ERR("failed to insert delayed into database\n");
+					return -1;
+				}
+			} else {
+				if (acc_dbf.insert(db_handle, db_keys, db_vals, m+n) < 0) {
+					LM_ERR("failed to insert into database\n");
+					return -1;
+				}
 			}
 		}while ( (n=legs2strar(leg_info,rq,val_arr+m,int_arr+m,
 				       type_arr+m,0))!=0 );

+ 2 - 0
modules_k/acc/acc_mod.c

@@ -187,6 +187,7 @@ str acc_callid_col     = str_init("callid");
 str acc_sipcode_col    = str_init("sip_code");
 str acc_sipreason_col  = str_init("sip_reason");
 str acc_time_col       = str_init("time");
+int acc_db_insert_mode = 0;
 #endif
 
 /*@}*/
@@ -276,6 +277,7 @@ static param_export_t params[] = {
 	{"acc_sip_code_column",  STR_PARAM, &acc_sipcode_col.s    },
 	{"acc_sip_reason_column",STR_PARAM, &acc_sipreason_col.s  },
 	{"acc_time_column",      STR_PARAM, &acc_time_col.s       },
+	{"db_insert_mode",       INT_PARAM, &acc_db_insert_mode   },
 #endif
 	{0,0,0}
 };

+ 17 - 0
modules_k/acc/doc/acc_admin.xml

@@ -992,6 +992,23 @@ modparam("acc", "acc_time_column", "time")
 		<title>db_extra example</title>
 		<programlisting format="linespecific">
 modparam("acc", "db_extra", "ct=$hdr(Content-type); email=$avp(s:email)")
+</programlisting>
+		</example>
+	</section>
+	<section>
+		<title><varname>db_insert_mode</varname> (integer)</title>
+		<para>
+		If set to 1, use INSERT DELAYED to add records to accounting tables
+		when the DB driver has support for it. If no INSERT DELAYED support
+		is offered by DB driver, then standard INSERT is used.
+		</para>
+		<para>
+		Default value is 0 (no INSERT DELAYED).
+		</para>
+		<example>
+		<title>db_insert_mode example</title>
+		<programlisting format="linespecific">
+modparam("acc", "db_insert_mode", 1)
 </programlisting>
 		</example>
 	</section>

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.