[Freeswitch-svn] [commit] r8715 - freeswitch/trunk/libs/xmlrpc-c/lib/abyss/src
Freeswitch SVN
anthm at freeswitch.org
Wed May 28 21:23:15 EDT 2008
Author: anthm
Date: Wed May 28 21:23:14 2008
New Revision: 8715
Modified:
freeswitch/trunk/libs/xmlrpc-c/lib/abyss/src/socket_unix.c
Log:
put bandaid on xmlrpc-c to not destroy the box for no reason
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 Wed May 28 21:23:14 2008
@@ -40,7 +40,7 @@
#include "socket_unix.h"
-
+#define sane_close(_it) if (_it > 0) {close(_it) ; _it = -1; }
typedef struct {
int interruptorFd;
@@ -50,19 +50,19 @@
static void
-initInterruptPipe(interruptPipe * const pipeP,
+initInterruptPipe(interruptPipe * pipeP,
const char ** const errorP) {
- int pipeFd[2];
+ int pipeFd[2] = {-1, -1};
int rc;
rc = pipe(pipeFd);
- if (rc != 0)
+ if (rc != 0) {
xmlrpc_asprintf(errorP, "Unable to create a pipe to use to interrupt "
"waits. pipe() failed with errno %d (%s)",
errno, strerror(errno));
- else {
+ } else {
*errorP = NULL;
pipeP->interruptorFd = pipeFd[1];
pipeP->interrupteeFd = pipeFd[0];
@@ -72,10 +72,14 @@
static void
-termInterruptPipe(interruptPipe const pipe) {
+termInterruptPipe(interruptPipe pipe) {
- close(pipe.interruptorFd);
- close(pipe.interrupteeFd);
+ if (pipe.interruptorFd) {
+ sane_close(pipe.interruptorFd);
+ }
+ if (pipe.interrupteeFd) {
+ sane_close(pipe.interrupteeFd);
+ }
}
@@ -153,7 +157,7 @@
termInterruptPipe(socketUnixP->interruptPipe);
if (!socketUnixP->userSuppliedFd)
- close(socketUnixP->fd);
+ sane_close(socketUnixP->fd);
free(socketUnixP);
}
@@ -484,13 +488,13 @@
struct socketUnix * socketUnixP;
MALLOCVAR(socketUnixP);
-
+
if (socketUnixP == NULL)
xmlrpc_asprintf(errorP, "Unable to allocate memory for Unix "
"channel descriptor");
else {
TChannel * channelP;
-
+
socketUnixP->fd = fd;
socketUnixP->userSuppliedFd = TRUE;
@@ -498,7 +502,6 @@
if (!*errorP) {
ChannelCreate(&channelVtbl, socketUnixP, &channelP);
-
if (channelP == NULL)
xmlrpc_asprintf(errorP, "Unable to allocate memory for "
"channel descriptor.");
@@ -564,7 +567,7 @@
termInterruptPipe(socketUnixP->interruptPipe);
if (!socketUnixP->userSuppliedFd)
- close(socketUnixP->fd);
+ sane_close(socketUnixP->fd);
free(socketUnixP);
}
@@ -728,13 +731,13 @@
rc = accept(listenSocketP->fd, &peerAddr, &size);
if (rc >= 0) {
- int const acceptedFd = rc;
+ int acceptedFd = rc;
createChannelForAccept(acceptedFd, peerAddr,
&channelP, channelInfoPP, errorP);
if (*errorP)
- close(acceptedFd);
+ sane_close(acceptedFd);
} else if (errno == EINTR)
interrupted = TRUE;
else
@@ -884,7 +887,7 @@
xmlrpc_asprintf(errorP, "socket() failed with errno %d (%s)",
errno, strerror(errno));
else {
- int const socketFd = rc;
+ int socketFd = rc;
setSocketOptions(socketFd, errorP);
if (!*errorP) {
@@ -896,7 +899,7 @@
}
}
if (*errorP)
- close(socketFd);
+ sane_close(socketFd);
}
}
More information about the Freeswitch-svn
mailing list