View | Details | Raw Unified | Return to bug 138486
Collapse All | Expand All

(-)www/apache22-peruser-mpm-r57/Makefile (+1 lines)
Lines 18-23 Link Here
18
SLAVE_PORT_MPM=		peruser
18
SLAVE_PORT_MPM=		peruser
19
EXTRA_PATCHES+=		${.CURDIR}/files/httpd-2.2.3-peruser-0.3.0.patch
19
EXTRA_PATCHES+=		${.CURDIR}/files/httpd-2.2.3-peruser-0.3.0.patch
20
EXTRA_PATCHES+=		${.CURDIR}/files/httpd-2.2.3-peruser-0.3.0-dc3.patch
20
EXTRA_PATCHES+=		${.CURDIR}/files/httpd-2.2.3-peruser-0.3.0-dc3.patch
21
EXTRA_PATCHES+=		${.CURDIR}/files/httpd-2.2.3-peruser-0.3.0-dc3-r57.patch
21
WITH_MPM=		${SLAVE_PORT_MPM}
22
WITH_MPM=		${SLAVE_PORT_MPM}
22
SLAVE_DESIGNED_FOR=	2.2.11	# 2.2.3 to be honest, but works fine on 2.2.11
23
SLAVE_DESIGNED_FOR=	2.2.11	# 2.2.3 to be honest, but works fine on 2.2.11
23
24
(-)www/apache22-peruser-mpm-r57/files/httpd-2.2.3-peruser-0.3.0-dc3-r57.patch (+275 lines)
Line 0 Link Here
1
--- server/mpm/experimental/peruser/peruser.c	(revision 55)
2
+++ server/mpm/experimental/peruser/peruser.c	(revision 57)
3
@@ -320,7 +320,7 @@
4
  * process.
5
  */
6
 static apr_size_t child_info_size;
7
-static child_info *child_info_image;
8
+static child_info *child_info_image = NULL;
9
 static child_grace_info_t *child_grace_info_table;
10
 struct ap_ctable *ap_child_table;
11
 
12
@@ -936,7 +936,7 @@
13
     msg.msg_iovlen  = 5;
14
 
15
     cmsg = apr_palloc(pool, sizeof(*cmsg) + sizeof(sock_fd));
16
-    cmsg->cmsg_len   = sizeof(*cmsg) + sizeof(sock_fd);
17
+    cmsg->cmsg_len   = CMSG_LEN(sizeof(sock_fd));
18
     cmsg->cmsg_level = SOL_SOCKET;
19
     cmsg->cmsg_type  = SCM_RIGHTS;
20
 
21
@@ -1034,9 +1034,10 @@
22
         ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, "apr_os_sock_get");
23
     }
24
 
25
-    _DBG("child_num=%d sock=%ld sock_fd=%d\n", my_child_num, sock, sock_fd);
26
+    _DBG("child_num=%d sock=%ld sock_fd=%d", my_child_num, sock, sock_fd);
27
     _DBG("type=%s %d", child_type_string(CHILD_INFO_TABLE[my_child_num].type), my_child_num);
28
 
29
+#ifdef _OSD_POSIX
30
     if (sock_fd >= FD_SETSIZE)
31
     {
32
         ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL,
33
@@ -1048,6 +1049,7 @@
34
         _DBG("child_num=%d: exiting with error", my_child_num);
35
         return;
36
     }
37
+#endif
38
 
39
     if (CHILD_INFO_TABLE[my_child_num].sock_fd < 0)
