From a869b56a61f4eeebeb1896dfbe0a80cdf0f173c1 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 29 May 2008 16:10:18 +0000 Subject: [PATCH] umm, yeah..... git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8720 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- libs/xmlrpc-c/lib/abyss/src/socket_unix.c | 26 +++++++++++----------- libs/xmlrpc-c/lib/util/include/mallocvar.h | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libs/xmlrpc-c/lib/abyss/src/socket_unix.c b/libs/xmlrpc-c/lib/abyss/src/socket_unix.c index c3d2c81c63..e554f0e54d 100644 --- a/libs/xmlrpc-c/lib/abyss/src/socket_unix.c +++ b/libs/xmlrpc-c/lib/abyss/src/socket_unix.c @@ -40,11 +40,12 @@ #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 { int interruptorFd; int interrupteeFd; + int inuse; } interruptPipe; @@ -62,23 +63,22 @@ initInterruptPipe(interruptPipe * pipeP, xmlrpc_asprintf(errorP, "Unable to create a pipe to use to interrupt " "waits. pipe() failed with errno %d (%s)", errno, strerror(errno)); + pipeP->inuse = 0; } else { *errorP = NULL; pipeP->interruptorFd = pipeFd[1]; pipeP->interrupteeFd = pipeFd[0]; + pipeP->inuse = 1; } } static void -termInterruptPipe(interruptPipe pipe) { - - if (pipe.interruptorFd) { - sane_close(pipe.interruptorFd); - } - if (pipe.interrupteeFd) { - sane_close(pipe.interrupteeFd); +termInterruptPipe(interruptPipe *pipeP) { + if (pipeP->inuse) { + sane_close(pipeP->interruptorFd); + sane_close(pipeP->interrupteeFd); } } @@ -154,7 +154,7 @@ channelDestroy(TChannel * const channelP) { struct socketUnix * const socketUnixP = channelP->implP; - termInterruptPipe(socketUnixP->interruptPipe); + termInterruptPipe(&socketUnixP->interruptPipe); if (!socketUnixP->userSuppliedFd) sane_close(socketUnixP->fd); @@ -510,7 +510,7 @@ makeChannelFromFd(int const fd, *errorP = NULL; } if (*errorP) - termInterruptPipe(socketUnixP->interruptPipe); + termInterruptPipe(&socketUnixP->interruptPipe); } if (*errorP) free(socketUnixP); @@ -564,7 +564,7 @@ chanSwitchDestroy(TChanSwitch * const chanSwitchP) { struct socketUnix * const socketUnixP = chanSwitchP->implP; - termInterruptPipe(socketUnixP->interruptPipe); + termInterruptPipe(&socketUnixP->interruptPipe); if (!socketUnixP->userSuppliedFd) sane_close(socketUnixP->fd); @@ -663,7 +663,7 @@ createChannelForAccept(int const acceptedFd, struct socketUnix * acceptedSocketP; MALLOCVAR(acceptedSocketP); - + if (!acceptedSocketP) xmlrpc_asprintf(errorP, "Unable to allocate memory"); else { @@ -805,7 +805,7 @@ createChanSwitch(int const fd, if (!*errorP) { ChanSwitchCreate(&chanSwitchVtbl, socketUnixP, &chanSwitchP); if (*errorP) - termInterruptPipe(socketUnixP->interruptPipe); + termInterruptPipe(&socketUnixP->interruptPipe); if (chanSwitchP == NULL) xmlrpc_asprintf(errorP, "Unable to allocate memory for " diff --git a/libs/xmlrpc-c/lib/util/include/mallocvar.h b/libs/xmlrpc-c/lib/util/include/mallocvar.h index 9048ec4f55..5dd9fc96e9 100644 --- a/libs/xmlrpc-c/lib/util/include/mallocvar.h +++ b/libs/xmlrpc-c/lib/util/include/mallocvar.h @@ -102,7 +102,7 @@ do { \ #define MALLOCVAR(varName) \ - varName = malloc(sizeof(*varName)) + if (varName = malloc(sizeof(*varName))) memset(varName, 0, sizeof(*varName)) #define MALLOCVAR_NOFAIL(varName) \ do {if ((varName = malloc(sizeof(*varName))) == NULL) abort();} while(0)