Browse code

* Ported xmlrpc server blocking fix from OpenSIPS.

Juha Heinanen authored on 27/05/2009 16:13:29
Showing 4 changed files
... ...
@@ -1352,7 +1352,7 @@ waitForConnectionCapacity(outstandingConnList * const outstandingConnListP) {
1352 1352
 void
1353 1353
 ServerHandleSigchld(pid_t const pid) {
1354 1354
 
1355
-    ThreadHandleSigchld(pid);
1355
+    //ThreadHandleSigchld(pid);
1356 1356
 }
1357 1357
 #endif
1358 1358
 
... ...
@@ -1388,7 +1388,6 @@ destroyConnSocket(void * const userHandle) {
1388 1388
 }
1389 1389
 
1390 1390
 
1391
-#include "../../dprint.h"
1392 1391
 static void 
1393 1392
 serverRun2(TServer * const serverP) {
1394 1393
 
... ...
@@ -1423,6 +1422,8 @@ serverRun2(TServer * const serverP) {
1423 1422
             if (!error) {
1424 1423
                 addToOutstandingConnList(outstandingConnListP, connectionP);
1425 1424
                 ConnProcess(connectionP);
1425
+                SocketClose(connectedSocketP);
1426
+                
1426 1427
                 /* When connection is done (which could be later, courtesy
1427 1428
                    of a background thread), destroyConnSocket() will
1428 1429
                    destroy *connectedSocketP.
... ...
@@ -146,6 +146,13 @@ SocketCreate(const struct TSocketVtbl * const vtblP,
146 146
 
147 147
 
148 148
 
149
+void
150
+SocketClose(TSocket * const socketP) {
151
+    socketP->vtbl.close(socketP);
152
+}
153
+
154
+
155
+
149 156
 void
150 157
 SocketDestroy(TSocket * const socketP) {
151 158
 
... ...
@@ -14,6 +14,8 @@
14 14
 
15 15
 typedef struct in_addr TIPAddr;
16 16
 
17
+typedef void SocketCloseImpl(TSocket * const socketP);
18
+
17 19
 typedef void SocketDestroyImpl(TSocket * const socketP);
18 20
 
19 21
 typedef void SocketWriteImpl(TSocket *             const socketP,
... ...
@@ -57,6 +59,7 @@ typedef void SocketGetPeerNameImpl(TSocket *    const socketP,
57 59
                                    abyss_bool * const successP);
58 60
 
59 61
 struct TSocketVtbl {
62
+    SocketCloseImpl              * close;
60 63
     SocketDestroyImpl            * destroy;
61 64
     SocketWriteImpl              * write;
62 65
     SocketReadImpl               * read;
... ...
@@ -91,6 +94,9 @@ SocketInit(void);
91 94
 void
92 95
 SocketTerm(void);
93 96
 
97
+void
98
+SocketClose(TSocket *       const socketP);
99
+
94 100
 void
95 101
 SocketCreate(const struct TSocketVtbl * const vtblP,
96 102
              void *                     const implP,
... ...
@@ -102,6 +102,7 @@ SocketUnixTerm(void) {
102 102
 
103 103
 
104 104
 
105
+static SocketCloseImpl              socketClose;
105 106
 static SocketDestroyImpl            socketDestroy;
106 107
 static SocketWriteImpl              socketWrite;
107 108
 static SocketReadImpl               socketRead;
... ...
@@ -116,6 +117,7 @@ static SocketGetPeerNameImpl        socketGetPeerName;
116 117
 
117 118
 
118 119
 static struct TSocketVtbl const vtbl = {
120
+    &socketClose,
119 121
     &socketDestroy,
120 122
     &socketWrite,
121 123
     &socketRead,
... ...
@@ -189,14 +191,24 @@ SocketUnixCreateFd(int        const fd,
189 191
 }
190 192
 
191 193
 
194
+static void
195
+socketClose(TSocket * const socketP) {
196
+
197
+    struct socketUnix * const socketUnixP = socketP->implP;
198
+
199
+    if (!socketUnixP->userSuppliedFd && socketUnixP->fd ) {
200
+        close(socketUnixP->fd);
201
+        socketUnixP->fd = 0;
202
+    }
203
+}
204
+
192 205
 
193 206
 static void
194 207
 socketDestroy(TSocket * const socketP) {
195 208
 
196 209
     struct socketUnix * const socketUnixP = socketP->implP;
197 210
 
198
-    if (!socketUnixP->userSuppliedFd)
199
-        close(socketUnixP->fd);
211
+    socketClose(socketP);
200 212
 
201 213
     free(socketUnixP);
202 214
 }