Browse Source

Merge pull request #734 from gaaf/random-fixes

Random fixes
Daniel-Constantin Mierla 9 years ago
parent
commit
b0f8516fbf

+ 14 - 1
main.c

@@ -833,7 +833,20 @@ void sig_usr(int signo)
 					_exit(0);
 					break;
 			case SIGUSR1:
-				/* statistics, do nothing, printed only from the main proc */
+#ifdef PKG_MALLOC
+					cfg_update_no_cbs();
+					memlog=cfg_get(core, core_cfg, memlog);
+					if (memlog <= cfg_get(core, core_cfg, debug)){
+						if (cfg_get(core, core_cfg, mem_summary) & 1) {
+							LOG(memlog, "Memory status (pkg):\n");
+							pkg_status();
+						}
+						if (cfg_get(core, core_cfg, mem_summary) & 2) {
+							LOG(memlog, "Memory still-in-use summary (pkg):\n");
+							pkg_sums();
+						}
+					}
+#endif
 					break;
 				/* ignored*/
 			case SIGUSR2:

+ 2 - 1
modules/dispatcher/dispatcher.c

@@ -596,7 +596,8 @@ static void destroy(void)
 	ds_hash_load_destroy();
 	if(ds_ping_reply_codes)
 		shm_free(ds_ping_reply_codes);
-
+	if(ds_ping_reply_codes_cnt)
+		shm_free(ds_ping_reply_codes_cnt);
 }
 
 #define GET_VALUE(param_name,param,i_value,s_value,value_flags) do{ \

+ 3 - 3
modules/jsonrpc-s/jsonrpc-s_mod.c

@@ -571,7 +571,7 @@ static int jsonrpc_scan(jsonrpc_ctx_t* ctx, char* fmt, ...)
 		case '{':
 		case '[':
 			LM_ERR("Unsupported param type '%c'\n", *fmt);
-			jsonrpc_fault(ctx, 500, "Unsupported param type");
+			jsonrpc_fault(ctx, 400, "Unsupported param type");
 			goto error;
 		default:
 			LM_ERR("Invalid param type in formatting string: [%c]\n", *fmt);
@@ -1041,7 +1041,7 @@ static int jsonrpc_dispatch(sip_msg_t* msg, char* s1, char* s2)
 	ctx->jreq = srjson_NewDoc(NULL);
 	if(ctx->jreq==NULL) {
 		LM_ERR("Failed to init the json document\n");
-		return NONSIP_MSG_PASS;
+		return NONSIP_MSG_ERROR;
 	}
 
 	ctx->jreq->buf.s = get_body(msg);
@@ -1050,7 +1050,7 @@ static int jsonrpc_dispatch(sip_msg_t* msg, char* s1, char* s2)
 	if(ctx->jreq->root == NULL)
 	{
 		LM_ERR("invalid json doc [[%s]]\n", ctx->jreq->buf.s);
-		return NONSIP_MSG_PASS;
+		return NONSIP_MSG_ERROR;
 	}
 	if (jsonrpc_init_reply(ctx) < 0) goto send_reply;
 

+ 2 - 6
modules/mqueue/mqueue_api.c

@@ -44,7 +44,6 @@ typedef struct _mq_item
 {
 	str key;
 	str val;
-	struct _mq_item *prev;
 	struct _mq_item *next;
 } mq_item_t;
 
@@ -266,8 +265,6 @@ int mq_head_fetch(str *name)
 	mh->ifirst = mh->ifirst->next;
 	if(mh->ifirst==NULL) {
 		mh->ilast = NULL;
-	} else {
-		mh->ifirst->prev = NULL;
 	}
 	mh->csize--;
 
@@ -332,7 +329,6 @@ int mq_item_add(str *qname, str *key, str *val)
 		mh->ilast = mi;
 	} else {
 		mh->ilast->next = mi;
-		mi->prev = mh->ilast;
 		mh->ilast = mi;
 	}
 	mh->csize++;
@@ -341,9 +337,9 @@ int mq_item_add(str *qname, str *key, str *val)
 		mi = mh->ifirst;
 		mh->ifirst = mh->ifirst->next;
 		if(mh->ifirst==NULL)
+		{
 			mh->ilast = NULL;
-		else
-			mh->ifirst->prev = NULL;
+		}
 		mh->csize--;
 		shm_free(mi);
 	}

+ 6 - 3
modules/pv/pv_xavp.c

