[Freeswitch-svn] [commit] r8720 - in freeswitch/trunk/libs/xmlrpc-c/lib: abyss/src util/include
Freeswitch SVN
anthm at freeswitch.org
Thu May 29 12:10:18 EDT 2008
Author: anthm
Date: Thu May 29 12:10:18 2008
New Revision: 8720
Modified:
freeswitch/trunk/libs/xmlrpc-c/lib/abyss/src/socket_unix.c
freeswitch/trunk/libs/xmlrpc-c/lib/util/include/mallocvar.h
Log:
umm, yeah.....
Modified: freeswitch/trunk/libs/xmlrpc-c/lib/abyss/src/socket_unix.c
==============================================================================
--- freeswitch/trunk/libs/xmlrpc-c/lib/abyss/src/socket_unix.c (original)
+++ freeswitch/trunk/libs/xmlrpc-c/lib/abyss/src/socket_unix.c Thu May 29 12:10:18 2008
@@ -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 @@
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 @@
struct socketUnix * const socketUnixP = channelP->implP;
- termInterruptPipe(socketUnixP->interruptPipe);
+ termInterruptPipe(&socketUnixP->interruptPipe);
if (!socketUnixP->userSuppliedFd)
sane_close(socketUnixP->fd);
@@ -510,7 +510,7 @@
*errorP = NULL;
}
if (*errorP)
- termInterruptPipe(socketUnixP->interruptPipe);
+ termInterruptPipe(&socketUnixP->interruptPipe);
}
if (*errorP)
free(socketUnixP);
@@ -564,7 +564,7 @@
struct socketUnix * const socketUnixP = chanSwitchP->implP;
- termInterruptPipe(socketUnixP->interruptPipe);
+ termInterruptPipe(&socketUnixP->interruptPipe);
if (!socketUnixP->userSuppliedFd)
sane_close(socketUnixP->fd);
@@ -663,7 +663,7 @@
struct socketUnix * acceptedSocketP;
MALLOCVAR(acceptedSocketP);
-
+
if (!acceptedSocketP)
xmlrpc_asprintf(errorP, "Unable to allocate memory");
else {
@@ -805,7 +805,7 @@
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 "
Modified: freeswitch/trunk/libs/xmlrpc-c/lib/util/include/mallocvar.h
==============================================================================
--- freeswitch/trunk/libs/xmlrpc-c/lib/util/include/mallocvar.h (original)
+++ freeswitch/trunk/libs/xmlrpc-c/lib/util/include/mallocvar.h Thu May 29 12:10:18 2008
@@ -102,7 +102,7 @@
#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)
More information about the Freeswitch-svn
mailing list