Skip to content

Commit a2c01e2

Browse files
committed
[ldk-net] Correct pollfds array offset after reads
Previously, we were copying the pollfds array at an offset of one into the handler thread's stack. However, when it was changed to copying at a 0 offset (adding the pipe read fd at the end instead of beginning), the disable-read handling code was not updated. This leads to an assertion failure at runtime if LDK decides we need to stop reading due to the outbound buffer of a peer being full.
1 parent cac55d2 commit a2c01e2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ldk-net/ldk_net.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ static void *sock_thread_fn(void* arg) {
266266
if (*res.contents.result) {
267267
lockres = pthread_mutex_lock(&handler->sockets_mutex);
268268
assert(lockres == 0);
269-
assert(handler->pollfds[i - 1].fd == pollfds[i].fd); // Only we change fd order!
270-
handler->pollfds[i - 1].events = POLLOUT;
269+
assert(handler->pollfds[i].fd == pollfds[i].fd); // Only we change fd order!
270+
handler->pollfds[i].events = POLLOUT;
271271
lockres = pthread_mutex_unlock(&handler->sockets_mutex);
272272
assert(lockres == 0);
273273
}

0 commit comments

Comments
 (0)