You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by pq...@apache.org on 2008/04/07 19:35:34 UTC

svn commit: r645626 - in /httpd/sandbox/amsterdam/d/server/mpm: ./ simple/

Author: pquerna
Date: Mon Apr  7 10:35:32 2008
New Revision: 645626

URL: http://svn.apache.org/viewvc?rev=645626&view=rev
Log:
Start the Simple MPM.

This is not a working MPM (yet).

I'm just check pointing what I've hacked together so far, before heading off to
dinner tonight.

Added:
    httpd/sandbox/amsterdam/d/server/mpm/simple/   (with props)
    httpd/sandbox/amsterdam/d/server/mpm/simple/Makefile.in
    httpd/sandbox/amsterdam/d/server/mpm/simple/SIMPLE.README
    httpd/sandbox/amsterdam/d/server/mpm/simple/config.m4
    httpd/sandbox/amsterdam/d/server/mpm/simple/mpm.h
    httpd/sandbox/amsterdam/d/server/mpm/simple/mpm_default.h
    httpd/sandbox/amsterdam/d/server/mpm/simple/simple_api.c
    httpd/sandbox/amsterdam/d/server/mpm/simple/simple_children.c
    httpd/sandbox/amsterdam/d/server/mpm/simple/simple_children.h
    httpd/sandbox/amsterdam/d/server/mpm/simple/simple_core.c
    httpd/sandbox/amsterdam/d/server/mpm/simple/simple_event.c
    httpd/sandbox/amsterdam/d/server/mpm/simple/simple_event.h
    httpd/sandbox/amsterdam/d/server/mpm/simple/simple_run.c
    httpd/sandbox/amsterdam/d/server/mpm/simple/simple_types.h
Modified:
    httpd/sandbox/amsterdam/d/server/mpm/MPM.NAMING
    httpd/sandbox/amsterdam/d/server/mpm/config.m4

Modified: httpd/sandbox/amsterdam/d/server/mpm/MPM.NAMING
URL: http://svn.apache.org/viewvc/httpd/sandbox/amsterdam/d/server/mpm/MPM.NAMING?rev=645626&r1=645625&r2=645626&view=diff
==============================================================================
--- httpd/sandbox/amsterdam/d/server/mpm/MPM.NAMING (original)
+++ httpd/sandbox/amsterdam/d/server/mpm/MPM.NAMING Mon Apr  7 10:35:32 2008
@@ -1,6 +1,9 @@
 
 The following MPMs currently exist:
 
+  simple ........ Single or Multi Process, with Preforking or Threading, 
+                  depending on configuration and operating systems.  Should
+                  be able to run on all modern operating systems.
   prefork ....... Multi  Process Model with Preforking (Apache 1.3)
   perchild ...... Multi  Process Model with Threading.
                   Constant number of processes, variable number of threads
@@ -13,3 +16,5 @@
                   multiple worker threads.
   netware ....... Multi-threaded MPM for Netware
   beos .......... Single Process Model with Threading on BeOS
+
+

