Skip to content

Commit f10331b

Browse files
committed
fixup! connectd: Implement sending of start_batch
1 parent 005dd30 commit f10331b

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

connectd/multiplex.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -417,28 +417,31 @@ static u8 *process_batch_elements(struct peer *peer, const u8 *msg TAKES)
417417
struct channel_id channel_id;
418418
u8 *enc_msg;
419419

420-
if (fromwire_u16(&cursor, &plen) != WIRE_PROTOCOL_BATCH_ELEMENT)
421-
status_failed(STATUS_FAIL_PROTO_BATCH,
422-
"process_batch_elements on msg that is"
420+
if (fromwire_u16(&cursor, &plen) != WIRE_PROTOCOL_BATCH_ELEMENT) {
421+
status_broken("process_batch_elements on msg that is"
423422
" not WIRE_PROTOCOL_BATCH_ELEMENT. %s",
424423
tal_hexstr(tmpctx, cursor, plen));
424+
return tal_free(ret);
425+
}
425426

426427
fromwire_channel_id(&cursor, &plen, &channel_id);
427428

428429
element_size = fromwire_u16(&cursor, &plen);
429-
if (!element_size)
430-
status_failed(STATUS_FAIL_PROTO_BATCH,
431-
"process_batch_elements cannot have zero"
430+
if (!element_size) {
431+
status_broken("process_batch_elements cannot have zero"
432432
" length elements. %s",
433433
tal_hexstr(tmpctx, cursor, plen));
434+
return tal_free(ret);
435+
}
434436

435437
element_bytes = fromwire_tal_arrn(NULL, &cursor, &plen,
436438
element_size);
437-
if (!element_bytes)
438-
status_failed(STATUS_FAIL_PROTO_BATCH,
439-
"process_batch_elements fromwire_tal_arrn"
439+
if (!element_bytes) {
440+
status_broken("process_batch_elements fromwire_tal_arrn"
440441
" %s",
441442
tal_hexstr(tmpctx, cursor, plen));
443+
return tal_free(ret);
444+
}
442445

443446
status_debug("Processing batch extracted item %s. %s",
444447
peer_wire_name(fromwire_peektype(element_bytes)),
@@ -503,10 +506,14 @@ static struct io_plan *encrypt_and_send(struct peer *peer,
503506
set_urgent_flag(peer, is_urgent(type));
504507

505508
/* Special message type directing us to process batch items. */
506-
if (type == WIRE_PROTOCOL_BATCH_ELEMENT)
509+
if (type == WIRE_PROTOCOL_BATCH_ELEMENT) {
507510
peer->sent_to_peer = process_batch_elements(peer, msg);
508-
else
511+
if (!peer->sent_to_peer)
512+
return io_close(peer->to_peer);
513+
}
514+
else {
509515
peer->sent_to_peer = cryptomsg_encrypt_msg(peer, &peer->cs, msg);
516+
}
510517
/* We free this and the encrypted version in next write_to_peer */
511518

512519
return io_write(peer->to_peer,

0 commit comments

Comments
 (0)