40
     {
41
@@ -1300,7 +1302,7 @@
42
     msg.msg_iovlen  = 5;
43
 
44
     cmsg = apr_palloc(r->pool, sizeof(*cmsg) + sizeof(sock_fd));
45
-    cmsg->cmsg_len   = sizeof(*cmsg) + sizeof(sock_fd);
46
+    cmsg->cmsg_len   = CMSG_LEN(sizeof(sock_fd));
47
     cmsg->cmsg_level = SOL_SOCKET;
48
     cmsg->cmsg_type  = SCM_RIGHTS;
49
 
50
@@ -1309,7 +1311,6 @@
51
     msg.msg_control    = cmsg;
52
     msg.msg_controllen = cmsg->cmsg_len;
53
 
54
-
55
     if (processor->status == CHILD_STATUS_STANDBY)
56
     {
57
         _DBG("Activating child #%d", processor->id);
58
@@ -1374,7 +1375,7 @@
59
     iov[3].iov_len  = HUGE_STRING_LEN;
60
 
61
     cmsg = apr_palloc(ptrans, sizeof(*cmsg) + sizeof(trans_sock_fd));
62
-    cmsg->cmsg_len = sizeof(*cmsg) + sizeof(trans_sock_fd);
63
+    cmsg->cmsg_len = CMSG_LEN(sizeof(trans_sock_fd));
64
 
65
     msg.msg_name       = NULL;
66
     msg.msg_namelen    = 0;
67
@@ -1424,32 +1425,32 @@
68
     apr_cpystrn(headers, buff, header_len + 1);
69
     _DBG("header_len=%d headers=\"%s\"", header_len, headers);
70
 
71
-if (header_len) {    
72
-    _DBG("header_len > 0, we got a request", 0);
73
-    /* -- store received data into an brigade and add
74
-          it to the current transaction's pool -- */
75
-    bucket = apr_bucket_eos_create(alloc);
76
-    APR_BRIGADE_INSERT_HEAD(bb, bucket);
77
-    bucket = apr_bucket_socket_create(*trans_sock, alloc);
78
-    APR_BRIGADE_INSERT_HEAD(bb, bucket);
79
-
80
-    if (body_len) {
81
-        body = (char*)&buff[header_len + 1];
82
-        _DBG("body_len=%d body=\"%s\"", body_len, body);
83
-
84
-        bucket = apr_bucket_heap_create(body, body_len, NULL, alloc);
85
+    if (header_len) {    
86
+        _DBG("header_len > 0, we got a request", 0);
87
+        /* -- store received data into an brigade and add
88
+           it to the current transaction's pool -- */
89
+        bucket = apr_bucket_eos_create(alloc);
90
         APR_BRIGADE_INSERT_HEAD(bb, bucket);
91
+        bucket = apr_bucket_socket_create(*trans_sock, alloc);
92
+        APR_BRIGADE_INSERT_HEAD(bb, bucket);
93
+        
94
+        if (body_len) {
95
+            body = (char*)&buff[header_len + 1];
96
+            _DBG("body_len=%d body=\"%s\"", body_len, body);
97
+            
98
+            bucket = apr_bucket_heap_create(body, body_len, NULL, alloc);
99
+            APR_BRIGADE_INSERT_HEAD(bb, bucket);
100
+        } else {
101
+            _DBG("There is no body",0);
102
+        }
103
+        
104
+        bucket = apr_bucket_heap_create(headers, header_len, NULL, alloc);
105
+        
106
+        APR_BRIGADE_INSERT_HEAD(bb, bucket);
107
+        apr_pool_userdata_set(bb, "PERUSER_SOCKETS", NULL, ptrans);
108
     } else {
109
-        _DBG("There is no body",0);
110
+        _DBG("header_len == 0, we got a socket only", 0);
111
     }
112
-
113
-    bucket = apr_bucket_heap_create(headers, header_len, NULL, alloc);
114
-
115
-    APR_BRIGADE_INSERT_HEAD(bb, bucket);
116
-    apr_pool_userdata_set(bb, "PERUSER_SOCKETS", NULL, ptrans);
117
-} else {
118
-    _DBG("header_len == 0, we got a socket only", 0);
119
-}
120
     _DBG("returning 0", 0);
121
     return 0;
122
 }
123
@@ -2608,6 +2609,12 @@
124
     ++ap_my_generation;
125
     ap_scoreboard_image->global->running_generation = ap_my_generation;
126
     
127
+    /* cleanup sockets */
128
+    for (i = 0; i < NUM_SENV; i++) {
129
+        close(SENV[i].input);
130
+        close(SENV[i].output);
131
+    }
132
+
133
     if (is_graceful) {
134
         char char_of_death = AP_PERUSER_CHAR_OF_DEATH;
135
 
136
@@ -2696,14 +2703,6 @@
137
         }
138
         _DBG("Total children of %d leaving behind for graceful restart (%d living)", 
139
                        grace_children, grace_children_alive);
140
-
141
-       /* destroy server_env_image */
142
-        for (i = 0; i < NUM_SENV; i++)
143
-        {
144
-            close(SENV[i].input);
145
-            close(SENV[i].output);
146
-        }
147
-       cleanup_server_environments(NULL);
148
     }
149
     else {
150
 	/* Kill 'em off */
151
@@ -2861,40 +2860,41 @@
152
         return rv;
153
     }
154
 
155
+    if (!child_info_image) {
156
+        _DBG("Initializing child_info_table", 0);
157
+        child_info_size = tmp_server_limit * sizeof(child_info_t) + sizeof(apr_size_t);
158
 
159
-    _DBG("Initializing child_info_table", 0);
160
-    child_info_size = tmp_server_limit * sizeof(child_info_t) + sizeof(apr_size_t);
161
+        rv = apr_shm_create(&child_info_shm, child_info_size, NULL, global_pool);
162
 
163
-    rv = apr_shm_create(&child_info_shm, child_info_size, NULL, global_pool);
164
+        /*  if ((rv != APR_SUCCESS) && (rv != APR_ENOTIMPL)) { */
165
+        if (rv != APR_SUCCESS) {
166
+            _DBG("shared memory creation failed", 0);
167
 
168
-/*  if ((rv != APR_SUCCESS) && (rv != APR_ENOTIMPL)) { */
169
-    if (rv != APR_SUCCESS) {
170
-        _DBG("shared memory creation failed", 0);
171
+            ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
172
+                         "Unable to create shared memory segment "
173
+                         "(anonymous shared memory failure)");
174
+        }
175
+        else if (rv == APR_ENOTIMPL) {
176
+            _DBG("anonymous shared memory not available", 0);
177
+            /* TODO: make up a filename and do name-based shmem */
178
+        }
179
 
180
-        ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
181
-                     "Unable to create shared memory segment "
182
-                     "(anonymous shared memory failure)");
183
-    }
184
-    else if (rv == APR_ENOTIMPL) {
185
-        _DBG("anonymous shared memory not available", 0);
186
-        /* TODO: make up a filename and do name-based shmem */
187
-    }
188
+        if (rv || !(shmem = apr_shm_baseaddr_get(child_info_shm))) {
189
+            _DBG("apr_shm_baseaddr_get() failed", 0);
190
+            return HTTP_INTERNAL_SERVER_ERROR;
191
+        }
192
 