Modified: httpd/sandbox/amsterdam/d/server/mpm/config.m4
URL: http://svn.apache.org/viewvc/httpd/sandbox/amsterdam/d/server/mpm/config.m4?rev=645626&r1=645625&r2=645626&view=diff
==============================================================================
--- httpd/sandbox/amsterdam/d/server/mpm/config.m4 (original)
+++ httpd/sandbox/amsterdam/d/server/mpm/config.m4 Mon Apr  7 10:35:32 2008
@@ -1,7 +1,7 @@
 AC_MSG_CHECKING(which MPM to use)
 AC_ARG_WITH(mpm,
 APACHE_HELP_STRING(--with-mpm=MPM,Choose the process model for Apache to use.
-                          MPM={beos|event|worker|prefork|mpmt_os2|perchild|leader|threadpool|winnt}),[
+                          MPM={simple|beos|event|worker|prefork|mpmt_os2|perchild|leader|threadpool|winnt}),[
   APACHE_MPM=$withval
 ],[
   if test "x$APACHE_MPM" = "x"; then
@@ -14,7 +14,7 @@
 	
 ap_mpm_is_threaded ()
 {
-    if test "$apache_cv_mpm" = "worker" -o "$apache_cv_mpm" = "event" -o "$apache_cv_mpm" = "perchild" -o "$apache_cv_mpm" = "leader" -o "$apache_cv_mpm" = "winnt" -o "$apache_cv_mpm" = "threadpool" ; then
+    if test "$apache_cv_mpm" = "worker" -o "$apache_cv_mpm" = "event" -o "$apache_cv_mpm" = "simple"  -o "$apache_cv_mpm" = "perchild" -o "$apache_cv_mpm" = "leader" -o "$apache_cv_mpm" = "winnt" -o "$apache_cv_mpm" = "threadpool" ; then
         return 0
     else
         return 1

Propchange: httpd/sandbox/amsterdam/d/server/mpm/simple/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Apr  7 10:35:32 2008
@@ -0,0 +1,3 @@
+.deps
+.libs
+Makefile

Added: httpd/sandbox/amsterdam/d/server/mpm/simple/Makefile.in
URL: http://svn.apache.org/viewvc/httpd/sandbox/amsterdam/d/server/mpm/simple/Makefile.in?rev=645626&view=auto
==============================================================================
--- httpd/sandbox/amsterdam/d/server/mpm/simple/Makefile.in (added)
+++ httpd/sandbox/amsterdam/d/server/mpm/simple/Makefile.in Mon Apr  7 10:35:32 2008
@@ -0,0 +1,4 @@
+LTLIBRARY_NAME    = libsimple.la
+LTLIBRARY_SOURCES = simple_api.c simple_children.c simple_core.c simple_event.c simple_run.c
+
+include $(top_srcdir)/build/ltlib.mk

Added: httpd/sandbox/amsterdam/d/server/mpm/simple/SIMPLE.README
URL: http://svn.apache.org/viewvc/httpd/sandbox/amsterdam/d/server/mpm/simple/SIMPLE.README?rev=645626&view=auto
==============================================================================
--- httpd/sandbox/amsterdam/d/server/mpm/simple/SIMPLE.README (added)
+++ httpd/sandbox/amsterdam/d/server/mpm/simple/SIMPLE.README Mon Apr  7 10:35:32 2008
@@ -0,0 +1,15 @@
+The "Simple MPM", is a departure from all previous MPM Designs.
+
+Instead of focusing on a subset of platforms, and a specific process model,
+it tries to be a generic 'process pool manager' at the top, and each process
+could run like an existing Worker MPM, or Prefork MPM in their high level
+behavoirs.
+
+The Simple MPM also aims to create a single MPM, that runs on all modern
+Unix and Win32 platforms, by using APR as much as possible, and not relying 
+upon fork to spawn children.
+
+The Simple MPM will revolve around a Poll CB event system, with 'timers' being
+built in.  When an event, either an IO or Timer is ready to run, it is dispatched
+to any available threads in the currrent process.
+

Added: httpd/sandbox/amsterdam/d/server/mpm/simple/config.m4
URL: http://svn.apache.org/viewvc/httpd/sandbox/amsterdam/d/server/mpm/simple/config.m4?rev=645626&view=auto
==============================================================================
--- httpd/sandbox/amsterdam/d/server/mpm/simple/config.m4 (added)
+++ httpd/sandbox/amsterdam/d/server/mpm/simple/config.m4 Mon Apr  7 10:35:32 2008
@@ -0,0 +1,3 @@
+if test "$MPM_NAME" = "simple" ; then
+    APACHE_FAST_OUTPUT(server/mpm/$MPM_NAME/Makefile)
+fi

Added: httpd/sandbox/amsterdam/d/server/mpm/simple/mpm.h
URL: http://svn.apache.org/viewvc/httpd/sandbox/amsterdam/d/server/mpm/simple/mpm.h?rev=645626&view=auto
==============================================================================
--- httpd/sandbox/amsterdam/d/server/mpm/simple/mpm.h (added)
+++ httpd/sandbox/amsterdam/d/server/mpm/simple/mpm.h Mon Apr  7 10:35:32 2008
@@ -0,0 +1,32 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "httpd.h"
+
+#ifndef APACHE_MPM_SIMPLE_H
+#define APACHE_MPM_SIMPLE_H
+
+#define MPM_NAME "Simple"
+
+/* pqXXXXXX: shouldn't need this really. */
+#define AP_MPM_WANT_SIGNAL_SERVER
+
+/* pqXXXXXX: signal server has a hidden dependency */
+#define AP_MPM_WANT_SET_PIDFILE
+
+extern server_rec *ap_server_conf;
+
+#endif /* APACHE_MPM_SIMPLE_H */

Added: httpd/sandbox/amsterdam/d/server/mpm/simple/mpm_default.h
URL: http://svn.apache.org/viewvc/httpd/sandbox/amsterdam/d/server/mpm/simple/mpm_default.h?rev=645626&view=auto
==============================================================================
--- httpd/sandbox/amsterdam/d/server/mpm/simple/mpm_default.h (added)
+++ httpd/sandbox/amsterdam/d/server/mpm/simple/mpm_default.h Mon Apr  7 10:35:32 2008
@@ -0,0 +1,79 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+ * @file  event/mpm_default.h
+ * @brief Event MPM defaults
+ *
+ * @addtogroup APACHE_MPM_EVENT
+ * @{
+ */
+
+#ifndef APACHE_MPM_DEFAULT_H
+#define APACHE_MPM_DEFAULT_H
+
+/* Number of servers to spawn off by default --- also, if fewer than
+ * this free when the caretaker checks, it will spawn more.
+ */
+#ifndef DEFAULT_START_DAEMON
+#define DEFAULT_START_DAEMON 3
+#endif
+
+/* Maximum number of *free* server processes --- more than this, and
+ * they will die off.
+ */
+
+#ifndef DEFAULT_MAX_FREE_DAEMON
+#define DEFAULT_MAX_FREE_DAEMON 10
+#endif
+
+/* Minimum --- fewer than this, and more will be created */
+
+#ifndef DEFAULT_MIN_FREE_DAEMON
+#define DEFAULT_MIN_FREE_DAEMON 3
+#endif
+
+#ifndef DEFAULT_THREADS_PER_CHILD
+#define DEFAULT_THREADS_PER_CHILD 25
+#endif
+
+/* File used for accept locking, when we use a file */
+#ifndef DEFAULT_LOCKFILE
+#define DEFAULT_LOCKFILE DEFAULT_REL_RUNTIMEDIR "/accept.lock"
+#endif
+
+/* Where the main/parent process's pid is logged */
+#ifndef DEFAULT_PIDLOG
+#define DEFAULT_PIDLOG DEFAULT_REL_RUNTIMEDIR "/httpd.pid"
+#endif
+
+/*
+ * Interval, in microseconds, between scoreboard maintenance.
+ */
+#ifndef SCOREBOARD_MAINTENANCE_INTERVAL
+#define SCOREBOARD_MAINTENANCE_INTERVAL 1000000
+#endif
+
+/* Number of requests to try to handle in a single process.  If <= 0,
+ * the children don't die off.
+ */
+#ifndef DEFAULT_MAX_REQUESTS_PER_CHILD
+#define DEFAULT_MAX_REQUESTS_PER_CHILD 10000
+#endif
+
+#endif /* AP_MPM_DEFAULT_H */
+/** @} */

Added: httpd/sandbox/amsterdam/d/server/mpm/simple/simple_api.c
URL: http://svn.apache.org/viewvc/httpd/sandbox/amsterdam/d/server/mpm/simple/simple_api.c?rev=645626&view=auto
==============================================================================
--- httpd/sandbox/amsterdam/d/server/mpm/simple/simple_api.c (added)
+++ httpd/sandbox/amsterdam/d/server/mpm/simple/simple_api.c Mon Apr  7 10:35:32 2008
@@ -0,0 +1,215 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mpm.h"
+#include "ap_mpm.h"
+#include "httpd.h"
+#include "http_config.h"
+#include "mpm_common.h"
+
+#include "scoreboard.h"
+
+#include "simple_types.h"
+
+/* Thie file contains the absolute minimal MPM API, to interface with httpd. */
+
+ap_generation_t volatile ap_my_generation = 0;
+server_rec *ap_server_conf = NULL;
+
+/* pqXXXXXX: removed from trunk. */
+int
+ap_graceful_stop_signalled()
+{
+  return 0;
+}
+
+apr_status_t
+ap_mpm_query(int query_code, int *result)
+{
+  simple_core_t* sc = simple_core_get();
+
+  switch (query_code) {
+    case AP_MPMQ_IS_THREADED:
+      *result = AP_MPMQ_STATIC;
+      return APR_SUCCESS;
+      break;
+    case AP_MPMQ_IS_FORKED:
+      *result = AP_MPMQ_DYNAMIC;
+      return APR_SUCCESS;
+      break;
+    case AP_MPMQ_IS_ASYNC:
+      *result = 1;
+      return APR_SUCCESS;
+      break;
+    /* pqXXXXXXX: support configuration queries */
+    case AP_MPMQ_MAX_DAEMON_USED:
+      *result = sc->procmgr.daemons_to_start;
+      return APR_SUCCESS;
+      break;
+    case AP_MPMQ_HARD_LIMIT_DAEMONS:
+      *result = sc->procmgr.daemons_to_start;
+      return APR_SUCCESS;
+      break;
+    case AP_MPMQ_HARD_LIMIT_THREADS:
+      *result = sc->procmgr.thread_count;
+      return APR_SUCCESS;
+      break;
+    case AP_MPMQ_MAX_THREADS:
+      *result = sc->procmgr.thread_count;
+      return APR_SUCCESS;
+      break;
+    case AP_MPMQ_MAX_SPARE_DAEMONS:
+      *result = sc->procmgr.daemons_max_free;
+      return APR_SUCCESS;
+      break;
+    case AP_MPMQ_MIN_SPARE_DAEMONS:
+      *result = sc->procmgr.daemons_min_free;
+      return APR_SUCCESS;
+      break;
+    case AP_MPMQ_MIN_SPARE_THREADS:
+    case AP_MPMQ_MAX_SPARE_THREADS:
+      *result = 0;
+      return APR_SUCCESS;
+      break;
+    case AP_MPMQ_MAX_REQUESTS_DAEMON:
+      *result = sc->procmgr.max_requests_per_child;
+      return APR_SUCCESS;
+      break;
+    case AP_MPMQ_MAX_DAEMONS:
+      *result = sc->procmgr.daemons_to_start;
+      return APR_SUCCESS;
+      break;
+    case AP_MPMQ_MPM_STATE:
+      *result = sc->mpm_state;
+      return APR_SUCCESS;
+    default:
+      break;
+  }
+
+  return APR_ENOTIMPL;
+}
+
+static int simple_open_logs(apr_pool_t *p,
+                            apr_pool_t *plog,
+                            apr_pool_t *ptemp,
+                            server_rec *s)
+{
+  ap_server_conf = s;
+  /**/
+  
+}
+
+static void
+simple_process_start(process_rec *process)
+{
+  apr_status_t rv;
+  /* this is our first 'real' entry point, so reset everything here. */
+  rv = simple_core_init(simple_core_get(), process->pool);
+  
+  if (rv) {
+    /* pqXXXXX: make smarter */
+    fprintf(stderr, "Unable to init Simple MPM Core. (rv=%d)", rv);
+    exit(EXIT_FAILURE);
+  }
+
+  ap_mpm_rewrite_args(process);
+}
+
+static int
+simple_check_config(apr_pool_t *p, apr_pool_t *plog,
+                    apr_pool_t *ptemp, server_rec *s)
+{
+  /* pqXXXX: check configuration */
+  return OK;
+}
+  
+static void
+simple_hooks(apr_pool_t *p)
+{
+  static const char *const aszSucc[] = {"core.c", NULL};
+
+  ap_hook_open_logs(simple_open_logs, NULL,
+                    aszSucc, APR_HOOK_REALLY_FIRST);
+
+  ap_hook_check_config(simple_check_config,
+                       NULL, NULL, APR_HOOK_MIDDLE);
+
+}
+
+static const char*
+set_start(cmd_parms *cmd, void *baton, const char *arg)
+{
+  const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+  if (err != NULL) {
+    return err;
+  }
+  
+  simple_core_get()->procmgr.daemons_to_start = atoi(arg);
+  return NULL;
+}
+
+
+static const char*
+set_poolsize(cmd_parms *cmd, void *baton, const char *arg1, const char *arg2)
+{
+  const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+  if (err != NULL) {
+    return err;
+  }
+  
+  simple_core_get()->procmgr.daemons_min_free = atoi(arg1);
+  simple_core_get()->procmgr.daemons_max_free = atoi(arg2);
+  return NULL;
+}
+
+
+static const char*
+set_threadcount(cmd_parms *cmd, void *baton, const char *arg)
+{
+  const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+  if (err != NULL) {
+    return err;
+  }
+
+  simple_core_get()->procmgr.thread_count = atoi(arg);
+  return NULL;
+}
+
+static const command_rec simple_cmds[] = {
+  AP_INIT_TAKE1("SimpleProcStart", set_start, NULL, RSRC_CONF,
+                "Number of child processes launched at server startup"),
+  AP_INIT_TAKE2("SimpleProcPool", set_poolsize, NULL, RSRC_CONF,
+                "Set minimum and maximum number of spare processes"),
+  AP_INIT_TAKE1("SimpleThreadCount", set_threadcount, NULL, RSRC_CONF,
+                "Set the number of Worker Threads Per-Process"),
+  { NULL }
+};
+
+
+
+module AP_MODULE_DECLARE_DATA mpm_simple_module = {
+  MPM20_MODULE_STUFF,
+  simple_process_start,       /* hook to run before apache parses args */
+  NULL,                       /* create per-directory config structure */
+  NULL,                       /* merge per-directory config structures */
+  NULL,                       /* create per-server config structure */
+  NULL,                       /* merge per-server config structures */
+  simple_cmds,                /* command apr_table_t */
+  simple_hooks                /* register_hooks */
+};
+
+  
+

Added: httpd/sandbox/amsterdam/d/server/mpm/simple/simple_children.c
URL: http://svn.apache.org/viewvc/httpd/sandbox/amsterdam/d/server/mpm/simple/simple_children.c?rev=645626&view=auto
==============================================================================
--- httpd/sandbox/amsterdam/d/server/mpm/simple/simple_children.c (added)
+++ httpd/sandbox/amsterdam/d/server/mpm/simple/simple_children.c Mon Apr  7 10:35:32 2008
@@ -0,0 +1,80 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "httpd.h"
+#include "http_config.h"
+#include "simple_types.h"
+#include "simple_event.h"
+#include "apr_hash.h"
+
+#define SPAWN_CHILDREN_INTERVAL (apr_time_from_sec(5))
+
+static void
+simple_kill_random_child(simple_core_t *sc)
+{
+  apr_thread_mutex_lock(sc->mtx);
+  apr_thread_mutex_unlock(sc->mtx);
+}
+
+static void
+simple_spawn_child(simple_core_t *sc)
+{
+  apr_thread_mutex_lock(sc->mtx);
+  apr_thread_mutex_unlock(sc->mtx);
+}
+
+void
+simple_check_children_size(simple_core_t *sc,
+                           void *baton)
+{
+  simple_register_timer(sc,
+                        simple_check_children_size,
+                        NULL,
+                        SPAWN_CHILDREN_INTERVAL);
+  unsigned int count;
+  int wanted;
+  int i;
+  {
+    apr_thread_mutex_lock(sc->mtx);
+    count = apr_hash_count(sc->children);
+    wanted = sc->procmgr.requested_children;
+    apr_thread_mutex_unlock(sc->mtx);
+  }
+
+  if (count > wanted) {
+    /* kill some kids */
+    int to_kill = count - wanted;
+    for (i = 0;
+         i < to_kill;
+         i++)
+    {
+      simple_kill_random_child(sc);
+    }
+  }
+  else if (count < wanted) {
+    /* spawn some kids */
+    int to_spawn = wanted - count;
+    for (i = 0;
+         i < to_spawn;
+         i++)
+    {
+      simple_spawn_child(sc);
+    }
+  }
+  else {
+    /* juuuuust right. */
+  }
+}

Added: httpd/sandbox/amsterdam/d/server/mpm/simple/simple_children.h
URL: http://svn.apache.org/viewvc/httpd/sandbox/amsterdam/d/server/mpm/simple/simple_children.h?rev=645626&view=auto
==============================================================================
--- httpd/sandbox/amsterdam/d/server/mpm/simple/simple_children.h (added)
+++ httpd/sandbox/amsterdam/d/server/mpm/simple/simple_children.h Mon Apr  7 10:35:32 2008
@@ -0,0 +1,32 @@
+
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "simple_types.h"
+
+#ifndef APACHE_MPM_SIMPLE_CHILDREN_H
+#define APACHE_MPM_SIMPLE_CHILDREN_H
+
+void
+simple_check_children_size(simple_core_t *sc,
+                           void *baton);
+
+void
+simple_check_children_status(simple_core_t *sc,
+                             void *baton);
+
+
+#endif /* APACHE_MPM_SIMPLE_CHILDREN_H */

Added: httpd/sandbox/amsterdam/d/server/mpm/simple/simple_core.c
URL: http://svn.apache.org/viewvc/httpd/sandbox/amsterdam/d/server/mpm/simple/simple_core.c?rev=645626&view=auto
==============================================================================
--- httpd/sandbox/amsterdam/d/server/mpm/simple/simple_core.c (added)
+++ httpd/sandbox/amsterdam/d/server/mpm/simple/simple_core.c Mon Apr  7 10:35:32 2008
@@ -0,0 +1,66 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* Simple Core utility methods.
+ */
+ 
+#include "simple_types.h"
+#include "mpm.h"
+#include "ap_mpm.h"
+#include "httpd.h"
+
+static simple_core_t g_simple_core;
+
+#ifndef DEFAULT_MAX_REQUESTS_PER_CHILD
+#define DEFAULT_MAX_REQUESTS_PER_CHILD 0
+#endif
+
+
+simple_core_t*
+simple_core_get()
+{
+  return &g_simple_core;
+}
+
+apr_status_t
+simple_core_init(simple_core_t* sc, apr_pool_t* pool)
+{
+  apr_status_t rv;
+  
+  sc->mpm_state = AP_MPMQ_STARTING;
+  sc->pool = pool;
+  sc->pollcb = NULL;
+  sc->procmgr.daemons_to_start = 0;
+  sc->procmgr.daemons_min_free = 0;
+  sc->procmgr.daemons_max_free = 0;
+  sc->procmgr.thread_count = 0;
+  sc->procmgr.requested_children = 0;
+  sc->procmgr.max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
+  
+  sc->children = apr_hash_make(sc->pool);
+
+  apr_thread_mutex_create(sc->mtx,
+                          0,
+                          sc->pool);
+
+  rv = apr_pollcb_create(&sc->pollcb,
+                         512 /* pqXXXXX: make configrable */,
+                         sc->pool,
+                         0);
+  
+  return rv;
+}
+

Added: httpd/sandbox/amsterdam/d/server/mpm/simple/simple_event.c
URL: http://svn.apache.org/viewvc/httpd/sandbox/amsterdam/d/server/mpm/simple/simple_event.c?rev=645626&view=auto
==============================================================================
--- httpd/sandbox/amsterdam/d/server/mpm/simple/simple_event.c (added)
+++ httpd/sandbox/amsterdam/d/server/mpm/simple/simple_event.c Mon Apr  7 10:35:32 2008
@@ -0,0 +1,32 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "simple_types.h"
+#include "simple_event.h"
+
+void 
+simple_register_timer(simple_core_t *sc,
+                      simple_timer_cb cb, 
+                      void *baton,
+                      apr_time_t relative_time)
+{
+  apr_thread_mutex_lock(sc->mtx);
+  apr_time_t t = apr_time_now() + relative_time;
+  /* pqXXXXX: create timed event list, iterate it, then insert
+   * in the right place.
+   */
+  apr_thread_mutex_unlock(sc->mtx);
+}

Added: httpd/sandbox/amsterdam/d/server/mpm/simple/simple_event.h
URL: http://svn.apache.org/viewvc/httpd/sandbox/amsterdam/d/server/mpm/simple/simple_event.h?rev=645626&view=auto
==============================================================================
--- httpd/sandbox/amsterdam/d/server/mpm/simple/simple_event.h (added)
+++ httpd/sandbox/amsterdam/d/server/mpm/simple/simple_event.h Mon Apr  7 10:35:32 2008
@@ -0,0 +1,63 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apr.h"
+#include "apr_pools.h"
+#include "apr_poll.h"
+
+#ifndef APACHE_MPM_SIMPLE_EVENT_H
+#define APACHE_MPM_SIMPLE_EVENT_H
+
+typedef void(*simple_timer_cb)(simple_core_t *sc, void *baton);
+typedef void(*simple_io_sock_cb)(simple_core_t *sc, apr_socket_t *sock,
+                                int flags, void *baton);
+typedef void(*simple_io_file_cb)(simple_core_t *sc, apr_socket_t *sock,
+                                int flags, void *baton);
+
+/* pqXXXXXX: Pool based cleanups
+ */
+
+void 
+simple_register_timer(simple_core_t *sc,
+                      simple_timer_cb cb, 
+                      void *baton,
+                      apr_time_t relative_time);
+
+/**
+ * @see apr_poll.h for watch_for values
+ */
+void
+simple_register_sock_io(simple_core_t *sc,
+                        simple_io_sock_cb cb, 
+                        void *baton,
+                        apr_socket_t *sock,
+                        int watch_for,
+                        apr_time_t relative_timeout);
+
+/**
+ * @see apr_poll.h for watch_for values
+ */
+void
+simple_register_file_io(simple_core_t *sc,
+                        simple_io_file_cb cb, 
+                        void *baton,
+                        apr_file_t *file,
+                        int watch_for,
+                        apr_time_t relative_timeout);
+
+
+#endif /* APACHE_MPM_SIMPLE_EVENT_H */
+

Added: httpd/sandbox/amsterdam/d/server/mpm/simple/simple_run.c
URL: http://svn.apache.org/viewvc/httpd/sandbox/amsterdam/d/server/mpm/simple/simple_run.c?rev=645626&view=auto
==============================================================================
--- httpd/sandbox/amsterdam/d/server/mpm/simple/simple_run.c (added)
+++ httpd/sandbox/amsterdam/d/server/mpm/simple/simple_run.c Mon Apr  7 10:35:32 2008
@@ -0,0 +1,62 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "httpd.h"
+#include "http_config.h"
+#include "simple_types.h"
+#include "simple_event.h"
+#include "simple_children.h"
+#include "ap_mpm.h"
+#include "scoreboard.h"
+
+static void
+simple_setup_timers(simple_core_t *sc)
+{
+  sc->procmgr.requested_children = sc->procmgr.daemons_to_start;
+
+  simple_register_timer(sc,
+                        simple_check_children_size,
+                        NULL,
+                        0);
+}
+
+static int
+simple_main_loop(simple_core_t *sc)
+{
+  simple_setup_timers(sc);
+
+  while (sc->mpm_state == AP_MPMQ_RUNNING) {
+  }
+  return 0;
+}
+
+int
+ap_mpm_run(apr_pool_t *pconf,
+           apr_pool_t *plog,
+           server_rec *s)
+{
+  simple_core_t *sc = simple_core_get();
+
+  sc->mpm_state = AP_MPMQ_RUNNING;
+
+  if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) {
+    sc->mpm_state = AP_MPMQ_STOPPING;
+    return 1;
+  }
+  
+  return simple_main_loop(sc);
+}
+

Added: httpd/sandbox/amsterdam/d/server/mpm/simple/simple_types.h
URL: http://svn.apache.org/viewvc/httpd/sandbox/amsterdam/d/server/mpm/simple/simple_types.h?rev=645626&view=auto
==============================================================================
--- httpd/sandbox/amsterdam/d/server/mpm/simple/simple_types.h (added)
+++ httpd/sandbox/amsterdam/d/server/mpm/simple/simple_types.h Mon Apr  7 10:35:32 2008
@@ -0,0 +1,54 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apr.h"
+#include "apr_pools.h"
+#include "apr_poll.h"
+#include "apr_hash.h"
+
+#ifndef APACHE_MPM_SIMPLE_TYPES_H
+#define APACHE_MPM_SIMPLE_TYPES_H
+
+typedef struct {
+  int requested_children;
+  int daemons_to_start;
+  int daemons_min_free;
+  int daemons_max_free;
+  int thread_count;
+  int max_requests_per_child;
+} simple_proc_mgr_t;
+
+typedef struct {
+  int pid;
+} simple_child_t;
+
+typedef struct {
+  simple_proc_mgr_t procmgr;
+  apr_hash_t *children;
+  int mpm_state;
+  apr_pool_t *pool;
+  apr_pollcb_t *pollcb;
+  apr_thread_mutex_t *mtx;
+} simple_core_t;
+
+simple_core_t* simple_core_get();
+
+/* Resets all variables to 0 for a simple_core_t */
+apr_status_t simple_core_init(simple_core_t* sc,
+                              apr_pool_t* pool);
+
+#endif /* APACHE_MPM_SIMPLE_TYPES_H */
+