@@ -506,8 +506,10 @@ int pv_parse_xavp_name(pv_spec_p sp, str *in)
 		return -1;
 
 	xname = (pv_xavp_name_t*)pkg_malloc(sizeof(pv_xavp_name_t));
-	if(xname==NULL)
+	if(xname==NULL) {
+		LM_ERR("not enough pkg mem\n");
 		return -1;
+	}
 
 	memset(xname, 0, sizeof(pv_xavp_name_t));
 
@@ -530,9 +532,10 @@ int pv_parse_xavp_name(pv_spec_p sp, str *in)
 			xname->name.s, s.len, s.s);
 
 	xname->next = (pv_xavp_name_t*)pkg_malloc(sizeof(pv_xavp_name_t));
-	if(xname->next==NULL)
+	if(xname->next==NULL) {
+		LM_ERR("not enough pkg mem\n");
 		goto error;
-
+	}
 	memset(xname->next, 0, sizeof(pv_xavp_name_t));
 
 	p = pv_xavp_fill_ni(&s, xname->next);

+ 4 - 4
modules/sl/sl_funcs.c

@@ -86,7 +86,7 @@ int sl_startup()
 		LOG(L_ERR,"ERROR:sl_startup: no more free memory!\n");
 		return -1;
 	}
-	*(sl_timeout)=get_ticks();
+	*(sl_timeout)=get_ticks_raw();
 
 	return 1;
 }
@@ -182,6 +182,8 @@ int sl_reply_helper(struct sip_msg *msg, int code, char *reason, str *tag)
 	
 	sl_run_callbacks(SLCB_REPLY_READY, msg, code, reason, &buf, &dst);
 
+	*(sl_timeout) = get_ticks_raw() + SL_RPL_WAIT_TIME;
+
 	/* supress multhoming support when sending a reply back -- that makes sure
 	   that replies will come from where requests came in; good for NATs
 	   (there is no known use for mhomed for locally generated replies;
@@ -286,8 +288,6 @@ event_route_error:
 	if (ret<0) {
 		goto error;
 	}
-	
-	*(sl_timeout) = get_ticks() + SL_RPL_WAIT_TIME;
 
 	update_sl_stats(code);
 	return 1;
@@ -383,7 +383,7 @@ int sl_filter_ACK(struct sip_msg *msg, unsigned int flags, void *bar )
 		goto pass_it;
 
 	/*check the timeout value*/
-	if ( *(sl_timeout)<= get_ticks() )
+	if ( *(sl_timeout)<= get_ticks_raw() )
 	{
 		DBG("DEBUG : sl_filter_ACK: to late to be a local ACK!\n");
 		goto pass_it;

+ 2 - 1
modules/sl/sl_funcs.h

@@ -24,8 +24,9 @@
 
 #include "../../sr_module.h"
 #include "../../parser/msg_parser.h"
+#include "../../timer_ticks.h"
 
-#define SL_RPL_WAIT_TIME  2  /* in sec */
+#define SL_RPL_WAIT_TIME  S_TO_TICKS(2)   /* in sec */
 
 #define SL_TOTAG_SEPARATOR '.'
 

+ 1 - 1
modules/tmx/t_var.c

@@ -396,7 +396,7 @@ int pv_get_tm_branch_idx(struct sip_msg *msg, pv_param_t *param,
 		return -1;
 
 	/* statefull replies have the branch_index set */
-	if(msg->first_line.type == SIP_REPLY && route_type != CORE_ONREPLY_ROUTE) {
+	if(msg->first_line.type == SIP_REPLY) {
 		tcx = _tmx_tmb.tm_ctx_get();
 		if(tcx != NULL)
 			idx = tcx->branch_index;

+ 2 - 2
socket_info.c

@@ -1406,8 +1406,8 @@ static int fix_socket_list(struct socket_info **list, int* type_flags)
 	for (si=*list;si;){
 		next=si->next;
 		ai_lst=0;
-		if (add_interfaces(si->name.s, 0, si->port_no,
-							si->proto, &ai_lst)!=-1){
+		if (add_interfaces(si->name.s, auto_bind_ipv6 ? 0 : AF_INET,
+							si->port_no, si->proto, &ai_lst)!=-1){
 			if (si->flags & SI_IS_MHOMED){
 				if((new_si=new_sock2list_after(ai_lst->name.s, 0, si->port_no,
 											si->proto, si->useinfo.name.s,