Browse code

- updates related with changes of the calback prototype (used by t_request_xx)

Bogdan-Andrei Iancu authored on 05/12/2003 14:31:49
Showing 4 changed files
... ...
@@ -200,7 +200,7 @@ static int mod_init(void)
200 200
 	}
201 201
 
202 202
 	/* import mysql functions */
203
-	if (bind_dbmod())
203
+	if (bind_dbmod(db_url))
204 204
 	{
205 205
 		LOG(L_ERR, "XJAB:mod_init: error - database module not found\n");
206 206
 		return -1;
... ...
@@ -1163,7 +1163,6 @@ int xj_send_sip_msg(str *proxy, str *to, str *from, str *msg, int *cbp)
1163 1163
 	char buf[512];
1164 1164
 	str  tfrom;
1165 1165
 	str  str_hdr;
1166
-	int **pcbp = NULL;//, beg, end, crt;
1167 1166
 	char buf1[1024];
1168 1167
 
1169 1168
 	if( !to || !to->s || to->len <= 0 
... ...
@@ -1198,11 +1197,8 @@ int xj_send_sip_msg(str *proxy, str *to, str *from, str *msg, int *cbp)
1198 1197
 		DBG("XJAB:xj_send_sip_msg: uac callback parameter [%p==%d]\n", 
1199 1198
 				cbp, *cbp);
1200 1199
 #endif
1201
-		if((pcbp = (int**)shm_malloc(sizeof(int*))) == NULL)
1202
-			return -1;
1203
-		*pcbp = cbp;
1204 1200
 		return tmb.t_request(&msg_type, 0, to, &tfrom, &str_hdr, msg, 
1205
-					     xj_tuac_callback, (void*)pcbp);
1201
+					     xj_tuac_callback, (void*)cbp);
1206 1202
 	}
1207 1203
 	else
1208 1204
 		return tmb.t_request(&msg_type, 0, to, &tfrom, &str_hdr, msg, 0, 0);
... ...
@@ -1269,28 +1265,27 @@ int xj_wlist_clean_jobs(xj_wlist jwl, int idx, int fl)
1269 1265
 /**
1270 1266
  * callback function for TM
1271 1267
  */
1272
-void xj_tuac_callback( struct cell *t, struct sip_msg *msg,
1273
-			int code, void *param)
1268
+void xj_tuac_callback( struct cell *t, int type, struct tmcb_params *ps)
1274 1269
 {
1275 1270
 #ifdef XJ_EXTRA_DEBUG
1276
-	DBG("XJAB: xj_tuac_callback: completed with status %d\n", code);
1271
+	DBG("XJAB: xj_tuac_callback: completed with status %d\n", ps->code);
1277 1272
 #endif
1278
-	if(!t->cbp)
1273
+	if(!ps->param)
1279 1274
 	{
1280 1275
 		DBG("XJAB: m_tuac_callback: parameter not received\n");
1281 1276
 		return;
1282 1277
 	}
1283 1278
 #ifdef XJ_EXTRA_DEBUG
1284
-	DBG("XJAB: xj_tuac_callback: parameter [%p : ex-value=%d]\n", t->cbp,
1285
-					*(*((int**)t->cbp)) );
1279
+	DBG("XJAB: xj_tuac_callback: parameter [%p : ex-value=%d]\n", ps->param,
1280
+					*((int*)ps->param) );
1286 1281
 #endif
1287
-	if(code < 200 || code >= 300)
1282
+	if(ps->code < 200 || ps->code >= 300)
1288 1283
 	{
1289 1284
 #ifdef XJ_EXTRA_DEBUG
1290 1285
 		DBG("XJAB: xj_tuac_callback: no 2XX return code - connection set"
1291 1286
 			" as expired \n");
1292 1287
 #endif
1293
-		*(*((int**)t->cbp)) = XJ_FLAG_CLOSE;	
1288
+		*((int*)ps->param) = XJ_FLAG_CLOSE;
1294 1289
 	}
1295 1290
 }
1296 1291
 
... ...
@@ -101,8 +101,7 @@ void xj_sig_handler(int s);
101 101
 
102 102
 int xj_send_sip_msg(str *, str *, str *, str *, int *);
103 103
 int xj_send_sip_msgz(str *,str *, str *, char *, int *);
104
-void xj_tuac_callback(struct cell *, struct sip_msg *,
105
-			int, void *);
104
+void xj_tuac_callback( struct cell *t, int type, struct tmcb_params *ps);
106 105
 void xj_worker_check_jcons(xj_wlist, xj_jcon_pool, int, fd_set*);
107 106
 void xj_worker_check_qmsg(xj_wlist, xj_jcon_pool);
108 107
 void xj_worker_check_watcher(xj_wlist, xj_jcon_pool, xj_jcon, xj_sipmsg);
... ...
@@ -158,8 +158,7 @@ void destroy(void);
158 158
 void m_clean_silo(unsigned int ticks, void *);
159 159
 
160 160
 /** TM callback function */
