Skip to content

Commit e2628bd

Browse files
committed
set_interrupt missed an EEXIST test fo the case when an interrupt is already running
1 parent 8647048 commit e2628bd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

c_src/gpio_drv.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,8 +1527,10 @@ static ErlDrvSSizeT gpio_drv_ctl(ErlDrvData d,
15271527
if (direction != gpio_direction_in)
15281528
goto badarg;
15291529
if (gp->interrupt != gpio_interrupt_none) {
1530-
if (add_interrupt(ctx, gp) == GPIO_NOK)
1531-
goto error;
1530+
if (add_interrupt(ctx, gp) == GPIO_NOK) {
1531+
if (errno != EEXIST) // active?
1532+
goto error;
1533+
}
15321534
}
15331535
gp->interrupt = intval;
15341536
gp->target = driver_caller(ctx->port);

0 commit comments

Comments
 (0)