On 10/28/2008 08:00 AM, [EMAIL PROTECTED] wrote:
> Author: pquerna
> Date: Tue Oct 28 00:00:15 2008
> New Revision: 708462
> 
> URL: http://svn.apache.org/viewvc?rev=708462&view=rev
> Log:
> Add a work in progress, a completely new, "Simple MPM".
> 
> Added:
>     httpd/httpd/trunk/server/mpm/simple/   (with props)

Nitpicking: While event MPM is still in experimental simple is not? :-).
As for name proposals, how about

Generic MPM
Universal MPM


> Added: httpd/httpd/trunk/server/mpm/simple/simple_api.c
> URL: 
> http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/simple/simple_api.c?rev=708462&view=auto
> ==============================================================================

> +static const char*
> +set_proccount(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.proc_count = atoi(arg);

Does this work on ANSI compilers?

> 
> Added: httpd/httpd/trunk/server/mpm/simple/simple_io.c
> URL: 
> http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/simple/simple_io.c?rev=708462&view=auto
> ==============================================================================
> --- httpd/httpd/trunk/server/mpm/simple/simple_io.c (added)
> +++ httpd/httpd/trunk/server/mpm/simple/simple_io.c Tue Oct 28 00:00:15 2008
> @@ -0,0 +1,279 @@
> +/* 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_log.h"
> +#include "ap_listen.h"
> +#include "simple_types.h"
> +#include "simple_io.h"
> +#include "simple_event.h"
> +
> +#include "http_connection.h"
> +#include "util_filter.h"
> +#include "http_main.h"
> +#include "mpm.h"
> +#include "scoreboard.h"
> +#include "http_vhost.h"
> +
> +void
> +simple_io_timeot_cb(simple_core_t *sc,

I guess this should be simple_io_timeout_cb.

> +                           void *baton)
> +{
> +  simple_conn_t *scon = (simple_conn_t *)baton;
> +  /* pqXXXXX: handle timeouts. */
> +  conn_rec *c = scon->c;
> +  conn_state_t *cs = c->cs;
> +
> +  cs = NULL;
> +
> +  ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ap_server_conf,
> +               "io timeout hit (?)");
> +}
> +
> +static apr_status_t
> +simple_io_process(simple_conn_t *scon)
> +{
> +  apr_status_t rv;
> +
> +  if (scon->c->clogging_input_filters && !scon->c->aborted) {
> +    /* Since we have an input filter which 'cloggs' the input stream,
> +     * like mod_ssl, lets just do the normal read from input filters,
> +     * like the Worker MPM does.
> +     */
> +    ap_run_process_connection(scon->c);
> +    if (scon->c->cs->state != CONN_STATE_SUSPENDED) {
> +      scon->c->cs->state = CONN_STATE_LINGER;
> +    }
> +  }
> +
> +  simple_core_t *sc = scon->sc;
> +  conn_rec *c = scon->c;
> +  conn_state_t *cs = c->cs;

This does not work on ANSI C compilers. Declarations need to be at the start of 
the block.

> Added: httpd/httpd/trunk/server/mpm/simple/simple_event.c
> URL: 
> http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/simple/simple_event.c?rev=708462&view=auto
> ==============================================================================
> --- httpd/httpd/trunk/server/mpm/simple/simple_event.c (added)
> +++ httpd/httpd/trunk/server/mpm/simple/simple_event.c Tue Oct 28 00:00:15 
> 2008
> @@ -0,0 +1,81 @@
> +/* 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.
> + */
> +
> +#define APR_RING_DEBUG 1
> +
> +#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)
> +{
> +  simple_timer_t *elem = NULL;
> +  simple_timer_t *ep = NULL;
> +  int inserted  = 0;
> +  apr_time_t t = apr_time_now() + relative_time;
> +
> +  apr_thread_mutex_lock(sc->mtx);
> +
> +  APR_RING_CHECK_CONSISTENCY(&sc->timer_ring, simple_timer_t, link);
> +  APR_RING_CHECK_CONSISTENCY(&sc->dead_timer_ring, simple_timer_t, link);
> +
> +  if (!APR_RING_EMPTY(&sc->dead_timer_ring, simple_timer_t, link)) {
> +    elem = APR_RING_FIRST(&sc->dead_timer_ring);
> +    APR_RING_REMOVE(elem, link);
> +    APR_RING_CHECK_CONSISTENCY(&sc->dead_timer_ring, simple_timer_t, link);
> +  }
> +  else {
> +    elem = (simple_timer_t *) apr_pcalloc(sc->pool, sizeof(simple_timer_t));
> +  }
> +
> +  APR_RING_ELEM_INIT(elem, link);
> +  elem->expires = t;
> +  elem->cb = cb;
> +  elem->baton = baton;
> +
> +  APR_RING_CHECK_CONSISTENCY(&sc->timer_ring, simple_timer_t, link);
> +
> +  /* pqXXXXXX: skiplist would be a nice optimization here. */
> +  if (!APR_RING_EMPTY(&sc->timer_ring, simple_timer_t, link)) {
> +    ep = APR_RING_FIRST(&sc->timer_ring);
> +    while (inserted == 0 &&
> +           ep != APR_RING_SENTINEL(&sc->timer_ring, simple_timer_t, link))
> +    {
> +      if (ep->expires < elem->expires) {
> +        APR_RING_CHECK_CONSISTENCY(&sc->timer_ring, simple_timer_t, link);

Do we really need this check here? We have already done this.

> +        APR_RING_INSERT_BEFORE(ep, elem, link);
> +        inserted = 1;
> +        APR_RING_CHECK_CONSISTENCY(&sc->timer_ring, simple_timer_t, link);
> +      }
> +      ep = APR_RING_NEXT(ep, link);
> +    }
> +  }
> +
> +  APR_RING_CHECK_CONSISTENCY(&sc->timer_ring, simple_timer_t, link);

Do we really need this check here? We have already done this.

> +
> +  if (!inserted) {
> +    APR_RING_INSERT_TAIL(&sc->timer_ring,
> +                         elem, simple_timer_t, link);
> +  }
> +
> +  APR_RING_CHECK_CONSISTENCY(&sc->timer_ring, simple_timer_t, link);
> +
> +  apr_thread_mutex_unlock(sc->mtx);
> +}
> +

Regards

RĂ¼diger

Reply via email to