23-AUG-1999 I performed the follwing changes to the apache port for VMS: - Modified makefile_openvms.com to make an apache_root logical that can reside at an arbitrary directory rather than the MFD. - Modified os.c/.h to provide support routines for: o server process creation and wait-for-exit. o Scoreboard creation using a global section. o Creation of sockets with the the 'shared' attribute so multiple processes can simultaneously accept on the same listen socket. - Modified http_main.c: o Creates/maps a global section and points ap_scoreboard_image to it. o Spawn sub-processes rather than fork. o Check for '-n slotnum' argument on command line, if present program assume it is a 'child' process. o redefines waitpid to wait on our child processes. - The apache_httpd image should be run standalone rather than started by the auxillary server. (round 2) - Added function vms_close_busy_socket() to os.c and modified function ap_pclosef in file alloc.c to call this new function if the RTL close on the socket returns EBUSY. The EBUSY result occurs when attempting to close the socket from a signal handler that interrupted a read or write in progress. The connection is closed but the file descriptor is still locked. - Modified http_core.c to only add the content-length header if the source file has record format fixed or stream-lf. The stat function does not return an accurate size for formats not one of these 2 types. - Modified function vms_assign_shared_socket in file os.c to set SHARE attribute on the socket or else it takes ownership of it (denying access to the children unless they have the VMS SHARE privilege). There is probably a race condition between the time the channel is assigned and the set attribute occurs but this is a small enough window that I won't worry about it for now. (round 3) - Add fix to http_request.c so the directory walk for a script request does not fail. We check the error status of failed stat() calls and change RMS syntax errors to ENOENT (no entity). - Modify http_main.c so children waiting on an accept() can be interrupted by the USR1 signal from the caretaker. The DEC C runtime's emulation of unix signals does not abort pending accept() calls, so the accept() loop was skipping the test for defered_die. The fix is to make the usr1 signal handler issue a SYS$CANCEL on the socket's device channel and fixup the EVMSERR that results to EINTR. - Added several files to [src.os.open] to provide support for a scripting scheme that features cached processes: process_cache.c/h Functions to create 'tasks' and the mailboxes usd to communicate bewteen them. The waitpid function is subverted. apache_cached_process.com Wrapper procedure that vms_create_task() spawns to oversee a child script process. It executes a loop that waits for the next request and executes scripts. process_cache_await_task.c Helper program used by the wrapper proc. (apache_cached_process.com) to wait for the next request from the server and setup the environment variables. In the scripting scheme, function vms_create_task() is used in place of fork()/exec() and vms_wait_for_task_exit() is used in place of waitpid(). - Add new file [.src.modules.standard]mod_cgi_vms.c to provide the cgi script handler instead of mod_cgi.c. The _vms version uses the process_cache functions to execute the cgi scripts rather than apache core functions to create a child process (ap_bspawn_child). (round 4) - Fix bugs in child creation code in os.c and http_main.c (uninitialized data leading to ACCVIO when compiled /optimize=inline=speed). - Modified http_main.c to spawn the child processes using "httpd -n n" or "httpc n" depending upon whether httpc is defined as a symbol. The httpc method lets you put a command procedure around the child programm execution for debuging purposes. - Reorganize file tree for code development, [src.os.openvms]setup.com now defines the following logicals: APACHE_BASE -> disk:[dir.APACHE_1_3_6.] ! terminal, concealed This tree contains the original files as unpacked from the apache.org distribution (apache_1.3.6.tar). It also may contain dummy directories to match those in APACHE_CUR APACHE_CUR -> disk:[dir.APACHE_1_3_6-n.] ! n = 5 This tree contains just the source files that have been added or modified from the original BASE files as well as intermediary files (.obj, .map, .exe) creating during the build process. APACHE_ROOT -> disk:[dir.APACHE_1_3_6-n.],APACHE_BASE: This search list logical lets you merge both code trees with any files in APACHE_CUR taking precendence over the corresponding file in APACHE_BASE. The makefile_openvms.com procedure similarly defines APACHE_INSTALL for the build process. - Made a procedure for scanning APACHE_CUR:[*...] and populating a differences directory with diff files for pieces of the original tree that are superceded and a vmsonly.zip file for the new files added. (round 5) - Corrected typo in fix to http_core.c so filetype check for inhibiting content-length header (except when fixed or stream-LF records) works as intended. When no content-length header present, apache sends the data with 'chunked' encoding when sending to HTTP 1.1 clients. - Fixed bug in buff.c that caused hangs with HTTP 1.1 clients when sending chunked data. The original code assumed the chunk size would always be less than 4096 bytes, chunked files would exceed this limit and generate an invalid chunk. - More enhancements to script support. Errorlog mailbox is now read asynchronously so the order the mailboxes are drained is irrelevant. - Made MMS decription file to permit more efficient rebuilds. (round 6) - Replaced MAKE_MODULES.COM procedure with CONFIG_MODULES.COM, which build modules.c as directed by [src]configuration rather the haphazard aggolermation based on the .olb file contents. The Apache documentation clearly says the ordering of the modules is important, so it really must be driven by the configuration file. The new procedure also builds both the ap_prelinked_modules and ap_preloaded_modules arrays, make_modules.com was incorrectly leaving the latter array blank. An additional benefit of the new procedure is user can customize apache by editting [src]configuration. the same as on other platforms. - Backed out incorrect 'fix' to [src.main]http_config.c that was needed to work around the broken modules.c produced by make_modules.com. When ap_preloaded_modules is initialized properly the original apache code is correct. - Deleted MAKEFILE_*.COM files, builds must be done via the the DESCRIP.MMS file in [src.os.openvms]. - Moved the mod_cgi_vms.c file from [src.modules.standard] to [src.os.openvms] and changed build procedures accordingly. - Created mod_osuscript.c module in [src.os.openvms] that provides the OSU scripting environment under Apache. This module is still under development so does not work yet. (round 7) - Reworked script handling done by mod_cgi_vms.c to share a pool of script processes rather than having each child create its own. The pooled processes now invoke apache_script.com and use apache_script_control.exe to setup the environment. The process_cache.c file was replaced with process_manager.c and mailbox_set.c - Extended functionality of the mod_osuscript module, all dialog tags are now recongized, though some are noops (, , , ). - Fix bug in http_request.c that was forcing directory scans for /usr/.htaccess regardless of configuration file setting. - Change http_main to use "-w" to designate the child number rather than -n. - Minor enhancements to descrip.mms. The All category now builds htpasswd image and apache_script_control.exe. Also added shortened target names httpd, script, htpasswd. - Fix translate_userdir function in mod_userdir.c to convert the VMS-style login directory specification to unix-style since apache appends unix-style directories (e.g. /www/index.html) to it. - Modified mod_status.c to display PIDs in hexadecimal so they match the show system display. (round 8) - Modify config_modules.com so it automatically substitutes module os/mod_cgi_vms.o for modules/standard/mod_cgi.o so we don't have to give instructions on modifying the standard src/configuration file. The substistutions are defined in set of symbols declared at the top of config_modules.com. - Modify descrip.mms so the stock gen_test_char and uri_delims programs can be used without VMS-specific modification (define sys$output to target file. - Move userdir fixup into function in os.c and call from mod_rewrite.c as well as a mod_userdir.c (round 9) - Fix http_main.c so only the caretaker creates pidfile. - Fix apache_script.com to invoke the manager mode operation using the same image location as the children (rather than sys$disk:[]). - Write simple apache_kill program that reads the pid file and sends either a shutdown or restart signal to the file it finds. As a security precaution, it only sends the signal if image name is apache_httpd. - Modified descrip.mms to locate the apache_httpd, apache_kill, and apache_script_control executables in the [000000] directory and copy the apache_daemon.com and apache_script.com procedures there as well. - Wrote new command procedure for starting/stopping http process. Place this procedure, apache_daemon.com, in the directory that will equate to apache_root:[000000]. Invoke the command procedure with one of the 4 following options as P1: STARTUP Create a detached process. SHUTDOWN Send SIGTERM signal to caretaker process. RESTART Send SIGHUP signal to caretaker process. RUN Run httpd interactively. Note that after a shutdown is signalled, there may be some delay before the server actually quits. - Fixed bug in http_main.c where invalid argument was being passed to getsockname(). - Add USE_VMSDLM_ACCEPT_SERIALIZATION definition to ap_config.h and modify http_main.c to define accept mutex operations for listening on multiple IP addresses. (Without the serialzation, the select calls in TCPIP 5.0A fail). The VMSDLM serialization uses the VMS $ENQ service to create a group lock for the serialization. (round 10) - Ported to Apache 1.3.9. - Created protected shareable image, apache_privileged, to handle the binding to privileged port numbers and login directory lookup. The main apache_httpd image now now longer needs to be installed with privileges. The protected image is loaded dynamically only if a privileged operation is needed: creating sockets with port numbers less than 1024 (done only by caretaker); or call getpwnam with a username other than the current processes username. - Made wrapper functions in os.c for the bind() and getpwnam() function calls that invoke the apache_privileged shareable image. The vms_getpwnam function also converts the returned login directory to unix syntax (disk:[dir] --> /disk/dir). - Fix bugs in serialzation VMSDLM serialzation code. (round 11) - Fix bugs in the syntax conversion logic in vms_getpwnam that cause conversion to fail if login directory was more than one level deep. - Change apache_privileged to supply function vms_create_privileged_socket and modified vms_create_shared_socket to call it when listen port is below 1024. The UCX driver only checks the privilges when the socket is created, not when bound (the 'privileged' status is saved as part of the socket state). Unknowns: - restarts. - Including form data with scripts.