mpm_common.c revision 1ca054782cb35b5f67686a41b1df75c269fa617b
/* 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
*
*
* 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.
*/
/* The purpose of this file is to store the code that MOST mpm's will need
* this does not mean a function only goes into this file if every MPM needs
* it. It means that if a function is needed by more than one MPM, and
* future maintenance would be served by making the code common, then the
* function belongs here.
*
* specific to multi-process servers, but NOT to Unix. Which is why it
*/
#include "apr.h"
#include "apr_thread_proc.h"
#include "apr_signal.h"
#include "apr_strings.h"
#define APR_WANT_STRFUNC
#include "apr_want.h"
#include "apr_getopt.h"
#include "apr_optional.h"
#include "apr_allocator.h"
#include "httpd.h"
#include "http_config.h"
#include "http_log.h"
#include "http_main.h"
#include "mpm_common.h"
#include "ap_mpm.h"
#include "ap_listen.h"
#include "util_mutex.h"
#include "scoreboard.h"
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#ifdef HAVE_GRP_H
#include <grp.h>
#endif
#include <unistd.h>
#endif
)
#else
)
#endif
(int query_code, int *result),
(int childnum),
(childnum), 0)
(int childnum),
(childnum), APR_ENOTIMPL)
AP_IMPLEMENT_HOOK_RUN_FIRST(const char *, mpm_get_name,
(void),
(), NULL)
/* number of calls to wait_or_timeout between writable probes */
#ifndef INTERVAL_OF_WRITABLE_PROBES
#define INTERVAL_OF_WRITABLE_PROBES 10
#endif
static int wait_or_timeout_counter;
apr_pool_t *p)
{
ap_run_monitor(p);
}
if (APR_STATUS_IS_EINTR(rv)) {
return;
}
if (APR_STATUS_IS_CHILD_DONE(rv)) {
return;
}
apr_sleep(1000000);
return;
}
void ap_sock_disable_nagle(apr_socket_t *s)
{
/* The Nagle algorithm says that we should delay sending partial
* packets in hopes of getting more data. We don't want to do
* this; we are not telnet. There are bad interactions between
* persistent connections and Nagle's algorithm that have very severe
* performance penalties. (Failing to disable Nagle is not much of a
* problem with simple HTTP.)
*
* In spite of these problems, failure here is not a shooting offense.
*/
if (status != APR_SUCCESS) {
"apr_socket_opt_set: (TCP_NODELAY)");
}
}
#endif
#ifdef HAVE_GETPWNAM
{
if (name[0] == '#')
exit(1);
}
}
#endif
#ifdef HAVE_GETGRNAM
{
if (name[0] == '#')
exit(1);
}
}
#endif
#ifndef HAVE_INITGROUPS
{
#if defined(QNX) || defined(MPE) || defined(_OSD_POSIX) || defined(TPF) || defined(__TANDEM) || defined(WIN32) || defined(NETWARE)
/* QNX and MPE do not appear to support supplementary groups. */
return 0;
#else /* ndef QNX */
struct group *g;
int index = 0;
setgrent();
char **names;
}
}
}
endgrent();
#endif /* def QNX */
}
#endif /* def NEED_INITGROUPS */
/* standard mpm configuration handling */
const char *ap_pid_fname = NULL;
const char *arg)
{
return err;
}
return "PidFile directive not allowed in <VirtualHost>";
}
ap_pid_fname = arg;
return NULL;
}
const char *arg)
{
return err;
}
return NULL;
}
const char *ap_lock_fname = NULL;
const char *arg)
{
return err;
}
ap_lock_fname = arg;
return NULL;
}
int ap_max_requests_per_child = 0;
const char *arg)
{
return err;
}
return NULL;
}
char ap_coredump_dir[MAX_STRING_LEN];
const char *arg)
{
const char *fname;
return err;
}
if (!fname) {
}
" does not exist", NULL);
}
" is not a directory", NULL);
}
return NULL;
}
int ap_graceful_shutdown_timeout = 0;
const char *arg)
{
return err;
}
return NULL;
}
void *dummy,
const char *arg)
{
const char *lockfile;
return err;
}
} else if (rv == APR_BADARG) {
}
if (lockfile && !ap_lock_fname)
return NULL;
}
const char *arg)
{
long value;
return err;
}
return NULL;
}
const char *arg)
{
long value;
return err;
}
return NULL;
}
{
}
{
}
{
return ap_run_mpm_get_child_pid(childnum);
}
{
return ap_run_mpm_note_child_killed(childnum);
}
AP_DECLARE(apr_status_t) ap_mpm_register_timed_callback(apr_time_t t, ap_mpm_callback_fn_t *cbfn, void *baton)
{
}
AP_DECLARE(const char *)ap_show_mpm(void)
{
const char *name = ap_run_mpm_get_name();
if (!name) {
name = "";
}
return name;
}