mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-29 09:44:26 +00:00
Merge pull request #1645 from qlyoung/fix-cancel-invalid-rw
lib: avoid crash when cancelling invalid rw job
This commit is contained in:
commit
9ee9eb8066
14
lib/thread.c
14
lib/thread.c
@ -919,6 +919,8 @@ struct thread *funcname_thread_add_event(struct thread_master *m,
|
||||
*/
|
||||
static void thread_cancel_rw(struct thread_master *master, int fd, short state)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
/* Cancel POLLHUP too just in case some bozo set it */
|
||||
state |= POLLHUP;
|
||||
|
||||
@ -926,8 +928,18 @@ static void thread_cancel_rw(struct thread_master *master, int fd, short state)
|
||||
nfds_t i;
|
||||
|
||||
for (i = 0; i < master->handler.pfdcount; i++)
|
||||
if (master->handler.pfds[i].fd == fd)
|
||||
if (master->handler.pfds[i].fd == fd) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
zlog_debug(
|
||||
"[!] Received cancellation request for nonexistent rw job");
|
||||
zlog_debug("[!] threadmaster: %s | fd: %d",
|
||||
master->name ? master->name : "", fd);
|
||||
return;
|
||||
}
|
||||
|
||||
/* NOT out event. */
|
||||
master->handler.pfds[i].events &= ~(state);
|
||||
|
Loading…
Reference in New Issue
Block a user