193
-    if (rv || !(shmem = apr_shm_baseaddr_get(child_info_shm))) {
194
-        _DBG("apr_shm_baseaddr_get() failed", 0);
195
-        return HTTP_INTERNAL_SERVER_ERROR;
196
+        memset(shmem, 0, child_info_size);
197
+        child_info_image = (child_info*)apr_palloc(global_pool, sizeof(child_info));
198
+        child_info_image->control = (child_info_control*)shmem;
199
+        shmem += sizeof(child_info_control);
200
+        child_info_image->table = (child_info_t*)shmem;
201
     }
202
 
203
-    memset(shmem, 0, sizeof(child_info_size));
204
-    child_info_image = (child_info*)calloc(1, sizeof(child_info_size));
205
-    child_info_image->control = (child_info_control*)shmem;
206
-    shmem += sizeof(child_info_control*);
207
-    child_info_image->table = (child_info_t*)shmem;
208
-
209
+    _DBG("Clearing child_info_table");
210
     child_info_image->control->num = 0;
211
 
212
-    for (i = 0; i < tmp_server_limit; i++)
213
-    {
214
+    for (i = 0; i < tmp_server_limit; i++) {
215
         CHILD_INFO_TABLE[i].pid     = 0;
216
         CHILD_INFO_TABLE[i].senv    = (server_env_t*)NULL;
217
         CHILD_INFO_TABLE[i].type    = CHILD_TYPE_UNKNOWN;
218
@@ -2927,25 +2927,23 @@
219
             return HTTP_INTERNAL_SERVER_ERROR;
220
         }
221
 
222
-        memset(shmem, 0, sizeof(server_env_size));
223
-        server_env_image = (server_env*)calloc(1, sizeof(server_env_size));
224
+        memset(shmem, 0, server_env_size);
225
+        server_env_image = (server_env*)apr_palloc(global_pool, sizeof(server_env));
226
         server_env_image->control = (server_env_control*)shmem;
227
-        shmem += sizeof(server_env_control*);
228
+        shmem += sizeof(server_env_control);
229
         server_env_image->table = (server_env_t*)shmem;
230
     }
231
-
232
-    if(restart_num <= 2) {
233
-        _DBG("Cleaning server environments table");
234
     
235
-        server_env_image->control->num = 0;
236
-        for (i = 0; i < tmp_server_limit; i++) {
237
-            SENV[i].processor_id = -1;
238
-            SENV[i].uid          = -1;
239
-            SENV[i].gid          = -1;
240
-            SENV[i].chroot       = NULL;
241
-            SENV[i].input        = -1;
242
-            SENV[i].output       = -1;
243
-        }
244
+    _DBG("Clearing server environment table");
245
+    server_env_image->control->num = 0;    
246
+
247
+    for (i = 0; i < tmp_server_limit; i++) {
248
+        SENV[i].processor_id = -1;
249
+        SENV[i].uid          = -1;
250
+        SENV[i].gid          = -1;
251
+        SENV[i].chroot       = NULL;
252
+        SENV[i].input        = -1;
253
+        SENV[i].output       = -1;
254
     }
255
 
256
     return OK;
257
@@ -3196,14 +3194,11 @@
258
                             "Error: Directive %s> takes one argument", cmd->cmd->name);
259
     }
260
 
261
-    /*	Check for existing processors on first launch and between gracefuls */
262
-    if (restart_num == 1 || is_graceful) {
263
-        server_env_t *old_senv = find_senv_by_name(senv.name);
264
+    server_env_t *old_senv = find_senv_by_name(senv.name);
265
 
266
-        if (old_senv) {
267
-            return apr_psprintf(cmd->temp_pool,
268
-                                "Error: Processor %s already defined", senv.name);
269
-        }
270
+    if (old_senv) {
271
+        return apr_psprintf(cmd->temp_pool,
272
+                            "Error: Processor %s already defined", senv.name);
273
     }
274
 
275
     senv.nice_lvl 		= 0;

Return to bug 138486