changeset 1201:d2608e47db28

Fix issue that can trigger an assert when failover occurs
author Sebastien Decugis <sdecugis@freediameter.net>
date Fri, 14 Jun 2013 12:19:32 +0800
parents ce2b00dc86c1
children 40330b75c044
files libfdcore/peers.c
diffstat 1 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libfdcore/peers.c	Fri Jun 14 10:14:11 2013 +0800
+++ b/libfdcore/peers.c	Fri Jun 14 12:19:32 2013 +0800
@@ -241,13 +241,20 @@
 	
 	/* Requeue all messages in the "out" queue */
 	while ( fd_fifo_tryget(peer->p_tosend, &m) == 0 ) {
-		fd_hook_call(HOOK_MESSAGE_FAILOVER, m, peer, NULL, fd_msg_pmdl_get(m));
-		CHECK_FCT_DO(fd_fifo_post_noblock(fd_g_outgoing, (void *)&m), 
-			{
-				/* fallback: destroy the message */
-				fd_hook_call(HOOK_MESSAGE_DROPPED, m, NULL, "Internal error: unable to requeue this message during failover process", fd_msg_pmdl_get(m));
-				CHECK_FCT_DO(fd_msg_free(m), /* What can we do more? */)
-			} );
+		/* but only if they are routable */
+		if (fd_msg_is_routable(m)) {
+			fd_hook_call(HOOK_MESSAGE_FAILOVER, m, peer, NULL, fd_msg_pmdl_get(m));
+			CHECK_FCT_DO(fd_fifo_post_noblock(fd_g_outgoing, (void *)&m), 
+				{
+					/* fallback: destroy the message */
+					fd_hook_call(HOOK_MESSAGE_DROPPED, m, NULL, "Internal error: unable to requeue this message during failover process", fd_msg_pmdl_get(m));
+					CHECK_FCT_DO(fd_msg_free(m), /* What can we do more? */)
+				} );
+		} else {
+			/* Just free it */
+			/* fd_hook_call(HOOK_MESSAGE_DROPPED, m, NULL, "Non-routable message freed during handover", fd_msg_pmdl_get(m)); */
+			CHECK_FCT_DO(fd_msg_free(m), /* What can we do more? */)
+		}
 	}
 	
 	/* Requeue all routable sent requests */
"Welcome to our mercurial repository"