mirror of
https://github.com/kidoman/embd
synced 2024-06-07 03:27:48 +02:00
Stop Watching pin when Closing
Closing a pin will automatically check and close any pin that where being watch for interrupt.
This commit is contained in:
parent
e1a90ade4f
commit
5f8a0fced0
|
@ -100,6 +100,12 @@ func (io *gpioDriver) RegisterInterrupt(p InterruptPin) error {
|
||||||
func (io *gpioDriver) UnregisterInterrupt(p InterruptPin) error {
|
func (io *gpioDriver) UnregisterInterrupt(p InterruptPin) error {
|
||||||
|
|
||||||
fd := p.Fd()
|
fd := p.Fd()
|
||||||
|
|
||||||
|
// check if we are watching this pin
|
||||||
|
if _, ok := io.watchEventCallbacks[fd]; !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if err := syscall.EpollCtl(epollFD, syscall.EPOLL_CTL_DEL, fd, nil); err != nil {
|
if err := syscall.EpollCtl(epollFD, syscall.EPOLL_CTL_DEL, fd, nil); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -276,6 +276,10 @@ func (p *digitalPin) Close() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := p.StopWatching(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if !p.initialized {
|
if !p.initialized {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user