Pārlūkot izejas kodu

cpg: Handle fragmented message sending interrupt

It turns out that there are some legitimate cases where fragmented
messages might be interrupted during sending (e.g. CS_ERR_TRY_AGAIN or
as in my case: CS_ERR_INTERRUPT). This creates a situation where
LIBCPG_PARTIAL_FIRST is sent multiple times before receiving
LIBCPG_PARTIAL_LAST.

Solution is to drop incomplete message and start assembly of new message
as libcpg should have reported error during sending of that
incomplete message.

Signed-off-by: Rytis Karpuška <rytisk@neurotechnology.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
Rytis Karpuška 8 gadi atpakaļ
vecāks
revīzija
aa62c2c028
1 mainītis faili ar 7 papildinājumiem un 3 dzēšanām
  1. 7 3
      lib/cpg.c

+ 7 - 3
lib/cpg.c

@@ -491,11 +491,15 @@ cs_error_t cpg_dispatch (
 				if (res_cpg_partial_deliver_callback->type == LIBCPG_PARTIAL_FIRST) {
 				if (res_cpg_partial_deliver_callback->type == LIBCPG_PARTIAL_FIRST) {
 
 
 					/*
 					/*
-					 * As this is LIBCPG_PARTIAL_FIRST packet, check that there is no ongoing assembly
+					 * As this is LIBCPG_PARTIAL_FIRST packet, check that there is no ongoing assembly.
+					 * Otherwise the sending of packet must have been interrupted and error should have
+					 * been reported to sending client. Therefore here last assembly will be dropped.
 					 */
 					 */
 					if (assembly_data) {
 					if (assembly_data) {
-						error = CS_ERR_MESSAGE_ERROR;
-						goto error_put;
+						qb_list_del (&assembly_data->list);
+						free(assembly_data->assembly_buf);
+						free(assembly_data);
+						assembly_data = NULL;
 					}
 					}
 
 
 					assembly_data = malloc(sizeof(struct cpg_assembly_data));
 					assembly_data = malloc(sizeof(struct cpg_assembly_data));