161
-static void m_tm_callback( struct cell *t, struct sip_msg *msg,
162
-	int code, void *param);
161
+static void m_tm_callback( struct cell *t, int type, struct tmcb_params *ps);
163 162
 
164 163
 static cmd_export_t cmds[]={
165 164
 	{"m_store",  m_store, 1, 0, REQUEST_ROUTE | FAILURE_ROUTE},
... ...
@@ -591,7 +590,7 @@ static int m_dump(struct sip_msg* msg, char* str1, char* str2)
591 590
 							DB_KEY_CTYPE, DB_KEY_INC_TIME 
592 591
 					};
593 592
 	db_res_t* db_res = NULL;
594
-	int i, db_no_cols = IDX_NO, db_no_keys = 1, *msg_id, mid, n;
593
+	int i, db_no_cols = IDX_NO, db_no_keys = 1, mid, n;
595 594
 	char hdr_buf[1024], body_buf[1024];
596 595
 
597 596
 	str str_vals[IDX_NO], hdr_str , body_str;
... ...
@@ -683,7 +682,7 @@ static int m_dump(struct sip_msg* msg, char* str1, char* str2)
683 682
 			SET_STR_VAL(str_vals[STR_IDX_BODY], db_res, i, DUMP_IDX_BODY);
684 683
 			SET_STR_VAL(str_vals[STR_IDX_CTYPE], db_res, i, DUMP_IDX_CTYPE);
685 684
 			
686
-			hdr_str.len = 1024;		
685
+			hdr_str.len = 1024;
687 686
 			if(m_build_headers(&hdr_str, str_vals[STR_IDX_CTYPE],
688 687
 					str_vals[STR_IDX_FROM]) < 0)
689 688
 			{
... ...
@@ -695,19 +694,7 @@ static int m_dump(struct sip_msg* msg, char* str1, char* str2)
695 694
 				goto error;
696 695
 			}
697 696
 			
698
-			if((msg_id = shm_malloc(sizeof(int))) == 0)
699
-			{
700
-				DBG("MSILO:m_dump: no more share memory!");
701
-				if (db_free_query(db_con, db_res) < 0)
702
-					DBG("MSILO:m_dump: Error while freeing result of"
703
-						" query\n");
704
-				msg_list_set_flag(ml, mid, MS_MSG_ERRO);
705
-				goto error;
706
-			}
707
-						
708
-			*msg_id = mid;
709
-			
710
-			DBG("MSILO:m_dump: msg [%d-%d] for: %.*s\n", i+1, *msg_id,
697
+			DBG("MSILO:m_dump: msg [%d-%d] for: %.*s\n", i+1, mid,
711 698
 					pto->uri.len, pto->uri.s);
712 699
 			
713 700
 			/** sending using TM function: t_uac */
... ...
@@ -733,7 +720,7 @@ static int m_dump(struct sip_msg* msg, char* str1, char* str2)
733 720
 					&hdr_str,         /* Optional headers including CRLF */
734 721
 					(n<0)?&str_vals[STR_IDX_BODY]:&body_str, /* Message body */
735 722
 					m_tm_callback,    /* Callback function */
736
-					(void*)msg_id     /* Callback parameter */
723
+					(void*)mid        /* Callback parameter */
737 724
 				);
738 725
 		}
739 726
 	}
... ...
@@ -826,11 +813,10 @@ void destroy(void)
826 813
 /** 
827 814
  * TM callback function - delete message from database if was sent OK
828 815
  */
829
-void m_tm_callback( struct cell *t, struct sip_msg *msg,
830
-	int code, void *param)
816
+void m_tm_callback( struct cell *t, int type, struct tmcb_params *ps)
831 817
 {
832
-	DBG("MSILO:m_tm_callback: completed with status %d\n", code);
833
-	if(!t->cbp)
818
+	DBG("MSILO:m_tm_callback: completed with status %d\n", ps->code);
819
+	if(!ps->param)
834 820
 	{
835 821
 		DBG("MSILO m_tm_callback: message id not received\n");
836 822
 		goto done;
... ...
@@ -840,15 +826,15 @@ void m_tm_callback( struct cell *t, struct sip_msg *msg,
840 826
 		DBG("MSILO:m_tm_callback: db_con is NULL\n");
841 827
 		goto done;
842 828
 	}
843
-	if(code < 200 || code >= 300)
829
+	if(ps->code < 200 || ps->code >= 300)
844 830
 	{
845 831
 		DBG("MSILO:m_tm_callback: message <%d> was not sent successfully\n",
846
-				*((int*)t->cbp));
847
-		msg_list_set_flag(ml, *((int*)t->cbp), MS_MSG_ERRO);
832
+				(int)ps->param);
833
+		msg_list_set_flag(ml, (int)ps->param, MS_MSG_ERRO);
848 834
 		goto done;
849 835
 	}
850 836
 
851
-	msg_list_set_flag(ml, *((int*)t->cbp), MS_MSG_DONE);
837
+	msg_list_set_flag(ml, (int)ps->param, MS_MSG_DONE);
852 838
 	
853 839
 done:
854 840
 	return;