[asterisk-commits] mmichelson: branch mmichelson/pool_shark r380543 - in /team/mmichelson/pool_s...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 30 12:19:54 CST 2013


Author: mmichelson
Date: Wed Jan 30 12:19:51 2013
New Revision: 380543

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=380543
Log:
Add failure handlers for ast_sip_push_task() calls.


Modified:
    team/mmichelson/pool_shark/channels/chan_gulp.c
    team/mmichelson/pool_shark/res/res_sip_session.c

Modified: team/mmichelson/pool_shark/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/pool_shark/channels/chan_gulp.c?view=diff&rev=380543&r1=380542&r2=380543
==============================================================================
--- team/mmichelson/pool_shark/channels/chan_gulp.c (original)
+++ team/mmichelson/pool_shark/channels/chan_gulp.c Wed Jan 30 12:19:51 2013
@@ -200,7 +200,12 @@
 	ast_setstate(ast, AST_STATE_UP);
 
 	ao2_ref(session, +1);
-	return ast_sip_push_task(session->work, answer, session);
+	if (ast_sip_push_task(session->work, answer, session)) {
+		ast_log(LOG_WARNING, "Unable to push answer task to the threadpool. Cannot answer call\n");
+		ao2_cleanup(session);
+		return -1;
+	}
+	return 0;
 }
 
 /*! \brief Function called by core to read any waiting frames */
@@ -288,6 +293,7 @@
 	}
 
 	if (ast_sip_push_task_synchronous(session->work, fixup, &fix_data)) {
+		ast_log(LOG_WARNING, "Unable to perform channel fixup\n");
 		return -1;
 	}
 
@@ -423,7 +429,11 @@
 		if (!ind_data) {
 			res = -1;
 		} else {
-			ast_sip_push_task(session->work, indicate, ind_data);
+			res = ast_sip_push_task(session->work, indicate, ind_data);
+			if (res) {
+				ast_log(LOG_NOTICE, "Unable to push indication task to the threadpool\n");
+				ao2_cleanup(ind_data);
+			}
 		}
 	}
 
@@ -494,7 +504,12 @@
 	struct ast_sip_session *session = ast_channel_tech_pvt(ast);
 
 	ao2_ref(session, +1);
-	return ast_sip_push_task(session->work, call, session);
+	if (ast_sip_push_task(session->work, call, session)) {
+		ast_log(LOG_WARNING, "Unable to push call task into the threadpool. Unable to call '%s'\n", dest);
+		ao2_cleanup(session);
+		return -1;
+	}
+	return 0;
 }
 
 /*! \brief Internal function which translates from Asterisk cause codes to SIP response codes */
@@ -603,6 +618,7 @@
 	}
 
 	if (ast_sip_push_task(session->work, hangup, h_data)) {
+		ast_log(LOG_WARNING, "Unable to push hangup task to the threadpool. Expect bad things\n");
 		goto failure;
 	}
 	return 0;
@@ -611,6 +627,7 @@
 	/* Go ahead and do our cleanup of the session and channel even if we're not going
 	 * to be able to send our SIP request/response
 	 */
+	ao2_cleanup(h_data);
 	session->channel = NULL;
 	ast_channel_tech_pvt_set(ast, NULL);
 

Modified: team/mmichelson/pool_shark/res/res_sip_session.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/pool_shark/res/res_sip_session.c?view=diff&rev=380543&r1=380542&r2=380543
==============================================================================
--- team/mmichelson/pool_shark/res/res_sip_session.c (original)
+++ team/mmichelson/pool_shark/res/res_sip_session.c Wed Jan 30 12:19:51 2013
@@ -900,7 +900,13 @@
 			ast_sip_destroy_work(work);
 			break;
 		}
-		ast_sip_push_task(work, handle_new_invite_request, nrd);
+		if (ast_sip_push_task(work, handle_new_invite_request, nrd)) {
+			ast_log(LOG_WARNING, "Failed to pass new INVITE to the threadpool\n");
+			pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, 500, NULL, NULL, NULL);
+			pjsip_rx_data_free_cloned(clone);
+			ast_sip_destroy_work(work);
+			ast_free(nrd);
+		}
 		break;
 	case PJSIP_OTHER_METHOD:
 		/* Area for INFO and REFER, possibly other methods */
@@ -1078,7 +1084,10 @@
 	case PJSIP_EVENT_RX_MSG:
 		hid = handle_incoming_data_alloc(session, e->body.rx_msg.rdata);
 		if (hid) {
-			ast_sip_push_task(session->work, handle_incoming, hid);
+			if (ast_sip_push_task(session->work, handle_incoming, hid)) {
+				ast_log(LOG_WARNING, "Failed to pass in-dialog request to threadpool\n");
+				ao2_cleanup(hid);
+			}
 		}
 		break;
 	case PJSIP_EVENT_TSX_STATE:
@@ -1091,7 +1100,10 @@
 		case PJSIP_EVENT_RX_MSG:
 			hid = handle_incoming_data_alloc(session, e->body.tsx_state.src.rdata);
 			if (hid) {
-				ast_sip_push_task(session->work, handle_incoming, hid);
+				if (ast_sip_push_task(session->work, handle_incoming, hid)) {
+					ast_log(LOG_WARNING, "Failed to pass in-dialog request to threadpool\n");
+					ao2_cleanup(hid);
+				}
 			}
 			break;
 		case PJSIP_EVENT_TRANSPORT_ERROR:
@@ -1112,7 +1124,10 @@
 	}
 
 	if (inv->state == PJSIP_INV_STATE_DISCONNECTED) {
-		ast_sip_push_task(session->work, session_end, session);
+		if (ast_sip_push_task(session->work, session_end, session)) {
+			ast_log(LOG_WARNING, "Failed to push session end task to threadpool. Ending session in-thread\n");
+			session_end(session);
+		}
 	}
 }
 
@@ -1215,7 +1230,9 @@
 	/* PJSIP requires us to have set an SDP answer when this returns, so we have to push this
 	 * task synchronously
 	 */
-	ast_sip_push_task_synchronous(session->work, on_rx_offer, &orod);
+	if (ast_sip_push_task_synchronous(session->work, on_rx_offer, &orod)) {
+		ast_log(LOG_WARNING, "Synchronous threadpool task to create SDP answer failed. A crash may occur\n");
+	}
 }
 
 #if 0
@@ -1263,7 +1280,10 @@
 	if (!mud) {
 		return;
 	}
-	ast_sip_push_task(session->work, on_media_update, mud);
+	if (ast_sip_push_task(session->work, on_media_update, mud)) {
+		ast_log(LOG_WARNING, "Failed to pass media update task to the threadpool\n");
+		ao2_cleanup(mud);
+	}
 }
 
 static pjsip_redirect_op session_inv_on_redirected(pjsip_inv_session *inv, const pjsip_uri *target, const pjsip_event *e)




More information about the asterisk-commits mailing list