mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-02 18:35:00 +01:00
gossip: Avoid reading gossip messages that we just wrote
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
parent
1135760a2f
commit
5944524d01
1 changed files with 9 additions and 1 deletions
|
@ -58,9 +58,17 @@ const u8 *gossip_store_read_next(const tal_t *ctx, struct gossip_store *gs)
|
|||
beint16_t belen;
|
||||
u16 msglen;
|
||||
u8 *msg;
|
||||
if (!read_all(gs->read_fd, &belen, sizeof(belen)))
|
||||
|
||||
/* Did we already reach the end of the gossip_store? */
|
||||
if (gs->read_fd == -1)
|
||||
return NULL;
|
||||
|
||||
/* Can we read one message? */
|
||||
if (!read_all(gs->read_fd, &belen, sizeof(belen))) {
|
||||
gs->read_fd = -1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
msglen = be16_to_cpu(belen);
|
||||
msg = tal_arr(ctx, u8, msglen);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue