changeset 1017:d69612a16929

Do not abort dispatch thread when a callback returns an error
author Sebastien Decugis <sdecugis@freediameter.net>
date Mon, 01 Apr 2013 11:27:34 +0800
parents dc7d6d5f93d3
children d67fec731a12
files libfdproto/dispatch.c
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libfdproto/dispatch.c	Fri Mar 29 17:31:46 2013 +0800
+++ b/libfdproto/dispatch.c	Mon Apr 01 11:27:34 2013 +0800
@@ -70,6 +70,7 @@
 			struct dict_object * obj_app, struct dict_object * obj_cmd, struct dict_object * obj_avp, struct dict_object * obj_enu)
 {
 	struct fd_list * senti, *li;
+	int r;
 	TRACE_ENTRY("%p %p %p %p %p %p %p %p %p", cb_list, msg, avp, sess, action, obj_app, obj_cmd, obj_avp, obj_enu);
 	CHECK_PARAMS(msg && action);
 	
@@ -93,7 +94,13 @@
 			continue;
 		
 		/* We have a match, the cb must be called. */
-		CHECK_FCT( (*hdl->cb)(msg, avp, sess, hdl->opaque, action) );
+		CHECK_FCT_DO( (r = (*hdl->cb)(msg, avp, sess, hdl->opaque, action)),
+			{
+				fd_msg_log( FD_MSG_LOG_DROPPED, *msg, "Internal error: a DISPATCH callback returned an error (%s)", strerror(r));
+				fd_msg_free(*msg);
+				*msg = NULL;
+			}
+		 );
 		
 		if (*action != DISP_ACT_CONT)
 			break;
"Welcome to our mercurial repository"