put bandaid on xmlrpc-c to not destroy the box for no reason
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8715 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
0c93b9d1bf
commit
a86de775b9
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
#include "socket_unix.h"
|
#include "socket_unix.h"
|
||||||
|
|
||||||
|
#define sane_close(_it) if (_it > 0) {close(_it) ; _it = -1; }
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int interruptorFd;
|
int interruptorFd;
|
||||||
|
@ -50,19 +50,19 @@ typedef struct {
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
initInterruptPipe(interruptPipe * const pipeP,
|
initInterruptPipe(interruptPipe * pipeP,
|
||||||
const char ** const errorP) {
|
const char ** const errorP) {
|
||||||
|
|
||||||
int pipeFd[2];
|
int pipeFd[2] = {-1, -1};
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = pipe(pipeFd);
|
rc = pipe(pipeFd);
|
||||||
|
|
||||||
if (rc != 0)
|
if (rc != 0) {
|
||||||
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));
|
||||||
else {
|
} else {
|
||||||
*errorP = NULL;
|
*errorP = NULL;
|
||||||
pipeP->interruptorFd = pipeFd[1];
|
pipeP->interruptorFd = pipeFd[1];
|
||||||
pipeP->interrupteeFd = pipeFd[0];
|
pipeP->interrupteeFd = pipeFd[0];
|
||||||
|
@ -72,10 +72,14 @@ initInterruptPipe(interruptPipe * const pipeP,
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
termInterruptPipe(interruptPipe const pipe) {
|
termInterruptPipe(interruptPipe pipe) {
|
||||||
|
|
||||||
close(pipe.interruptorFd);
|
if (pipe.interruptorFd) {
|
||||||
close(pipe.interrupteeFd);
|
sane_close(pipe.interruptorFd);
|
||||||
|
}
|
||||||
|
if (pipe.interrupteeFd) {
|
||||||
|
sane_close(pipe.interrupteeFd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -153,7 +157,7 @@ channelDestroy(TChannel * const channelP) {
|
||||||
termInterruptPipe(socketUnixP->interruptPipe);
|
termInterruptPipe(socketUnixP->interruptPipe);
|
||||||
|
|
||||||
if (!socketUnixP->userSuppliedFd)
|
if (!socketUnixP->userSuppliedFd)
|
||||||
close(socketUnixP->fd);
|
sane_close(socketUnixP->fd);
|
||||||
|
|
||||||
free(socketUnixP);
|
free(socketUnixP);
|
||||||
}
|
}
|
||||||
|
@ -498,7 +502,6 @@ makeChannelFromFd(int const fd,
|
||||||
|
|
||||||
if (!*errorP) {
|
if (!*errorP) {
|
||||||
ChannelCreate(&channelVtbl, socketUnixP, &channelP);
|
ChannelCreate(&channelVtbl, socketUnixP, &channelP);
|
||||||
|
|
||||||
if (channelP == NULL)
|
if (channelP == NULL)
|
||||||
xmlrpc_asprintf(errorP, "Unable to allocate memory for "
|
xmlrpc_asprintf(errorP, "Unable to allocate memory for "
|
||||||
"channel descriptor.");
|
"channel descriptor.");
|
||||||
|
@ -564,7 +567,7 @@ chanSwitchDestroy(TChanSwitch * const chanSwitchP) {
|
||||||
termInterruptPipe(socketUnixP->interruptPipe);
|
termInterruptPipe(socketUnixP->interruptPipe);
|
||||||
|
|
||||||
if (!socketUnixP->userSuppliedFd)
|
if (!socketUnixP->userSuppliedFd)
|
||||||
close(socketUnixP->fd);
|
sane_close(socketUnixP->fd);
|
||||||
|
|
||||||
free(socketUnixP);
|
free(socketUnixP);
|
||||||
}
|
}
|
||||||
|
@ -728,13 +731,13 @@ chanSwitchAccept(TChanSwitch * const chanSwitchP,
|
||||||
rc = accept(listenSocketP->fd, &peerAddr, &size);
|
rc = accept(listenSocketP->fd, &peerAddr, &size);
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
int const acceptedFd = rc;
|
int acceptedFd = rc;
|
||||||
|
|
||||||
createChannelForAccept(acceptedFd, peerAddr,
|
createChannelForAccept(acceptedFd, peerAddr,
|
||||||
&channelP, channelInfoPP, errorP);
|
&channelP, channelInfoPP, errorP);
|
||||||
|
|
||||||
if (*errorP)
|
if (*errorP)
|
||||||
close(acceptedFd);
|
sane_close(acceptedFd);
|
||||||
} else if (errno == EINTR)
|
} else if (errno == EINTR)
|
||||||
interrupted = TRUE;
|
interrupted = TRUE;
|
||||||
else
|
else
|
||||||
|
@ -884,7 +887,7 @@ ChanSwitchUnixCreate(unsigned short const portNumber,
|
||||||
xmlrpc_asprintf(errorP, "socket() failed with errno %d (%s)",
|
xmlrpc_asprintf(errorP, "socket() failed with errno %d (%s)",
|
||||||
errno, strerror(errno));
|
errno, strerror(errno));
|
||||||
else {
|
else {
|
||||||
int const socketFd = rc;
|
int socketFd = rc;
|
||||||
|
|
||||||
setSocketOptions(socketFd, errorP);
|
setSocketOptions(socketFd, errorP);
|
||||||
if (!*errorP) {
|
if (!*errorP) {
|
||||||
|
@ -896,7 +899,7 @@ ChanSwitchUnixCreate(unsigned short const portNumber,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*errorP)
|
if (*errorP)
|
||||||
close(socketFd);
|
sane_close(socketFd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue