rbb 99/01/27 08:15:49
Modified: pthreads/src/include multithread.h pthreads/src/modules/standard mod_include.c mod_mime_magic.c pthreads/src/os/unix multithread.c Log: Initial changes for thread-safety. Revision Changes Path 1.2 +1 -1 apache-apr/pthreads/src/include/multithread.h Index: multithread.h =================================================================== RCS file: /home/cvs/apache-apr/pthreads/src/include/multithread.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- multithread.h 1999/01/21 23:08:32 1.1 +++ multithread.h 1999/01/27 16:15:46 1.2 @@ -55,7 +55,7 @@ API_EXPORT(int) ap_acquire_mutex(mutex *mutex_id); API_EXPORT(int) ap_release_mutex(mutex *mutex_id); API_EXPORT(void) ap_destroy_mutex(mutex *mutex_id); - +API_EXPORT(int) ap_spawnvp(const char *, char *const []); #endif /* ndef MULTITHREAD */ #ifdef __cplusplus 1.2 +15 -10 apache-apr/pthreads/src/modules/standard/mod_include.c Index: mod_include.c =================================================================== RCS file: /home/cvs/apache-apr/pthreads/src/modules/standard/mod_include.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- mod_include.c 1999/01/21 23:08:38 1.1 +++ mod_include.c 1999/01/27 16:15:47 1.2 @@ -614,9 +614,10 @@ } ap_destroy_sub_req(rr); -#ifndef WIN32 + /* changing directory should be handled by CreateProcess. + #ifndef WIN32 ap_chdir_file(r->filename); -#endif + #endif */ return 0; } @@ -708,9 +709,10 @@ if (!error_fmt && ap_run_sub_req(rr)) { error_fmt = "unable to include \"%s\" in parsed file %s"; } -#ifndef WIN32 + /* changing directory should be handled by CreateProcess. + #ifndef WIN32 ap_chdir_file(r->filename); -#endif + #endif*/ if (error_fmt) { ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r, error_fmt, tag_val, r->filename); @@ -855,9 +857,10 @@ ap_rputs(error, r); } /* just in case some stooge changed directories */ -#ifndef WIN32 + /* changing directory should be handled by CreateProcess. + #ifndef WIN32 ap_chdir_file(r->filename); -#endif + #endif*/ } else if (!strcmp(tag, "cgi")) { parse_string(r, tag_val, parsed_string, sizeof(parsed_string), 0); @@ -867,9 +870,10 @@ ap_rputs(error, r); } /* grumble groan */ -#ifndef WIN32 + /* changing directory should be handled by CreateProcess. + #ifndef WIN32 ap_chdir_file(r->filename); -#endif + #endif*/ } else if (!strcmp(tag, "done")) { return 0; @@ -2114,9 +2118,10 @@ printing = conditional_status = 1; if_nesting = 0; -#ifndef WIN32 + /* changing directory should be handled by CreateProcess. + #ifndef WIN32 ap_chdir_file(r->filename); -#endif + #endif*/ if (r->args) { /* add QUERY stuff to env cause it ain't yet */ char *arg_copy = ap_pstrdup(r->pool, r->args); 1.2 +6 -8 apache-apr/pthreads/src/modules/standard/mod_mime_magic.c Index: mod_mime_magic.c =================================================================== RCS file: /home/cvs/apache-apr/pthreads/src/modules/standard/mod_mime_magic.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- mod_mime_magic.c 1999/01/21 23:08:38 1.1 +++ mod_mime_magic.c 1999/01/27 16:15:47 1.2 @@ -1,4 +1,4 @@ -/* ==================================================================== +2/* ==================================================================== * Copyright (c) 1995-1998 The Apache Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -2139,9 +2139,7 @@ static int uncompress_child(void *data, child_info *pinfo) { struct uncompress_parms *parm = data; -#if defined(WIN32) int child_pid; -#endif if (compr[parm->method].silent) { close(STDERR_FILENO); @@ -2150,14 +2148,14 @@ #if defined(WIN32) child_pid = spawnvp(compr[parm->method].argv[0], compr[parm->method].argv); - return (child_pid); #else - execvp(compr[parm->method].argv[0], compr[parm->method].argv); - ap_log_rerror(APLOG_MARK, APLOG_ERR, parm->r, + child_pid = ap_spawnvp(compr[parm->method].argv[0], compr[parm->method].argv); +#endif + if (child_pid == -1) + ap_log_rerror(APLOG_MARK, APLOG_ERR, parm->r, MODNAME ": could not execute `%s'.", compr[parm->method].argv[0]); - return -1; -#endif + return (child_pid); } 1.2 +15 -1 apache-apr/pthreads/src/os/unix/multithread.c Index: multithread.c =================================================================== RCS file: /home/cvs/apache-apr/pthreads/src/os/unix/multithread.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- multithread.c 1999/01/21 23:08:40 1.1 +++ multithread.c 1999/01/27 16:15:49 1.2 @@ -1,8 +1,8 @@ #include "ap_config.h" +/*#include "http_log.h"*/ #include "multithread.h" #include <pthread.h> - API_EXPORT(mutex *) ap_create_mutex(char * name) { int rv; @@ -29,3 +29,17 @@ { pthread_mutex_destroy((pthread_mutex_t *) mutex_id); } + +API_EXPORT(int) ap_spawnvp(const char *file, char *const argv[]) +{ + int pid; + + if ((pid = fork()) == -1) { + return pid; + } else if (pid == 0) { + execvp(file, argv); + return -1; + } else + return pid; +} +