+1. This is something I've wanted to do for awhile, just never got around to it. BTW, please feel free to modify winnt.c. The only favor I ask is to not change the accept and thread dispatch flows w/o bouncing it off me first (unless it is someting that is obviously broken). There are a lot of things to keep in mind when changing the AcceptEx/Completion port stuff, especially with regard to shutting down the server. I forget some of them myself and I wrote the stuff :-) And I'm still not happy with shutdown (specifically restart) I am against creating seperate MPMs for 95/99 and NT/2000. One MPM should dynamically handle both. If you want to take a shot at breaking up winnt.c into seperate files (common, nt/2000, 95/98 pieces), be my guest :-) I expect to be out of the development loop for 2 weeks or so starting in a day or so. Cheers, Bill > I'm -really- hesitant to touch this, seeing as you own > it at this moment, Bill. Here's the 2.0 equivilant of > the new 1.3.x code for clean process termination. > > Feel free to test and criticize. This -does-not- solve > the Win9x hung shutdown issue, which is it's own beast. > > Index: src/modules/mpm/winnt/winnt.c > =================================================================== > RCS file: /home/cvs/apache-2.0/src/modules/mpm/winnt/winnt.c,v > retrieving revision 1.65 > diff -u -r1.65 winnt.c > --- src/modules/mpm/winnt/winnt.c 2000/05/12 00:43:43 1.65 > +++ src/modules/mpm/winnt/winnt.c 2000/05/16 20:00:45 > return 0; > } > > +static BOOL CALLBACK master_control_handler(DWORD ctrl_type) > +{ > + switch (ctrl_type) > + { > + case CTRL_C_EVENT: > + case CTRL_BREAK_EVENT: > + fprintf(stderr, "Apache server interrupted...\n"); > + /* for Interrupt signals, shut down the server. > + * Tell the system we have dealt with the signal > + * without waiting for Apache to terminate. > + */ > + ap_start_shutdown(); > + return TRUE; > + > + case CTRL_CLOSE_EVENT: > + case CTRL_LOGOFF_EVENT: > + case CTRL_SHUTDOWN_EVENT: > + /* for Terminate signals, shut down the server. > + * Wait for Apache to terminate, but respond > + * after a reasonable time to tell the system > + * that we did attempt to shut ourself down. > + * THESE EVENTS WILL NOT OCCUR UNDER WIN9x! > + */ > + fprintf(stderr, "Apache server shutdown initiated...\n"); > + ap_start_shutdown(); > + Sleep(30000); > + return TRUE; > + } > + > + /* We should never get here, but this is (mostly) harmless */ > + return FALSE; > +} > + > static int master_main(server_rec *s, HANDLE shutdown_event, HANDLE restart_event) > { > int remaining_children_to_start = ap_daemons_to_start; > @@ -1548,6 +1581,8 @@ > > HANDLE process_handles[MAX_PROCESSES]; > HANDLE process_kill_events[MAX_PROCESSES]; > + > + SetConsoleCtrlHandler(master_control_handler, TRUE); > > setup_listeners(s); > bind_listeners_to_completion_port();