Module: sip-router Branch: master Commit: 9f6ac8e61b433fc81cd923e43e819c628be6ce88 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=9f6ac8e6...
Author: Juha Heinanen jh@tutpro.com Committer: Juha Heinanen jh@tutpro.com Date: Wed May 27 19:13:29 2009 +0300
* Ported xmlrpc server blocking fix from OpenSIPS.
---
modules_k/mi_xmlrpc/abyss_server.c | 5 +++-- modules_k/mi_xmlrpc/abyss_socket.c | 7 +++++++ modules_k/mi_xmlrpc/abyss_socket.h | 6 ++++++ modules_k/mi_xmlrpc/abyss_socket_unix.c | 16 ++++++++++++++-- 4 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/modules_k/mi_xmlrpc/abyss_server.c b/modules_k/mi_xmlrpc/abyss_server.c index c23606f..48219fc 100644 --- a/modules_k/mi_xmlrpc/abyss_server.c +++ b/modules_k/mi_xmlrpc/abyss_server.c @@ -1352,7 +1352,7 @@ waitForConnectionCapacity(outstandingConnList * const outstandingConnListP) { void ServerHandleSigchld(pid_t const pid) {
- ThreadHandleSigchld(pid); + //ThreadHandleSigchld(pid); } #endif
@@ -1388,7 +1388,6 @@ destroyConnSocket(void * const userHandle) { }
-#include "../../dprint.h" static void serverRun2(TServer * const serverP) {
@@ -1423,6 +1422,8 @@ serverRun2(TServer * const serverP) { if (!error) { addToOutstandingConnList(outstandingConnListP, connectionP); ConnProcess(connectionP); + SocketClose(connectedSocketP); + /* When connection is done (which could be later, courtesy of a background thread), destroyConnSocket() will destroy *connectedSocketP. diff --git a/modules_k/mi_xmlrpc/abyss_socket.c b/modules_k/mi_xmlrpc/abyss_socket.c index 8f3168a..7a367f0 100644 --- a/modules_k/mi_xmlrpc/abyss_socket.c +++ b/modules_k/mi_xmlrpc/abyss_socket.c @@ -147,6 +147,13 @@ SocketCreate(const struct TSocketVtbl * const vtblP,
void +SocketClose(TSocket * const socketP) { + socketP->vtbl.close(socketP); +} + + + +void SocketDestroy(TSocket * const socketP) {
assert(socketP->signature == socketSignature); diff --git a/modules_k/mi_xmlrpc/abyss_socket.h b/modules_k/mi_xmlrpc/abyss_socket.h index 000e099..90b429e 100644 --- a/modules_k/mi_xmlrpc/abyss_socket.h +++ b/modules_k/mi_xmlrpc/abyss_socket.h @@ -14,6 +14,8 @@
typedef struct in_addr TIPAddr;
+typedef void SocketCloseImpl(TSocket * const socketP); + typedef void SocketDestroyImpl(TSocket * const socketP);
typedef void SocketWriteImpl(TSocket * const socketP, @@ -57,6 +59,7 @@ typedef void SocketGetPeerNameImpl(TSocket * const socketP, abyss_bool * const successP);
struct TSocketVtbl { + SocketCloseImpl * close; SocketDestroyImpl * destroy; SocketWriteImpl * write; SocketReadImpl * read; @@ -92,6 +95,9 @@ void SocketTerm(void);
void +SocketClose(TSocket * const socketP); + +void SocketCreate(const struct TSocketVtbl * const vtblP, void * const implP, TSocket ** const socketPP); diff --git a/modules_k/mi_xmlrpc/abyss_socket_unix.c b/modules_k/mi_xmlrpc/abyss_socket_unix.c index cb87abd..c5bdccd 100644 --- a/modules_k/mi_xmlrpc/abyss_socket_unix.c +++ b/modules_k/mi_xmlrpc/abyss_socket_unix.c @@ -102,6 +102,7 @@ SocketUnixTerm(void) {
+static SocketCloseImpl socketClose; static SocketDestroyImpl socketDestroy; static SocketWriteImpl socketWrite; static SocketReadImpl socketRead; @@ -116,6 +117,7 @@ static SocketGetPeerNameImpl socketGetPeerName;
static struct TSocketVtbl const vtbl = { + &socketClose, &socketDestroy, &socketWrite, &socketRead, @@ -189,14 +191,24 @@ SocketUnixCreateFd(int const fd, }
+static void +socketClose(TSocket * const socketP) { + + struct socketUnix * const socketUnixP = socketP->implP; + + if (!socketUnixP->userSuppliedFd && socketUnixP->fd ) { + close(socketUnixP->fd); + socketUnixP->fd = 0; + } +} +
static void socketDestroy(TSocket * const socketP) {
struct socketUnix * const socketUnixP = socketP->implP;
- if (!socketUnixP->userSuppliedFd) - close(socketUnixP->fd); + socketClose(socketP);
free(socketUnixP); }