freetdm: update to threadmutex to allow ftdm to run properly under GDB
This commit is contained in:
parent
16d918d025
commit
70b0e4bd51
|
@ -373,6 +373,7 @@ FT_DECLARE(ftdm_status_t) ftdm_interrupt_signal(ftdm_interrupt_t *interrupt)
|
||||||
if (!SetEvent(interrupt->event)) {
|
if (!SetEvent(interrupt->event)) {
|
||||||
ftdm_log(FTDM_LOG_ERROR, "Failed to signal interrupt\n");
|
ftdm_log(FTDM_LOG_ERROR, "Failed to signal interrupt\n");
|
||||||
return FTDM_FAIL;
|
return FTDM_FAIL;
|
||||||
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
int err;
|
int err;
|
||||||
|
@ -404,6 +405,7 @@ FT_DECLARE(ftdm_status_t) ftdm_interrupt_destroy(ftdm_interrupt_t **ininterrupt)
|
||||||
#else
|
#else
|
||||||
close(interrupt->readfd);
|
close(interrupt->readfd);
|
||||||
close(interrupt->writefd);
|
close(interrupt->writefd);
|
||||||
|
|
||||||
interrupt->readfd = -1;
|
interrupt->readfd = -1;
|
||||||
interrupt->writefd = -1;
|
interrupt->writefd = -1;
|
||||||
#endif
|
#endif
|
||||||
|
@ -416,6 +418,7 @@ FT_DECLARE(ftdm_status_t) ftdm_interrupt_multiple_wait(ftdm_interrupt_t *interru
|
||||||
{
|
{
|
||||||
int numdevices = 0;
|
int numdevices = 0;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
#if defined(__WINDOWS__)
|
#if defined(__WINDOWS__)
|
||||||
DWORD res = 0;
|
DWORD res = 0;
|
||||||
HANDLE ints[20];
|
HANDLE ints[20];
|
||||||
|
@ -428,6 +431,7 @@ FT_DECLARE(ftdm_status_t) ftdm_interrupt_multiple_wait(ftdm_interrupt_t *interru
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
ints[i] = interrupts[i]->event;
|
ints[i] = interrupts[i]->event;
|
||||||
if (interrupts[i]->device != FTDM_INVALID_SOCKET) {
|
if (interrupts[i]->device != FTDM_INVALID_SOCKET) {
|
||||||
|
|
||||||
ints[size+numdevices] = interrupts[i]->device;
|
ints[size+numdevices] = interrupts[i]->device;
|
||||||
numdevices++;
|
numdevices++;
|
||||||
}
|
}
|
||||||
|
@ -454,7 +458,7 @@ FT_DECLARE(ftdm_status_t) ftdm_interrupt_multiple_wait(ftdm_interrupt_t *interru
|
||||||
struct pollfd ints[size*2];
|
struct pollfd ints[size*2];
|
||||||
|
|
||||||
memset(&ints, 0, sizeof(ints));
|
memset(&ints, 0, sizeof(ints));
|
||||||
|
pollagain:
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
ints[i].events = POLLIN;
|
ints[i].events = POLLIN;
|
||||||
ints[i].revents = 0;
|
ints[i].revents = 0;
|
||||||
|
@ -463,6 +467,7 @@ FT_DECLARE(ftdm_status_t) ftdm_interrupt_multiple_wait(ftdm_interrupt_t *interru
|
||||||
ints[size+numdevices].events = POLLIN;
|
ints[size+numdevices].events = POLLIN;
|
||||||
ints[size+numdevices].revents = 0;
|
ints[size+numdevices].revents = 0;
|
||||||
ints[size+numdevices].fd = interrupts[i]->device;
|
ints[size+numdevices].fd = interrupts[i]->device;
|
||||||
|
|
||||||
numdevices++;
|
numdevices++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -470,6 +475,9 @@ FT_DECLARE(ftdm_status_t) ftdm_interrupt_multiple_wait(ftdm_interrupt_t *interru
|
||||||
res = poll(ints, size + numdevices, ms);
|
res = poll(ints, size + numdevices, ms);
|
||||||
|
|
||||||
if (res == -1) {
|
if (res == -1) {
|
||||||
|
if (errno == EINTR) {
|
||||||
|
goto pollagain;
|
||||||
|
}
|
||||||
ftdm_log(FTDM_LOG_CRIT, "interrupt poll failed (%s)\n", strerror(errno));
|
ftdm_log(FTDM_LOG_CRIT, "interrupt poll failed (%s)\n", strerror(errno));
|
||||||
return FTDM_FAIL;
|
return FTDM_FAIL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue