mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-02-07 22:03:50 +00:00
umm, yeah.....
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8720 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
e120728d6e
commit
a869b56a61
@ -40,11 +40,12 @@
|
|||||||
|
|
||||||
#include "socket_unix.h"
|
#include "socket_unix.h"
|
||||||
|
|
||||||
#define sane_close(_it) if (_it > 0) {close(_it) ; _it = -1; }
|
#define sane_close(_it) if (_it > -1) {close(_it) ; _it = -1; }
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int interruptorFd;
|
int interruptorFd;
|
||||||
int interrupteeFd;
|
int interrupteeFd;
|
||||||
|
int inuse;
|
||||||
} interruptPipe;
|
} interruptPipe;
|
||||||
|
|
||||||
|
|
||||||
@ -62,23 +63,22 @@ initInterruptPipe(interruptPipe * pipeP,
|
|||||||
xmlrpc_asprintf(errorP, "Unable to create a pipe to use to interrupt "
|
xmlrpc_asprintf(errorP, "Unable to create a pipe to use to interrupt "
|
||||||
"waits. pipe() failed with errno %d (%s)",
|
"waits. pipe() failed with errno %d (%s)",
|
||||||
errno, strerror(errno));
|
errno, strerror(errno));
|
||||||
|
pipeP->inuse = 0;
|
||||||
} else {
|
} else {
|
||||||
*errorP = NULL;
|
*errorP = NULL;
|
||||||
pipeP->interruptorFd = pipeFd[1];
|
pipeP->interruptorFd = pipeFd[1];
|
||||||
pipeP->interrupteeFd = pipeFd[0];
|
pipeP->interrupteeFd = pipeFd[0];
|
||||||
|
pipeP->inuse = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
termInterruptPipe(interruptPipe pipe) {
|
termInterruptPipe(interruptPipe *pipeP) {
|
||||||
|
if (pipeP->inuse) {
|
||||||
if (pipe.interruptorFd) {
|
sane_close(pipeP->interruptorFd);
|
||||||
sane_close(pipe.interruptorFd);
|
sane_close(pipeP->interrupteeFd);
|
||||||
}
|
|
||||||
if (pipe.interrupteeFd) {
|
|
||||||
sane_close(pipe.interrupteeFd);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ channelDestroy(TChannel * const channelP) {
|
|||||||
|
|
||||||
struct socketUnix * const socketUnixP = channelP->implP;
|
struct socketUnix * const socketUnixP = channelP->implP;
|
||||||
|
|
||||||
termInterruptPipe(socketUnixP->interruptPipe);
|
termInterruptPipe(&socketUnixP->interruptPipe);
|
||||||
|
|
||||||
if (!socketUnixP->userSuppliedFd)
|
if (!socketUnixP->userSuppliedFd)
|
||||||
sane_close(socketUnixP->fd);
|
sane_close(socketUnixP->fd);
|
||||||
@ -510,7 +510,7 @@ makeChannelFromFd(int const fd,
|
|||||||
*errorP = NULL;
|
*errorP = NULL;
|
||||||
}
|
}
|
||||||
if (*errorP)
|
if (*errorP)
|
||||||
termInterruptPipe(socketUnixP->interruptPipe);
|
termInterruptPipe(&socketUnixP->interruptPipe);
|
||||||
}
|
}
|
||||||
if (*errorP)
|
if (*errorP)
|
||||||
free(socketUnixP);
|
free(socketUnixP);
|
||||||
@ -564,7 +564,7 @@ chanSwitchDestroy(TChanSwitch * const chanSwitchP) {
|
|||||||
|
|
||||||
struct socketUnix * const socketUnixP = chanSwitchP->implP;
|
struct socketUnix * const socketUnixP = chanSwitchP->implP;
|
||||||
|
|
||||||
termInterruptPipe(socketUnixP->interruptPipe);
|
termInterruptPipe(&socketUnixP->interruptPipe);
|
||||||
|
|
||||||
if (!socketUnixP->userSuppliedFd)
|
if (!socketUnixP->userSuppliedFd)
|
||||||
sane_close(socketUnixP->fd);
|
sane_close(socketUnixP->fd);
|
||||||
@ -805,7 +805,7 @@ createChanSwitch(int const fd,
|
|||||||
if (!*errorP) {
|
if (!*errorP) {
|
||||||
ChanSwitchCreate(&chanSwitchVtbl, socketUnixP, &chanSwitchP);
|
ChanSwitchCreate(&chanSwitchVtbl, socketUnixP, &chanSwitchP);
|
||||||
if (*errorP)
|
if (*errorP)
|
||||||
termInterruptPipe(socketUnixP->interruptPipe);
|
termInterruptPipe(&socketUnixP->interruptPipe);
|
||||||
|
|
||||||
if (chanSwitchP == NULL)
|
if (chanSwitchP == NULL)
|
||||||
xmlrpc_asprintf(errorP, "Unable to allocate memory for "
|
xmlrpc_asprintf(errorP, "Unable to allocate memory for "
|
||||||
|
@ -102,7 +102,7 @@ do { \
|
|||||||
|
|
||||||
|
|
||||||
#define MALLOCVAR(varName) \
|
#define MALLOCVAR(varName) \
|
||||||
varName = malloc(sizeof(*varName))
|
if (varName = malloc(sizeof(*varName))) memset(varName, 0, sizeof(*varName))
|
||||||
|
|
||||||
#define MALLOCVAR_NOFAIL(varName) \
|
#define MALLOCVAR_NOFAIL(varName) \
|
||||||
do {if ((varName = malloc(sizeof(*varName))) == NULL) abort();} while(0)
|
do {if ((varName = malloc(sizeof(*varName))) == NULL) abort();} while(0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user