f997d134bcee6bfa4cd87b69acee96e80c5a358bpquerna/* Licensed to the Apache Software Foundation (ASF) under one or more
f997d134bcee6bfa4cd87b69acee96e80c5a358bpquerna * contributor license agreements. See the NOTICE file distributed with
f997d134bcee6bfa4cd87b69acee96e80c5a358bpquerna * this work for additional information regarding copyright ownership.
f997d134bcee6bfa4cd87b69acee96e80c5a358bpquerna * The ASF licenses this file to You under the Apache License, Version 2.0
f997d134bcee6bfa4cd87b69acee96e80c5a358bpquerna * (the "License"); you may not use this file except in compliance with
f997d134bcee6bfa4cd87b69acee96e80c5a358bpquerna * the License. You may obtain a copy of the License at
f997d134bcee6bfa4cd87b69acee96e80c5a358bpquerna * Unless required by applicable law or agreed to in writing, software
f997d134bcee6bfa4cd87b69acee96e80c5a358bpquerna * distributed under the License is distributed on an "AS IS" BASIS,
f997d134bcee6bfa4cd87b69acee96e80c5a358bpquerna * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
f997d134bcee6bfa4cd87b69acee96e80c5a358bpquerna * See the License for the specific language governing permissions and
f997d134bcee6bfa4cd87b69acee96e80c5a358bpquerna * limitations under the License.
f997d134bcee6bfa4cd87b69acee96e80c5a358bpquerna#define SPAWN_CHILDREN_INTERVAL (apr_time_from_sec(5))
52a5101047d0148d33df1f9f4f77b24bce7fdf70pquernastatic void simple_kill_random_child(simple_core_t * sc)
52a5101047d0148d33df1f9f4f77b24bce7fdf70pquerna /* See comment in simple_spawn_child for why we check here. */
f47612d41722d85fe2d698c43316a36fbccd4685pquerna apr_hash_set(sc->children, &child->pid, sizeof(child->pid), NULL);
f47612d41722d85fe2d698c43316a36fbccd4685pquerna /* TODO: recycle child object */
f47612d41722d85fe2d698c43316a36fbccd4685pquernastatic void clean_child_exit(int code) __attribute__ ((noreturn));
f47612d41722d85fe2d698c43316a36fbccd4685pquerna /* TODO: Pool cleanups.... sigh. */
5bfaaf573bacb45c1cf290ce85ecc676587e8a64jim /* Although we could cut this off 'earlier', and not even invoke this
52a5101047d0148d33df1f9f4f77b24bce7fdf70pquerna * function, I would like to keep the functions invoked when in debug mode
52a5101047d0148d33df1f9f4f77b24bce7fdf70pquerna * to be as close as possible to those when not in debug... So, we just skip
52a5101047d0148d33df1f9f4f77b24bce7fdf70pquerna * the actual spawn itself, but go through all of the motions...
185aa71728867671e105178b4c66fbc22b65ae26sf ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL, APLOGNO(00245)
f47612d41722d85fe2d698c43316a36fbccd4685pquerna "simple_spawn_child: Unable to fork new process");
f47612d41722d85fe2d698c43316a36fbccd4685pquerna if (pid == 0) {
f47612d41722d85fe2d698c43316a36fbccd4685pquerna /* this is the child process */
f47612d41722d85fe2d698c43316a36fbccd4685pquerna /* TODO: SIMPLE_SPAWN_EXEC */
f47612d41722d85fe2d698c43316a36fbccd4685pquerna if (pid != 0) {
f47612d41722d85fe2d698c43316a36fbccd4685pquerna child = apr_palloc(sc->pool, sizeof(simple_child_t));
f47612d41722d85fe2d698c43316a36fbccd4685pquerna apr_hash_set(sc->children, &child->pid, sizeof(child->pid), child);
52a5101047d0148d33df1f9f4f77b24bce7fdf70pquernavoid simple_check_children_size(simple_core_t * sc, void *baton)
52a5101047d0148d33df1f9f4f77b24bce7fdf70pquerna if (sc->run_single_process && sc->restart_num == 2) {
5bfaaf573bacb45c1cf290ce85ecc676587e8a64jim /* This is kinda of hack, but rather than spawning a child process,
52a5101047d0148d33df1f9f4f77b24bce7fdf70pquerna * we register the normal IO handlers in the main event loop....
52a5101047d0148d33df1f9f4f77b24bce7fdf70pquerna if (run == 0) {
52a5101047d0148d33df1f9f4f77b24bce7fdf70pquerna /* kill some kids */
52a5101047d0148d33df1f9f4f77b24bce7fdf70pquerna for (i = 0; i < to_kill; i++) {
52a5101047d0148d33df1f9f4f77b24bce7fdf70pquerna /* spawn some kids */
52a5101047d0148d33df1f9f4f77b24bce7fdf70pquerna /* juuuuust right. */