forked from pool/apache2
This commit is contained in:
committed by
Git OBS Bridge
parent
97abcf1aa4
commit
c028012343
2
a2enflag
2
a2enflag
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2005 Peter Poeml <poeml@suse.de>. All Rights Reserved.
|
||||
# Copyright 2005 Peter Poeml <apache@suse.de>. All Rights Reserved.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
2
a2enmod
2
a2enmod
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2005 Peter Poeml <poeml@suse.de>. All Rights Reserved.
|
||||
# Copyright 2005 Peter Poeml <apache@suse.de>. All Rights Reserved.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@@ -1,101 +1,6 @@
|
||||
|
||||
QUICKSTART -- How to get your server up and running as fast as possible
|
||||
|
||||
o General machine setup:
|
||||
- configure your network
|
||||
- make sure that all components are current, by running YaST Online Update
|
||||
regularly
|
||||
|
||||
o synchronise time (parts of the HTTP protocol depend on correct time):
|
||||
- configure machine as NTP client, either with the YaST configuration module or
|
||||
by editing /etc/ntp.conf (just put a server name into it) and starting
|
||||
"rcxntpd start", and running "chkconfig -a xntpd"
|
||||
|
||||
o if you run a firewall, make sure to allow access through port 80 if the server
|
||||
should be reachable from other machines.
|
||||
|
||||
o start the server, and configure it to automatically start at boot time:
|
||||
- rcapache2 start
|
||||
- chkconfig -a apache2
|
||||
|
||||
o add web pages:
|
||||
- the DocumentRoot is at /srv/www/htdocs
|
||||
- if you add documents somewhere else and link to them with e.g.
|
||||
Alias someplace "/path/to/someplace"
|
||||
make sure to also use <Directory /path/to/someplace> ... </Directory>
|
||||
to define access permissions and options for that directory, since
|
||||
(starting with SuSE Linux 9.0) access to the entire filesystem is blocked
|
||||
by default. See http://httpd.apache.org/docs-2.2/mod/core.html#directory
|
||||
|
||||
o go through /etc/sysconfig/apache2:
|
||||
- check loaded modules (APACHE_MODULES="...").
|
||||
- add "php4", "perl", or other needed modules to APACHE_MODULES al gusto.
|
||||
- modules can be enabled/disabled in a simple (Debian-compatible ;) way from
|
||||
the command line like this:
|
||||
a2enmod php5
|
||||
a2dismod php5
|
||||
- there is also a command a2enflag, to change APACHE_SERVER_FLAGS
|
||||
- restart the server ('rcapache2 restart')
|
||||
|
||||
o where to add your own configuration:
|
||||
- add e.g. /etc/apache2/httpd.conf.local and change APACHE_CONF_INCLUDE_FILES
|
||||
in /etc/sysconfig/apache2, e.g. APACHE_CONF_INCLUDE_FILES="httpd.conf.local"
|
||||
- to understand the hierarchy and layout of all include files, read the
|
||||
comments at the top of httpd.conf
|
||||
- if you strongly prefer the old, single, 40K, monolithic configuration file,
|
||||
it's there! Just use it:
|
||||
mv /etc/apache2/httpd.conf /etc/apache2/httpd.conf.dist
|
||||
cp /usr/share/doc/packages/apache2/httpd-std.conf-prefork /etc/apache2/httpd.conf
|
||||
rcapache2 restart
|
||||
|
||||
o add virtual hosts:
|
||||
- edit /etc/apache2/listen.conf. It is a suitable place to add
|
||||
NameVirtualHost directives.
|
||||
- copy the commented template /etc/apache2/vhosts.d/vhost.template to
|
||||
/etc/apache2/vhosts.d/yourhost.conf
|
||||
(note, it must end in .conf to be automatically read)
|
||||
- edit /etc/apache2/vhosts.d/yourhost.conf to suit your needs
|
||||
- alternative approach: simply append the NameVirtualHost directive and the
|
||||
<VirtualHost> container to your local configuration (httpd.conf.local --
|
||||
see above)
|
||||
- if in doubt about how apache interprets your vhost setup, always use
|
||||
httpd2 -S. If SSL is involved you will need to run httpd2 -S -DSSL instead --
|
||||
likewise for other needed defines.
|
||||
- the "default" server, which responds to requests not handled by other
|
||||
vhosts, is always the one which is defined first. If you want a dedicated
|
||||
"default" server for such requests, you need to put it first in the configuration.
|
||||
If the configuration is in multiple files, like /etc/apache2/vhosts.d/*.conf, then
|
||||
simply name the file _default.conf, or e.g. _192.168.0.1.conf if you do it per IP
|
||||
address.
|
||||
|
||||
o TROUBLESHOOTING -- if anything does not work:
|
||||
- fire up "tail -F /var/log/apache2/*_log &" in a root shell
|
||||
- reproduce what is not working (starting apache, doing client requests,
|
||||
or whatever), and see how it is reflected in the logs
|
||||
- read http://www.suse.com/~poeml/apache-faq.html
|
||||
- make use of http://bugzilla.novell.com if you suspect a bug
|
||||
|
||||
o for all configuration questions, consult
|
||||
http://localhost/manual (if the apache2-doc package is installed), or
|
||||
http://httpd.apache.org/docs-2.2/ (the online version)
|
||||
- read the documentation under /usr/share/doc/packages/apache2/ (where you
|
||||
will also find example configuration files)
|
||||
|
||||
o building 3rd party modules:
|
||||
- install apache2-devel (and of course gcc as well as other needed
|
||||
development tools)
|
||||
- use
|
||||
apxs2 -- to build a module for all MPM types, or
|
||||
apxs2-prefork -- to build a module for the Prefork MPM, or
|
||||
apxs2-worker -- to build a module for the Worker MPM
|
||||
(see man 8 apxs2). In most cases you can just use "apxs2", the most
|
||||
notably exception being mod_php4. Using apxs2-prefork then will prevent
|
||||
you from accidentally trying to use the module with the Worker MPM.
|
||||
Typical example: apxs2 -c -i -a mod_foo.c
|
||||
-c compiles
|
||||
-i installs the module in the right place
|
||||
-a activates the module by running 'a2enmod mod_foo'
|
||||
- if the module's build system does not allow to use apxs, use at least
|
||||
CFLAGS=$(apxs2 -q CFLAGS)
|
||||
to determine the right compiler flags for your apache installation.
|
||||
This README is now online:
|
||||
http://www.opensuse.org/Apache_Howto_Quickstart
|
||||
|
||||
General starting point:
|
||||
http://www.opensuse.org/Apache
|
||||
|
@@ -1,59 +0,0 @@
|
||||
|
||||
QUICKSTART.SSL -- How to get your SSL server up and running as fast as possible
|
||||
|
||||
You need to have read the README.QUICKSTART before going on with
|
||||
this one!
|
||||
|
||||
|
||||
o make sure that apache starts with mod_ssl loaded
|
||||
- a2enmod ssl
|
||||
It adapts /etc/sysconfig/apache2:APACHE_MODULES.
|
||||
|
||||
o make sure that the SSL configuration is active
|
||||
- a2enflag SSL
|
||||
It adapts /etc/sysconfig/apache2:APACHE_SERVER_FLAGS.
|
||||
- the reason why the flag SSL is also needed is because it's enclosed in
|
||||
<IfDefine> statements. This way it can be dormant until the necessary
|
||||
prerequisite are present (keys) and you want to use it. In addition, it
|
||||
can be useful to be able to start apache unattended at boot time even if
|
||||
you use encrypted keys that need a passphrase otherwise.
|
||||
|
||||
o for a real SSL setup, I recommend TinyCA to create and manage a real ssl setup.
|
||||
It is available on SUSE Linux as package "tinyca2".
|
||||
Also, please refer to the mod_ssl documentation.
|
||||
|
||||
o The following steps will create _dummy_ keys in a very simple way:
|
||||
- run /usr/bin/gensslcert
|
||||
- it will (over)write /etc/apache2/ssl.crt/ca.crt
|
||||
/etc/apache2/ssl.key/server.key
|
||||
/etc/apache2/ssl.crt/server.crt
|
||||
/etc/apache2/ssl.csr/server.csr
|
||||
- a copy of ca.crt will be installed as /srv/www/htdocs/CA.crt for download.
|
||||
- cp vhosts.d/vhost-ssl.template vhosts.d/vhost-ssl.conf
|
||||
and adapt vhosts.d/vhost-ssl.conf al gusto
|
||||
(note it must end in .conf to be read automatically)
|
||||
|
||||
o to check your vhost setup, use "httpd2 -S -DSSL"
|
||||
|
||||
o for all configuration questions, consult
|
||||
http://localhost/manual (if the apache2-doc package is installed), or
|
||||
http://httpd.apache.org/docs-2.2/ (the online version)
|
||||
- read the documentation under /usr/share/doc/packages/apache2/ (where you
|
||||
will also find example configuration files)
|
||||
|
||||
o TROUBLESHOOTING -- if anything does not work:
|
||||
- fire up "tail -F /var/log/apache2/*_log &" in a root shell
|
||||
- reproduce what is not working (starting apache, doing client requests,
|
||||
or whatever), and see how it is reflected in the logs
|
||||
- read http://www.suse.com/~poeml/apache-faq.html
|
||||
- make use of http://bugzilla.novell.com if you suspect a bug
|
||||
|
||||
o common symptom:
|
||||
- server logs this: [Thu Aug 28 21:07:39 2003] [error] [client 192.168.0.180] Invalid method in request j
|
||||
- client shows this: SSL error: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
|
||||
cause: client speaks HTTPS, server speaks HTTP. If that happens to be port
|
||||
443, it means that the server is listening on the port but not with
|
||||
SSL. If it was the other way round (client speaks HTTP, server
|
||||
speaks HTTPS), the server would log 400 and the client show an error
|
||||
400 (HTTP_BAD_REQUEST) page.
|
||||
|
@@ -1,75 +0,0 @@
|
||||
|
||||
#
|
||||
# Example (using Digest Authentication)
|
||||
#
|
||||
|
||||
# enable needed apache modules:
|
||||
/usr/sbin/a2enmod dav
|
||||
/usr/sbin/a2enmod dav_fs
|
||||
|
||||
# Define directory to be accesed:
|
||||
davdir="editme"
|
||||
# Define a location where the credentials are stored:
|
||||
acldir=ACL
|
||||
auth_realm=$davdir
|
||||
|
||||
cd /srv/www
|
||||
|
||||
# create a directory for WebDAV access:
|
||||
mkdir $davdir
|
||||
chmod 770 $davdir
|
||||
chown root:www $davdir
|
||||
|
||||
# create the directory for the credentials:
|
||||
mkdir $acldir
|
||||
chmod 750 $acldir
|
||||
chown root:www $acldir
|
||||
|
||||
# create credentials file:
|
||||
touch $acldir/$davdir
|
||||
chown root:www $acldir/$davdir
|
||||
chmod 640 $acldir/$davdir
|
||||
|
||||
# set up a user accound
|
||||
htdigest $acldir/$davdir $auth_realm ${user:-user1}
|
||||
|
||||
|
||||
cat <<EOF
|
||||
#
|
||||
# Put this into /etc/apache2/conf.d/$davdir.conf:
|
||||
#
|
||||
|
||||
EOF
|
||||
|
||||
cat <<EOF
|
||||
|
||||
# This directive is always needed, if you use WebDAV.
|
||||
# see http://httpd.apache.org/docs-2.2/mod/mod_dav_fs.html#davlockdb
|
||||
<IfModule mod_dav_fs.c>
|
||||
DavLockDB /var/lib/apache2/DAVLock
|
||||
</IfModule>
|
||||
|
||||
<IfModule mod_dav.c>
|
||||
<IfModule mod_dav_fs.c>
|
||||
Alias /$davdir /srv/www/$davdir
|
||||
<Location /$davdir>
|
||||
DAV On
|
||||
#ForceType text/plain
|
||||
|
||||
Order Deny,Allow
|
||||
Deny from all
|
||||
|
||||
AuthType Digest
|
||||
AuthName "private area"
|
||||
|
||||
AuthDigestFile /srv/www/ACL/$davdir
|
||||
AuthDigestDomain /$davdir/
|
||||
AuthName $auth_realm
|
||||
|
||||
Require valid-user
|
||||
Satisfy Any
|
||||
</Location>
|
||||
</IfModule>
|
||||
</IfModule>
|
||||
|
||||
EOF
|
@@ -1,12 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
# check_forensic <forensic log file>
|
||||
# Author: Peter Poeml <apache@suse.de>
|
||||
|
||||
# check the forensic log for requests that did not complete
|
||||
# output the request log for each one
|
||||
|
||||
# This script is based on Ben Laurie's check_forensic, but is adjusted for GNU
|
||||
# tools (as used on Linux) and it works in a safe tmpdir directory. <poeml@suse.de>
|
||||
# tools (as used on Linux) and it works in a safe tmpdir directory.
|
||||
# todo: rewrite in a form that allows running on more operating systems.
|
||||
|
||||
F=${1:?give filename as argument. cannot read from stdin.}
|
||||
|
@@ -1,5 +1,37 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Jan 11 09:56:27 CET 2007 - mskibbe@suse.de
|
||||
Mon Mar 19 12:44:22 CET 2007 - mskibbe@suse.de
|
||||
|
||||
- Apache - Support for FATE #300687: Ports for SuSEfirewall added
|
||||
via packages (#246929)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Jan 26 12:44:04 CET 2007 - poeml@suse.de
|
||||
|
||||
- the QUICKSTART Readmes have been moved to
|
||||
http://www.opensuse.org/Apache
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Jan 22 11:24:32 CET 2007 - poeml@suse.de
|
||||
|
||||
- point out better in README.QUICKSTART.SSL that a vhost needs to
|
||||
be created
|
||||
- fixes to README.QUICKSTART.WebDAV
|
||||
- updated email addresses (now there is apache@suse.de)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sat Jan 20 17:16:20 CET 2007 - poeml@suse.de
|
||||
|
||||
- add httpd-2.2.x.doublefree.patch, backport of
|
||||
http://svn.apache.org/viewvc?diff_format=h&view=rev&revision=496831
|
||||
See http://issues.apache.org/bugzilla/show_bug.cgi?id=39985
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Jan 18 22:00:48 CET 2007 - poeml@suse.de
|
||||
|
||||
- create debuginfo package in the buildservice
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Jan 12 14:25:51 CET 2007 - mskibbe@suse.de
|
||||
|
||||
- change path to service cml document (fate #301708)
|
||||
|
||||
|
17
apache2.firewall
Normal file
17
apache2.firewall
Normal file
@@ -0,0 +1,17 @@
|
||||
## Name: Apache 2
|
||||
## Description: Opens ports for Apache Web Server.
|
||||
|
||||
# space separated list of allowed TCP ports
|
||||
TCP="http"
|
||||
|
||||
# space separated list of allowed UDP ports
|
||||
UDP="http"
|
||||
|
||||
# space separated list of allowed RPC services
|
||||
RPC=""
|
||||
|
||||
# space separated list of allowed IP protocols
|
||||
IP=""
|
||||
|
||||
# space separated list of allowed UDP broadcast ports
|
||||
BROADCAST=""
|
45
apache2.spec
45
apache2.spec
@@ -54,7 +54,7 @@ License: The Apache Software License
|
||||
Group: Productivity/Networking/Web/Servers
|
||||
%define realver 2.2.4
|
||||
Version: 2.2.4
|
||||
Release: 3
|
||||
Release: 10
|
||||
#Source0: http://www.apache.org/dist/httpd-%{version}.tar.bz2
|
||||
Source0: http://httpd.apache.org/dev/dist/httpd-%{realver}.tar.bz2
|
||||
Source10: SUSE-NOTICE
|
||||
@@ -65,8 +65,6 @@ Source17: mkcert.sh.gz
|
||||
Source18: robots.txt
|
||||
Source20: favicon.ico
|
||||
Source22: apache2-README.QUICKSTART
|
||||
Source23: apache2-README.QUICKSTART.SSL
|
||||
Source231: apache2-README.QUICKSTART.WebDAV
|
||||
Source24: apache2-README
|
||||
Source25: gensslcert
|
||||
Source27: %{pname}.logrotate
|
||||
@@ -81,6 +79,7 @@ Source45: sysconf_addword
|
||||
Source46: a2enflag
|
||||
Source47: a2enmod
|
||||
Source48: apache2.xml
|
||||
Source49: apache2.firewall
|
||||
Source100: apache2-httpd.conf
|
||||
Source101: apache2-errors.conf
|
||||
Source102: apache2-default-server.conf
|
||||
@@ -106,6 +105,7 @@ Patch65: httpd-2.0.49-log_server_status.dif
|
||||
Patch66: httpd-2.0.54-envvars.dif
|
||||
Patch67: httpd-2.2.0-apxs-a2enmod.dif
|
||||
Patch68: httpd-2.2.3-AddDirectoryIndexCharset.patch
|
||||
Patch69: httpd-2.2.x.doublefree.patch
|
||||
URL: http://httpd.apache.org/
|
||||
Icon: Apache.xpm
|
||||
Summary: The Apache Web Server Version 2.0
|
||||
@@ -285,6 +285,8 @@ Authors:
|
||||
--------
|
||||
Too many to list here -- see /usr/share/doc/packages/apache2/ABOUT_APACHE
|
||||
|
||||
%if 0%{?opensuse_bs}
|
||||
%endif
|
||||
%prep
|
||||
#
|
||||
# O/ ._ .__ ._
|
||||
@@ -299,6 +301,7 @@ Authors:
|
||||
%patch66 -p1
|
||||
%patch67 -p1
|
||||
%patch68 -p1
|
||||
%patch69 -p0
|
||||
#
|
||||
cat $RPM_SOURCE_DIR/SUSE-NOTICE >> NOTICE
|
||||
#
|
||||
@@ -322,6 +325,9 @@ autoreconf --force --install
|
||||
#
|
||||
function configure {
|
||||
CFLAGS="$RPM_OPT_FLAGS -fPIC -Wall -fno-strict-aliasing -DLDAP_DEPRECATED" \
|
||||
%if 0%{?opensuse_bs}
|
||||
CFLAGS="$CFLAGS -g"
|
||||
%endif
|
||||
CPPFLAGS="-DSSL_EXPERIMENTAL_ENGINE -DMAX_SERVER_LIMIT=200000 -DLDAP_DEPRECATED -DMAXLINE=4096" \
|
||||
./configure \
|
||||
--enable-maintainer-mode \
|
||||
@@ -411,6 +417,9 @@ for mpm in %{mpms_to_build}; do
|
||||
make CFLAGS="$RPM_OPT_FLAGS -fPIC \
|
||||
-fno-strict-aliasing \
|
||||
-Wall \
|
||||
%if 0%{?opensuse_bs}
|
||||
-g \
|
||||
%endif
|
||||
-DDEFAULT_PIDLOG='\"%{runtimedir}/%{httpd}.pid\"' \
|
||||
-DDEFAULT_ERRORLOG='\"%{logfiledir}/error_log\"' " \
|
||||
%{?jobs:-j%jobs}
|
||||
@@ -570,8 +579,6 @@ sed "s+@@all_modules@@+$all_modules +" $RPM_SOURCE_DIR/sysconfig.%{pname} \
|
||||
# install READMEs
|
||||
cp -p $RPM_SOURCE_DIR/%{pname}-README README.%VENDOR
|
||||
cp -p $RPM_SOURCE_DIR/%{pname}-README.QUICKSTART README.QUICKSTART
|
||||
cp -p $RPM_SOURCE_DIR/%{pname}-README.QUICKSTART.SSL README.QUICKSTART.SSL
|
||||
cp -p $RPM_SOURCE_DIR/%{pname}-README.QUICKSTART.WebDAV README.QUICKSTART.WebDAV
|
||||
#
|
||||
# install configuration files:
|
||||
mkdir -p $RPM_BUILD_ROOT/%{runtimedir}
|
||||
@@ -668,7 +675,9 @@ pushd $RPM_BUILD_ROOT/%{_sbindir}
|
||||
EOT_ED
|
||||
mv apxs apxs%{vers}
|
||||
popd
|
||||
|
||||
# install firewall information file
|
||||
install -d $RPM_BUILD_ROOT%{_sysconfdir}/SuSEfirewall2.d/services/
|
||||
install -m 644 %{S:49} $RPM_BUILD_ROOT%{_sysconfdir}/SuSEfirewall2.d/services/%{name}
|
||||
#
|
||||
# filelists
|
||||
#
|
||||
@@ -850,6 +859,9 @@ mv $RPM_BUILD_ROOT/%{sysconfdir}/original .
|
||||
%{_prefix}/share/%{pname}/find_httpd2_includes
|
||||
%{_prefix}/share/%{pname}/find_mpm
|
||||
%{_prefix}/share/%{pname}/load_configuration
|
||||
%dir /etc/SuSEfirewall2.d
|
||||
%dir /etc/SuSEfirewall2.d/services
|
||||
%config %{_sysconfdir}/SuSEfirewall2.d/services/%{name}
|
||||
%if %prefork
|
||||
|
||||
%files prefork
|
||||
@@ -1014,8 +1026,25 @@ if ! test -f /.buildenv; then
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
fi
|
||||
|
||||
%changelog -n apache2
|
||||
* Thu Jan 11 2007 - mskibbe@suse.de
|
||||
%changelog
|
||||
* Mon Mar 19 2007 - mskibbe@suse.de
|
||||
- Apache - Support for FATE #300687: Ports for SuSEfirewall added
|
||||
via packages (#246929)
|
||||
* Fri Jan 26 2007 - poeml@suse.de
|
||||
- the QUICKSTART Readmes have been moved to
|
||||
http://www.opensuse.org/Apache
|
||||
* Mon Jan 22 2007 - poeml@suse.de
|
||||
- point out better in README.QUICKSTART.SSL that a vhost needs to
|
||||
be created
|
||||
- fixes to README.QUICKSTART.WebDAV
|
||||
- updated email addresses (now there is apache@suse.de)
|
||||
* Sat Jan 20 2007 - poeml@suse.de
|
||||
- add httpd-2.2.x.doublefree.patch, backport of
|
||||
http://svn.apache.org/viewvc?diff_format=h&view=rev&revision=496831
|
||||
See http://issues.apache.org/bugzilla/show_bug.cgi?id=39985
|
||||
* Thu Jan 18 2007 - poeml@suse.de
|
||||
- create debuginfo package in the buildservice
|
||||
* Fri Jan 12 2007 - mskibbe@suse.de
|
||||
- change path to service cml document (fate #301708)
|
||||
* Tue Jan 09 2007 - poeml@suse.de
|
||||
- upstream 2.2.4
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
# Peter Poeml <poeml@suse.de>
|
||||
# Peter Poeml <apache@suse.de>
|
||||
#
|
||||
# Script to generate ssl keys for mod_ssl, without requiring user input
|
||||
# most of it is copied from mkcert.sh of the mod_ssl distribution
|
||||
|
358
httpd-2.2.x.doublefree.patch
Normal file
358
httpd-2.2.x.doublefree.patch
Normal file
@@ -0,0 +1,358 @@
|
||||
Attempt of a backport of
|
||||
http://svn.apache.org/viewvc?diff_format=h&view=rev&revision=496831
|
||||
|
||||
See
|
||||
http://issues.apache.org/bugzilla/show_bug.cgi?id=39985
|
||||
|
||||
poeml@suse.de
|
||||
|
||||
Index: modules/database/mod_dbd.c
|
||||
===================================================================
|
||||
--- modules/database/mod_dbd.c (revision 497960)
|
||||
+++ modules/database/mod_dbd.c (working copy)
|
||||
@@ -50,10 +50,11 @@
|
||||
const char *params;
|
||||
int persist;
|
||||
dbd_prepared *prepared;
|
||||
+ apr_pool_t *pool;
|
||||
#if APR_HAS_THREADS
|
||||
apr_thread_mutex_t *mutex;
|
||||
- apr_pool_t *pool;
|
||||
apr_reslist_t *dbpool;
|
||||
+ int destroyed;
|
||||
int nmin;
|
||||
int nkeep;
|
||||
int nmax;
|
||||
@@ -241,6 +242,12 @@
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
+static apr_status_t dbd_close(void *data)
|
||||
+{
|
||||
+ ap_dbd_t *rec = data;
|
||||
+ return apr_dbd_close(rec->driver, rec->handle);
|
||||
+}
|
||||
+
|
||||
/************ svr cfg: manage db connection pool ****************/
|
||||
/* an apr_reslist_constructor for SQL connections
|
||||
* Also use this for opening in non-reslist modes, since it gives
|
||||
@@ -249,16 +256,20 @@
|
||||
static apr_status_t dbd_construct(void **db, void *params, apr_pool_t *pool)
|
||||
{
|
||||
svr_cfg *svr = (svr_cfg*) params;
|
||||
- ap_dbd_t *rec = apr_pcalloc(pool, sizeof(ap_dbd_t));
|
||||
+ apr_pool_t *rec_pool, *prepared_pool;
|
||||
+ ap_dbd_t *rec;
|
||||
apr_status_t rv;
|
||||
|
||||
- /* this pool is mostly so dbd_close can destroy the prepared stmts */
|
||||
- rv = apr_pool_create(&rec->pool, pool);
|
||||
+ rv = apr_pool_create(&rec_pool, pool);
|
||||
if (rv != APR_SUCCESS) {
|
||||
ap_log_perror(APLOG_MARK, APLOG_CRIT, rv, pool,
|
||||
"DBD: Failed to create memory pool");
|
||||
}
|
||||
|
||||
+ rec = apr_pcalloc(rec_pool, sizeof(ap_dbd_t));
|
||||
+
|
||||
+ rec->pool = rec_pool;
|
||||
+
|
||||
/* The driver is loaded at config time now, so this just checks a hash.
|
||||
* If that changes, the driver DSO could be registered to unload against
|
||||
* our pool, which is probably not what we want. Error checking isn't
|
||||
@@ -299,63 +310,94 @@
|
||||
case APR_SUCCESS:
|
||||
break;
|
||||
}
|
||||
- *db = rec;
|
||||
- rv = dbd_prepared_init(rec->pool, svr, rec);
|
||||
+
|
||||
+ apr_pool_cleanup_register(rec->pool, rec, dbd_close,
|
||||
+ apr_pool_cleanup_null);
|
||||
+
|
||||
+ /* we use a sub-pool for the prepared statements for each connection so
|
||||
+ * that they will be cleaned up first, before the connection is closed
|
||||
+ */
|
||||
+ rv = apr_pool_create(&prepared_pool, rec->pool);
|
||||
if (rv != APR_SUCCESS) {
|
||||
+ ap_log_perror(APLOG_MARK, APLOG_CRIT, rv, rec->pool,
|
||||
+ "DBD: Failed to create memory pool");
|
||||
+
|
||||
+ apr_pool_destroy(rec->pool);
|
||||
+ return rv;
|
||||
+ }
|
||||
+
|
||||
+ rv = dbd_prepared_init(prepared_pool, svr, rec);
|
||||
+ if (rv != APR_SUCCESS) {
|
||||
const char *errmsg = apr_dbd_error(rec->driver, rec->handle, rv);
|
||||
ap_log_perror(APLOG_MARK, APLOG_CRIT, rv, rec->pool,
|
||||
"DBD: failed to initialise prepared SQL statements: %s",
|
||||
(errmsg ? errmsg : "[???]"));
|
||||
}
|
||||
+
|
||||
+ *db = rec;
|
||||
+
|
||||
return rv;
|
||||
}
|
||||
-static apr_status_t dbd_close(void *CONN)
|
||||
-{
|
||||
- ap_dbd_t *conn = CONN;
|
||||
- apr_status_t rv = apr_dbd_close(conn->driver, conn->handle);
|
||||
- apr_pool_destroy(conn->pool);
|
||||
- return rv;
|
||||
-}
|
||||
#if APR_HAS_THREADS
|
||||
static apr_status_t dbd_destruct(void *sql, void *params, apr_pool_t *pool)
|
||||
{
|
||||
- return dbd_close(sql);
|
||||
+ svr_cfg *svr = params;
|
||||
+
|
||||
+ if (!svr->destroyed) {
|
||||
+ ap_dbd_t *rec = sql;
|
||||
+
|
||||
+ apr_pool_destroy(rec->pool);
|
||||
+ }
|
||||
+
|
||||
+ return APR_SUCCESS;
|
||||
}
|
||||
|
||||
-static apr_status_t dbd_setup(apr_pool_t *pool, svr_cfg *svr)
|
||||
+static apr_status_t dbd_destroy(void *data)
|
||||
{
|
||||
+ svr_cfg *svr = data;
|
||||
+
|
||||
+ svr->destroyed = 1;
|
||||
+
|
||||
+ return APR_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+static apr_status_t dbd_setup(server_rec *s, svr_cfg *svr)
|
||||
+{
|
||||
apr_status_t rv;
|
||||
|
||||
- /* create a pool just for the reslist from a process-lifetime pool;
|
||||
- * that pool (s->process->pool in the dbd_setup_lock case,
|
||||
- * whatever was passed to ap_run_child_init in the dbd_setup_init case)
|
||||
- * will be shared with other threads doing other non-mod_dbd things
|
||||
- * so we can't use it for the reslist directly
|
||||
+ /* We create the reslist using a sub-pool of the pool passed to our
|
||||
+ * child_init hook. No other threads can be here because we're
|
||||
+ * either in the child_init phase or dbd_setup_lock() acquired our mutex.
|
||||
+ * No other threads will use this sub-pool after this, except via
|
||||
+ * reslist calls, which have an internal mutex.
|
||||
+ *
|
||||
+ * We need to short-circuit the cleanup registered internally by
|
||||
+ * apr_reslist_create(). We do this by registering dbd_destroy()
|
||||
+ * as a cleanup afterwards, so that it will run before the reslist's
|
||||
+ * internal cleanup.
|
||||
+ *
|
||||
+ * If we didn't do this, then we could free memory twice when the pool
|
||||
+ * was destroyed. When apr_pool_destroy() runs, it first destroys all
|
||||
+ * all the per-connection sub-pools created in dbd_construct(), and
|
||||
+ * then it runs the reslist's cleanup. The cleanup calls dbd_destruct()
|
||||
+ * on each resource, which would then attempt to destroy the sub-pools
|
||||
+ * a second time.
|
||||
*/
|
||||
- rv = apr_pool_create(&svr->pool, pool);
|
||||
- if (rv != APR_SUCCESS) {
|
||||
- ap_log_perror(APLOG_MARK, APLOG_CRIT, rv, pool,
|
||||
- "DBD: Failed to create reslist memory pool");
|
||||
- return rv;
|
||||
- }
|
||||
-
|
||||
rv = apr_reslist_create(&svr->dbpool, svr->nmin, svr->nkeep, svr->nmax,
|
||||
apr_time_from_sec(svr->exptime),
|
||||
dbd_construct, dbd_destruct, svr, svr->pool);
|
||||
- if (rv == APR_SUCCESS) {
|
||||
- apr_pool_cleanup_register(svr->pool, svr->dbpool,
|
||||
- (void*)apr_reslist_destroy,
|
||||
- apr_pool_cleanup_null);
|
||||
- }
|
||||
- else {
|
||||
- ap_log_perror(APLOG_MARK, APLOG_CRIT, rv, svr->pool,
|
||||
+ if (rv != APR_SUCCESS) {
|
||||
+ ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s,
|
||||
"DBD: failed to initialise");
|
||||
- apr_pool_destroy(svr->pool);
|
||||
- svr->pool = NULL;
|
||||
+ return rv;
|
||||
}
|
||||
|
||||
- return rv;
|
||||
+ apr_pool_cleanup_register(svr->pool, svr, dbd_destroy,
|
||||
+ apr_pool_cleanup_null);
|
||||
+ return APR_SUCCESS;
|
||||
}
|
||||
+#endif
|
||||
+
|
||||
static apr_status_t dbd_setup_init(apr_pool_t *pool, server_rec *s)
|
||||
{
|
||||
svr_cfg *svr = ap_get_module_config(s->module_config, &dbd_module);
|
||||
@@ -374,7 +416,15 @@
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
|
||||
- rv = dbd_setup(pool, svr);
|
||||
+ rv = apr_pool_create(&svr->pool, pool);
|
||||
+ if (rv != APR_SUCCESS) {
|
||||
+ ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s,
|
||||
+ "DBD: Failed to create reslist cleanup memory pool");
|
||||
+ return rv;
|
||||
+ }
|
||||
+
|
||||
+#if APR_HAS_THREADS
|
||||
+ rv = dbd_setup(s, svr);
|
||||
if (rv == APR_SUCCESS) {
|
||||
return rv;
|
||||
}
|
||||
@@ -387,9 +437,12 @@
|
||||
ap_log_perror(APLOG_MARK, APLOG_CRIT, rv, pool,
|
||||
"DBD: Failed to create thread mutex");
|
||||
}
|
||||
+#endif
|
||||
+
|
||||
return rv;
|
||||
}
|
||||
-static apr_status_t dbd_setup_lock(apr_pool_t *pool, server_rec *s)
|
||||
+#if APR_HAS_THREADS
|
||||
+static apr_status_t dbd_setup_lock(server_rec *s)
|
||||
{
|
||||
svr_cfg *svr = ap_get_module_config(s->module_config, &dbd_module);
|
||||
apr_status_t rv, rv2 = APR_SUCCESS;
|
||||
@@ -404,18 +457,18 @@
|
||||
|
||||
rv = apr_thread_mutex_lock(svr->mutex);
|
||||
if (rv != APR_SUCCESS) {
|
||||
- ap_log_perror(APLOG_MARK, APLOG_CRIT, rv, pool,
|
||||
+ ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s,
|
||||
"DBD: Failed to acquire thread mutex");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!svr->dbpool) {
|
||||
- rv2 = dbd_setup(s->process->pool, svr);
|
||||
+ rv2 = dbd_setup(s, svr);
|
||||
}
|
||||
|
||||
rv = apr_thread_mutex_unlock(svr->mutex);
|
||||
if (rv != APR_SUCCESS) {
|
||||
- ap_log_perror(APLOG_MARK, APLOG_CRIT, rv, pool,
|
||||
+ ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s,
|
||||
"DBD: Failed to release thread mutex");
|
||||
if (rv2 == APR_SUCCESS) {
|
||||
rv2 = rv;
|
||||
@@ -434,7 +487,7 @@
|
||||
{
|
||||
svr_cfg *svr = ap_get_module_config(s->module_config, &dbd_module);
|
||||
if (!svr->persist) {
|
||||
- dbd_close((void*) sql);
|
||||
+ apr_pool_destroy(sql->pool);
|
||||
}
|
||||
#if APR_HAS_THREADS
|
||||
else {
|
||||
@@ -459,12 +512,12 @@
|
||||
|
||||
if (!svr->persist) {
|
||||
/* Return a once-only connection */
|
||||
- rv = dbd_construct(&rec, svr, s->process->pool);
|
||||
+ dbd_construct((void*) &rec, svr, pool);
|
||||
return (rv == APR_SUCCESS) ? arec : NULL;
|
||||
}
|
||||
|
||||
if (!svr->dbpool) {
|
||||
- if (dbd_setup_lock(pool, s) != APR_SUCCESS) {
|
||||
+ if (dbd_setup_lock(s) != APR_SUCCESS) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -503,7 +556,7 @@
|
||||
|
||||
if (!svr->persist) {
|
||||
/* Return a once-only connection */
|
||||
- rv = dbd_construct(&rec, svr, s->process->pool);
|
||||
+ dbd_construct((void*) &rec, svr, pool);
|
||||
return (rv == APR_SUCCESS) ? arec : NULL;
|
||||
}
|
||||
|
||||
@@ -519,14 +572,14 @@
|
||||
ap_log_perror(APLOG_MARK, APLOG_ERR, rv, pool,
|
||||
"DBD[%s] Error: %s", svr->name, errmsg);
|
||||
svr->conn = NULL;
|
||||
+ apr_pool_destroy(rec->pool);
|
||||
}
|
||||
}
|
||||
+
|
||||
/* We don't have a connection right now, so we'll open one */
|
||||
if (!svr->conn) {
|
||||
- if (dbd_construct(&rec, svr, s->process->pool) == APR_SUCCESS) {
|
||||
+ if (dbd_construct(&rec, svr, svr->pool) == APR_SUCCESS) {
|
||||
svr->conn = arec ;
|
||||
- apr_pool_cleanup_register(s->process->pool, svr->conn,
|
||||
- dbd_close, apr_pool_cleanup_null);
|
||||
}
|
||||
}
|
||||
return svr->conn;
|
||||
@@ -569,10 +622,6 @@
|
||||
apr_pool_cleanup_register(r->pool, req, dbd_release,
|
||||
apr_pool_cleanup_null);
|
||||
}
|
||||
- else {
|
||||
- apr_pool_cleanup_register(r->pool, req->conn, dbd_close,
|
||||
- apr_pool_cleanup_null);
|
||||
- }
|
||||
}
|
||||
}
|
||||
return req->conn;
|
||||
@@ -592,10 +641,6 @@
|
||||
apr_pool_cleanup_register(c->pool, req, dbd_release,
|
||||
apr_pool_cleanup_null);
|
||||
}
|
||||
- else {
|
||||
- apr_pool_cleanup_register(c->pool, req->conn, dbd_close,
|
||||
- apr_pool_cleanup_null);
|
||||
- }
|
||||
}
|
||||
}
|
||||
return req->conn;
|
||||
@@ -617,15 +662,9 @@
|
||||
|
||||
ret = ap_get_module_config(r->request_config, &dbd_module);
|
||||
if (!ret) {
|
||||
- svr = ap_get_module_config(r->server->module_config, &dbd_module);
|
||||
ret = ap_dbd_open(r->pool, r->server);
|
||||
if (ret) {
|
||||
ap_set_module_config(r->request_config, &dbd_module, ret);
|
||||
- if (!svr->persist) {
|
||||
- apr_pool_cleanup_register(r->pool, svr->conn, dbd_close,
|
||||
- apr_pool_cleanup_null);
|
||||
- }
|
||||
- /* if persist then dbd_open registered cleanup on proc pool */
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@@ -635,15 +674,9 @@
|
||||
svr_cfg *svr;
|
||||
ap_dbd_t *ret = ap_get_module_config(c->conn_config, &dbd_module);
|
||||
if (!ret) {
|
||||
- svr = ap_get_module_config(c->base_server->module_config, &dbd_module);
|
||||
ret = ap_dbd_open(c->pool, c->base_server);
|
||||
if (ret) {
|
||||
ap_set_module_config(c->conn_config, &dbd_module, ret);
|
||||
- if (!svr->persist) {
|
||||
- apr_pool_cleanup_register(c->pool, svr->conn, dbd_close,
|
||||
- apr_pool_cleanup_null);
|
||||
- }
|
||||
- /* if persist then dbd_open registered cleanup on proc pool */
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@@ -670,9 +703,7 @@
|
||||
}
|
||||
static void dbd_hooks(apr_pool_t *pool)
|
||||
{
|
||||
-#if APR_HAS_THREADS
|
||||
ap_hook_child_init((void*)dbd_setup_init, NULL, NULL, APR_HOOK_MIDDLE);
|
||||
-#endif
|
||||
APR_REGISTER_OPTIONAL_FN(ap_dbd_open);
|
||||
APR_REGISTER_OPTIONAL_FN(ap_dbd_close);
|
||||
APR_REGISTER_OPTIONAL_FN(ap_dbd_acquire);
|
@@ -2,10 +2,11 @@
|
||||
#
|
||||
# Copyright (c) 1996, 1997, 1998 S.u.S.E. GmbH
|
||||
# Copyright (c) 1998, 1999, 2000, 2001 SuSE GmbH
|
||||
# Copyright (c) 2002, 2003 SuSE Linux AG
|
||||
# Copyright (c) 2002, 2003, (2004?) SuSE Linux AG
|
||||
# Copyright (c) 2004(?), 2005, 2006, 2007 SUSE Linux Products GmbH
|
||||
#
|
||||
# Authors: Rolf Haberrecker <rolf@suse.de>, 2001
|
||||
# Peter Poeml <poeml@suse.de>, 2002, 2003, 2004, 2005
|
||||
# Authors: Rolf Haberrecker <apache@suse.de>, 2001
|
||||
# Peter Poeml <apache@suse.de>, 2002, 2003, 2004, 2005, 2006, 2007
|
||||
#
|
||||
#
|
||||
# /etc/init.d/apache2
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2005 Peter Poeml <poeml@suse.de>. All Rights Reserved.
|
||||
# Copyright 2005 Peter Poeml <apache@suse.de>. All Rights Reserved.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
Reference in New Issue
Block a user