Changes with Apache 2.0.31-dev
+ *) The Win32 mpm_winnt now has a shared scoreboard. [William Rowe]
+
*) Change ap_get_brigade prototype to use apr_off_t instead of apr_off_t*.
[Justin Erenkrantz]
*/
#define HARD_SERVER_LIMIT 1
+extern apr_shm_t *ap_scoreboard_shm;
server_rec *ap_server_conf;
typedef HANDLE thread;
* data. The sockets have been set to listening in the parent process.
*/
pipe = GetStdHandle(STD_INPUT_HANDLE);
+
for (lr = ap_listeners; lr; lr = lr->next) {
if (!ReadFile(pipe, &WSAProtocolInfo, sizeof(WSAPROTOCOL_INFO),
&BytesRead, (LPOVERLAPPED) NULL)) {
HANDLE hShareError;
HANDLE hShareErrorDup;
HANDLE hCurrentProcess = GetCurrentProcess();
+ HANDLE sb_os_shm;
+ HANDLE dup_os_shm;
SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
LPWSAPROTOCOL_INFO lpWSAProtocolInfo;
*/
Sleep(1000);
+ if ((rv = apr_os_shm_get(&sb_os_shm, ap_scoreboard_shm)) != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_CRIT, rv, ap_server_conf,
+ "Parent: Unable to retrieve the scoreboard handle");
+ return -1;
+ }
+ if (!DuplicateHandle(hCurrentProcess, sb_os_shm, pi.hProcess, &dup_os_shm,
+ 0, FALSE, DUPLICATE_SAME_ACCESS)) {
+ ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), ap_server_conf,
+ "Parent: Unable to duplicate the scoreboard handle to the child");
+ return -1;
+ }
+ if (!WriteFile(hPipeWrite, &dup_os_shm, sizeof(dup_os_shm),
+ &BytesWritten, (LPOVERLAPPED) NULL)
+ || (BytesWritten != sizeof(dup_os_shm))) {
+ ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), ap_server_conf,
+ "Parent: Unable to send the scoreboard handle to the child");
+ return -1;
+ }
+
/* Run the chain of open sockets. For each socket, duplicate it
* for the target process then send the WSAPROTOCOL_INFO
* (returned by dup socket) to the child.
if (one_process) {
/* Set up the scoreboard. */
- ap_run_pre_mpm(pconf, SB_NOT_SHARED);
+ ap_run_pre_mpm(pconf, SB_SHARED);
if (ap_setup_listeners(ap_server_conf) < 1) {
return 1;
}
}
else {
/* Set up the scoreboard. */
+ HANDLE pipe;
+ HANDLE sb_os_shm;
+ DWORD BytesRead;
+ apr_status_t rv;
+
+ pipe = GetStdHandle(STD_INPUT_HANDLE);
+ if (!ReadFile(pipe, &sb_os_shm, sizeof(sb_os_shm),
+ &BytesRead, (LPOVERLAPPED) NULL)
+ || (BytesRead != sizeof(sb_os_shm))) {
+ ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), ap_server_conf,
+ "child: Unable to access scoreboard handle from parent");
+ ap_signal_parent(SIGNAL_PARENT_SHUTDOWN);
+ exit(1);
+ }
+ if ((rv = apr_os_shm_put(&ap_scoreboard_shm, &sb_os_shm, s->process->pool))
+ != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_CRIT, rv, ap_server_conf,
+ "child: Unable to access scoreboard handle from parent");
+ ap_signal_parent(SIGNAL_PARENT_SHUTDOWN);
+ exit(1);
+ }
+
ap_run_pre_mpm(pconf, SB_SHARED_CHILD);
ap_my_generation = atoi(getenv("AP_MY_GENERATION"));
get_listeners_from_parent(ap_server_conf);
"Child %d: Child process is exiting", my_pid);
return 1;
}
- else {
+ else /* Child */ {
/* Set up the scoreboard. */
ap_run_pre_mpm(pconf, SB_SHARED);
AP_DECLARE_DATA apr_time_t ap_restart_time = 0;
#if APR_HAS_SHARED_MEMORY
+
#include "apr_shm.h"
-static apr_shm_t *scoreboard_shm = NULL;
+
+#ifndef WIN32
+static /* but must be exported to mpm_winnt */
+#endif
+ apr_shm_t *ap_scoreboard_shm = NULL;
+
#endif
APR_HOOK_STRUCT(
#if APR_HAS_SHARED_MEMORY
free(ap_scoreboard_image);
ap_scoreboard_image = NULL;
- apr_shm_destroy(scoreboard_shm);
+ apr_shm_destroy(ap_scoreboard_shm);
#endif
return APR_SUCCESS;
}
char *fname = NULL;
#ifndef WIN32
- rv = apr_shm_create(&scoreboard_shm, scoreboard_size, fname, p);
+ rv = apr_shm_create(&ap_scoreboard_shm, scoreboard_size, fname, p);
if ((rv != APR_SUCCESS) && (rv != APR_ENOTIMPL)) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
"Fatal error: could not create scoreboard "
if (ap_scoreboard_fname) {
fname = ap_server_root_relative(p, ap_scoreboard_fname);
}
- rv = apr_shm_create(&scoreboard_shm, scoreboard_size, fname, p);
+ rv = apr_shm_create(&ap_scoreboard_shm, scoreboard_size, fname, p);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
"Fatal error: could not open(create) scoreboard");
if (!detached) {
return APR_SUCCESS;
}
- if (ap_scoreboard_fname) {
- fname = ap_server_root_relative(p, ap_scoreboard_fname);
- }
- rv = apr_shm_attach(&scoreboard_shm, fname, p);
- if (rv != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
- "Fatal error: could not open(create) scoreboard");
- return rv;
- }
- if (apr_shm_size_get(scoreboard_shm) < scoreboard_size) {
+ if (apr_shm_size_get(ap_scoreboard_shm) < scoreboard_size) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
"Fatal error: shared scoreboard too small for child!");
- apr_shm_detach(scoreboard_shm);
- scoreboard_shm = NULL;
+ apr_shm_detach(ap_scoreboard_shm);
+ ap_scoreboard_shm = NULL;
+ return APR_EINVAL;
}
/* everything will be cleared shortly */
#endif
if (sb_type == SB_SHARED) {
void *sb_shared;
rv = open_scoreboard(p);
- if (rv || !(sb_shared = apr_shm_baseaddr_get(scoreboard_shm))) {
+ if (rv || !(sb_shared = apr_shm_baseaddr_get(ap_scoreboard_shm))) {
exit(APEXIT_INIT); /* XXX need to return an error from this function */
}
memset(sb_shared, 0, scoreboard_size);
else if (sb_type == SB_SHARED_CHILD) {
void *sb_shared;
rv = reopen_scoreboard(p, 1);
- if (rv || !(sb_shared = apr_shm_baseaddr_get(scoreboard_shm))) {
+ if (rv || !(sb_shared = apr_shm_baseaddr_get(ap_scoreboard_shm))) {
exit(APEXIT_INIT); /* XXX need to return an error from this function */
}
ap_init_scoreboard(sb_shared);
if (sb_type != SB_SHARED_CHILD) {
ap_scoreboard_image->global->sb_type = sb_type;
ap_scoreboard_image->global->running_generation = running_gen;
- ap_restart_time = apr_time_now();
apr_pool_cleanup_register(p, NULL, ap_cleanup_scoreboard,
apr_pool_cleanup_null);
}
+ ap_restart_time = apr_time_now();
}
/* Routines called to deal with the scoreboard image