wiringPi.c ; waitForInterrupt releases fd and line itself, wiringPiISRStop not necessary to be called

This commit is contained in:
phylax2020
2025-02-17 22:09:07 +01:00
parent 04dc08e511
commit 7abeddde2d
2 changed files with 9 additions and 19 deletions

View File

@@ -2782,34 +2782,35 @@ long long int waitForInterrupt (int pin, int edgeMode, int mS, unsigned long deb
}
/*
* waitForInterruptClose:
* wait for thread interruptHandler to be stopped.
* wiringPiISRStop:
* stop interruptHandler thread and
* wait untill stopped.
* close isrFds[pin], reset isrFds[pin], isrFunction[pin] and isrDebouncePeriodUs[pin]
*
*********************************************************************************
*/
int waitForInterruptClose (int pin) {
int wiringPiISRStop (int pin) {
void *res;
if (isrFds[pin] > 0) {
if (wiringPiDebug)
printf ("waitForInterruptClose: close thread 0x%lX\n", (unsigned long)isrThreads[pin]) ;
printf ("wiringPiISRStop: close thread 0x%lX\n", (unsigned long)isrThreads[pin]) ;
if (isrThreads[pin] != 0) {
if (pthread_cancel(isrThreads[pin]) == 0) {
pthread_join(isrThreads[pin], &res);
if (res == PTHREAD_CANCELED) {
if (wiringPiDebug)
printf("waitForInterruptClose: thread was canceled\n");
printf("wiringPiISRStop: thread was canceled\n");
}
else {
if (wiringPiDebug)
printf("waitForInterruptClose: thread was not canceled\n");
printf("wiringPiISRStop: thread was not canceled\n");
}
} else {
if (wiringPiDebug)
printf ("waitForInterruptClose: waitForInterruptClose could not cancel thread\n");
printf ("wiringPiISRStop: could not cancel thread\n");
}
}
close(isrFds [pin]);
@@ -2830,17 +2831,6 @@ int waitForInterruptClose (int pin) {
return 0;
}
/*
* wiringPiISRStop:
* stop thread interruptHandler
*
*********************************************************************************
*/
int wiringPiISRStop (int pin) {
return waitForInterruptClose (pin);
}
/*
* interruptHandler: