I am not that familiar with 'diff -c' format, but I guess it is ok. Ultimately can be reverted.
Many modules were updated to use use_table() before db ops along the time, but there might still be some that have to be updated. Perhaps is good to check the sources when using a module with db cluster.
Not sure everyone knows, but if you work on a source tree taken from git, then you can do:
git diff >/path/to/save/the/patch
an you get the diff in unified format (git friendly).
If wanted, you can reset all the changes that were not committed with: git reset --hard HEAD
Cheers, Daniel
On 9/27/12 5:58 PM, Juha Heinanen wrote:
i applied the patch below to pua module and the crash disappeared. can i commit it to master? i wonder if there are other places where use_table should be added in some other modules.
-- juha
diff -c /usr/src/orig/sip-router/modules_k/pua/pua.c ./pua.c *** /usr/src/orig/sip-router/modules_k/pua/pua.c 2012-09-16 17:24:34.515266527 +0300 --- ./pua.c 2012-09-27 18:39:24.938581317 +0300
*** 63,69 **** int min_expires= 0; int default_expires=3600; static str db_url = str_init(DEFAULT_DB_URL); ! static str db_table= str_init("pua"); int update_period= 100; str outbound_proxy = {0, 0}; int check_remote_contact = 1; --- 63,69 ---- int min_expires= 0; int default_expires=3600; static str db_url = str_init(DEFAULT_DB_URL); ! str db_table= str_init("pua"); int update_period= 100; str outbound_proxy = {0, 0}; int check_remote_contact = 1; diff -c /usr/src/orig/sip-router/modules_k/pua/pua_db.c ./pua_db.c *** /usr/src/orig/sip-router/modules_k/pua/pua_db.c 2012-09-16 17:34:22.367646853 +0300 --- ./pua_db.c 2012-09-27 18:50:47.275474397 +0300
*** 168,173 **** --- 168,178 ---- q_vals[0].val.int_val = now+update_period; q_ops[0] = OP_LT;
- if (pua_dbf.use_table(pua_db, &db_table) < 0) {
LM_ERR("error in use_table pua\n");
return(-1);
- }
- if(db_fetch_query(&pua_dbf, pua_fetch_rows, pua_db, q_cols, q_ops, q_vals, NULL, 1, 0, 0, &res) < 0) {
*** 279,284 **** --- 284,294 ---- return(-1); }
if (pua_dbf.use_table(pua_db, &db_table) < 0)
{
LM_ERR("error in use_table pua\n");
return(-1);
}
if(pua_dbf.query(pua_db, q_cols, 0, q_vals, res_cols,n_query_cols,n_res_cols,0,&res) < 0)
*** 367,372 **** --- 377,388 ---- return(-1); }
- if (pua_dbf.use_table(pua_db, &db_table) < 0)
- {
LM_ERR("error in use_table pua\n");
return(-1);
- }
- if(pua_dbf.query(pua_db, q_cols, 0, q_vals, res_cols,n_query_cols,n_res_cols,0,&res) < 0) {
*** 614,620 **** query_vals[n_query_cols].val.str_val.len = 0; n_query_cols++;
!
if (pua_dbf.replace != NULL) {
--- 630,640 ---- query_vals[n_query_cols].val.str_val.len = 0; n_query_cols++;
! if (pua_dbf.use_table(pua_db, &db_table) < 0) ! { ! LM_ERR("error in use_table pua\n"); ! return(-1); ! }
if (pua_dbf.replace != NULL) {
*** 843,848 **** --- 863,874 ---- return(NULL); }
- if (pua_dbf.use_table(pua_db, &db_table) < 0)
- {
LM_ERR("error in use_table pua\n");
return(NULL);
- }
- if(query_fn(pua_db, q_cols, 0, q_vals, NULL,n_query_cols,0,0,&res) < 0) {
*** 919,924 **** --- 945,956 ---- return(-1); }
- if (pua_dbf.use_table(pua_db, &db_table) < 0)
- {
LM_ERR("error in use_table pua\n");
return(-1);
- }
- if (pua_dbf.delete(pua_db, q_cols, 0, q_vals, n_query_cols) < 0) { LM_ERR("deleting record\n");
*** 985,990 **** --- 1017,1028 ---- return(-1); }
- if (pua_dbf.use_table(pua_db, &db_table) < 0)
- {
LM_ERR("error in use_table pua\n");
return(-1);
- }
- if (pua_dbf.update(pua_db, q_cols, 0, q_vals, u_cols, u_vals, n_query_cols, n_update_cols) < 0) {
*** 1192,1197 **** --- 1230,1241 ---- return(NULL); }
- if (pua_dbf.use_table(pua_db, &db_table) < 0)
- {
LM_ERR("error in use_table pua\n");
return(NULL);
- }
- if(query_fn(pua_db, q_cols, 0, q_vals, NULL,n_query_cols,0,0,&res) < 0) {
*** 1278,1283 **** --- 1322,1333 ---- return(-1); }
- if (pua_dbf.use_table(pua_db, &db_table) < 0)
- {
LM_ERR("error in use_table pua\n");
return(-1);
- }
- if (pua_dbf.delete(pua_db, q_cols, 0, q_vals, n_query_cols) < 0) { LM_ERR("deleting record\n");
*** 1350,1355 **** --- 1400,1411 ---- return(-1); }
- if (pua_dbf.use_table(pua_db, &db_table) < 0)
- {
LM_ERR("error in use_table pua\n");
return(-1);
- }
- if (pua_dbf.update(pua_db, q_cols, 0, q_vals, u_cols, u_vals, n_query_cols, n_update_cols) < 0) {
*** 1409,1414 **** --- 1465,1476 ---- return(-1); }
- if (pua_dbf.use_table(pua_db, &db_table) < 0)
- {
LM_ERR("error in use_table pua\n");
return(-1);
- }
- if(pua_dbf.update(pua_db, q_cols, 0, q_vals, db_cols,db_vals,n_query_cols,n_update_cols) < 0) {
*** 1467,1472 **** --- 1529,1540 ---- return(-1); }
- if (pua_dbf.use_table(pua_db, &db_table) < 0)
- {
LM_ERR("error in use_table pua\n");
return(-1);
- }
- if(pua_dbf.update(pua_db, q_cols, 0, q_vals, db_cols,db_vals,n_query_cols,n_update_cols) < 0)
*** 1505,1510 **** --- 1573,1584 ---- return list; }
- if (pua_dbf.use_table(pua_db, &db_table) < 0)
- {
LM_ERR("error in use_table pua\n");
return(list);
- }
- if(db_fetch_query(&pua_dbf, pua_fetch_rows, pua_db, q_cols, 0, q_vals, res_cols, n_query_cols, n_res_cols, 0, &res) < 0) {
diff -c /usr/src/orig/sip-router/modules_k/pua/pua.h ./pua.h *** /usr/src/orig/sip-router/modules_k/pua/pua.h 2012-09-02 15:14:34.426055998 +0300 --- ./pua.h 2012-09-27 18:48:22.298428856 +0300
*** 59,63 **** --- 59,64 ---- extern db1_con_t *pua_db; extern int pua_fetch_rows;
extern str db_table;
#endif