Changes with Apache 2.3.12
+ *) MPM helper function ap_remove_pid() added. [Jeff Trawick]
+
*) Enable DEFAULT_REL_RUNTIMEDIR on Windows and NetWare. [various]
*) Correct C++ incompatibility with http_log.h. [Stefan Fritsch, Jeff
/**
* Log the current pid of the parent process
- * @param p The pool to use for logging
+ * @param p The pool to use for processing
* @param fname The name of the file to log to
*/
AP_DECLARE(void) ap_log_pid(apr_pool_t *p, const char *fname);
+/**
+ * Remove the pidfile.
+ * @param p The pool to use for processing
+ * @param fname The name of the pid file to remove
+ */
+AP_DECLARE(void) ap_remove_pid(apr_pool_t *p, const char *fname);
+
/**
* Retrieve the pid from a pidfile.
- * @param p The pool to use for logging
+ * @param p The pool to use for processing
* @param filename The name of the file containing the pid
* @param mypid Pointer to pid_t (valid only if return APR_SUCCESS)
*/
"Command line: '%s'", result);
}
+AP_DECLARE(void) ap_remove_pid(apr_pool_t *p, const char *rel_fname)
+{
+ apr_status_t rv;
+ const char *fname = ap_server_root_relative(p, rel_fname);
+
+ if (fname != NULL) {
+ rv = apr_file_remove(fname, p);
+ if (rv != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf,
+ "failed to remove PID file %s", fname);
+ }
+ else {
+ ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf,
+ "removed PID file %s (pid=%" APR_PID_T_FMT ")",
+ fname, getpid());
+ }
+ }
+}
+
AP_DECLARE(void) ap_log_pid(apr_pool_t *p, const char *filename)
{
apr_file_t *pid_file = NULL;
if (!child_fatal) {
/* cleanup pid file on normal shutdown */
- const char *pidfile = NULL;
- pidfile = ap_server_root_relative(pconf, ap_pid_fname);
- if (pidfile != NULL && unlink(pidfile) == 0)
- ap_log_error(APLOG_MARK, APLOG_INFO, 0,
- ap_server_conf,
- "removed PID file %s (pid=%ld)",
- pidfile, (long) getpid());
-
+ ap_remove_pid(pconf, ap_pid_fname);
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0,
ap_server_conf, "caught SIGTERM, shutting down");
}
if (!child_fatal) {
/* cleanup pid file on normal shutdown */
- const char *pidfile = NULL;
- pidfile = ap_server_root_relative (pconf, ap_pid_fname);
- if ( pidfile != NULL && unlink(pidfile) == 0)
- ap_log_error(APLOG_MARK, APLOG_INFO, 0,
- ap_server_conf,
- "removed PID file %s (pid=%ld)",
- pidfile, (long)getpid());
-
+ ap_remove_pid(pconf, ap_pid_fname);
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
"caught " AP_SIG_GRACEFUL_STOP_STRING
", shutting down gracefully");
ap_scoreboard_image->global->running_generation = ap_my_generation;
if (!restart) {
- const char *pidfile = ap_server_root_relative(pconf, ap_pid_fname);
-
- if (pidfile != NULL && remove(pidfile) == 0) {
- ap_log_error(APLOG_MARK, APLOG_INFO, APR_SUCCESS,
- ap_server_conf, "removed PID file %s (pid=%d)",
- pidfile, getpid());
- }
-
+ ap_remove_pid(pconf, ap_pid_fname);
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
"caught SIGTERM, shutting down");
return 1;
ap_reclaim_child_processes(1); /* Start with SIGTERM */
/* cleanup pid file on normal shutdown */
- {
- const char *pidfile = NULL;
- pidfile = ap_server_root_relative (pconf, ap_pid_fname);
- if ( pidfile != NULL && unlink(pidfile) == 0)
- ap_log_error(APLOG_MARK, APLOG_INFO,
- 0, ap_server_conf,
- "removed PID file %s (pid=%ld)",
- pidfile, (long)getpid());
- }
-
+ ap_remove_pid(pconf, ap_pid_fname);
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
"caught SIGTERM, shutting down");
ap_relieve_child_processes();
/* cleanup pid file */
- {
- const char *pidfile = NULL;
- pidfile = ap_server_root_relative (pconf, ap_pid_fname);
- if ( pidfile != NULL && unlink(pidfile) == 0)
- ap_log_error(APLOG_MARK, APLOG_INFO,
- 0, ap_server_conf,
- "removed PID file %s (pid=%ld)",
- pidfile, (long)getpid());
- }
-
+ ap_remove_pid(pconf, ap_pid_fname);
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
"caught " AP_SIG_GRACEFUL_STOP_STRING ", shutting down gracefully");
if (!restart)
{
/* Shutting down. Clean up... */
- const char *pidfile = ap_server_root_relative (pconf, ap_pid_fname);
-
- if (pidfile != NULL && unlink(pidfile) == 0) {
- ap_log_error(APLOG_MARK, APLOG_INFO, APR_SUCCESS,
- ap_server_conf, "removed PID file %s (pid=%ld)",
- pidfile, GetCurrentProcessId());
- }
+ ap_remove_pid(pconf, ap_pid_fname);
apr_proc_mutex_destroy(start_mutex);
CloseHandle(restart_event);
if (!child_fatal) {
/* cleanup pid file on normal shutdown */
- const char *pidfile = NULL;
- pidfile = ap_server_root_relative (pconf, ap_pid_fname);
- if ( pidfile != NULL && unlink(pidfile) == 0)
- ap_log_error(APLOG_MARK, APLOG_INFO, 0,
- ap_server_conf,
- "removed PID file %s (pid=%" APR_PID_T_FMT ")",
- pidfile, getpid());
-
+ ap_remove_pid(pconf, ap_pid_fname);
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0,
ap_server_conf, "caught SIGTERM, shutting down");
}
if (!child_fatal) {
/* cleanup pid file on normal shutdown */
- const char *pidfile = NULL;
- pidfile = ap_server_root_relative (pconf, ap_pid_fname);
- if ( pidfile != NULL && unlink(pidfile) == 0)
- ap_log_error(APLOG_MARK, APLOG_INFO, 0,
- ap_server_conf,
- "removed PID file %s (pid=%" APR_PID_T_FMT ")",
- pidfile, getpid());
-
+ ap_remove_pid(pconf, ap_pid_fname);
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
"caught " AP_SIG_GRACEFUL_STOP_STRING
", shutting down gracefully");