Return-Path: Delivered-To: apache-cvs-archive@hyperreal.org Received: (qmail 10657 invoked by uid 6000); 6 Jun 1999 07:15:29 -0000 Received: (qmail 10641 invoked by alias); 6 Jun 1999 07:15:27 -0000 Delivered-To: apache-apr-cvs@hyperreal.org Received: (qmail 10631 invoked by uid 240); 6 Jun 1999 07:15:25 -0000 Date: 6 Jun 1999 07:15:25 -0000 Message-ID: <19990606071525.10630.qmail@hyperreal.org> From: bjh@hyperreal.org To: apache-apr-cvs@hyperreal.org Subject: cvs commit: apache-apr/apr/threadproc/os2 Makefile.in proc.c signals.c thread.c threadcancel.c threadpriv.c threadproc.h Sender: apache-cvs-owner@apache.org Precedence: bulk Reply-To: new-httpd@apache.org bjh 99/06/06 00:15:24 Added: apr/threadproc/os2 Makefile.in proc.c signals.c thread.c threadcancel.c threadpriv.c threadproc.h Log: Initial OS/2 thread/process library. Revision Changes Path 1.1 apache-apr/apr/threadproc/os2/Makefile.in Index: Makefile.in =================================================================== #CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS) #LIBS=$(EXTRA_LIBS) $(LIBS1) #INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES) #LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS) CC=@CC@ RANLIB=@RANLIB@ CFLAGS=@PLATFORM@ @CFLAGS@ @OPTIM@ LDLIBS=@LDLIBS@ LDFLAGS=@LDFLAGS@ $(LDLIBS) INCDIR=../../include INCDIR1=../../../include INCDIR2=../../file_io/os2 INCLUDES=-I$(INCDIR) -I$(INCDIR1) -I$(INCDIR2) -I. LIB=../threadproc.a OBJS=proc.o \ thread.o \ threadcancel.o \ threadpriv.o \ signals.o .c.o: $(CC) $(CFLAGS) -c $(INCLUDES) $< all: $(LIB) clean: $(RM) -f *.o *.a *.so distclean: clean -$(RM) -f Makefile $(OBJS): Makefile $(LIB): $(OBJS) $(RM) -f $@ $(AR) cr $@ $(OBJS) $(RANLIB) $@ # # We really don't expect end users to use this rule. It works only with # gcc, and rebuilds Makefile.tmpl. You have to re-run Configure after # using it. # depend: cp Makefile.in Makefile.in.bak \ && sed -ne '1,/^# DO NOT REMOVE/p' Makefile.in > Makefile.new \ && gcc -MM $(INCLUDES) $(CFLAGS) *.c >> Makefile.new \ && sed -e '1,$$s: $(INCDIR)/: $$(INCDIR)/:g' \ -e '1,$$s: $(OSDIR)/: $$(OSDIR)/:g' Makefile.new \ > Makefile.in \ && rm Makefile.new # DO NOT REMOVE proc.o: proc.c threadproc.h ../../../include/apr_thread_proc.h \ ../../../include/apr_file_io.h ../../../include/apr_general.h \ ../../../include/apr_errno.h ../../file_io/unix/fileio.h signals.o: signals.c threadproc.h ../../../include/apr_thread_proc.h \ ../../../include/apr_file_io.h ../../../include/apr_general.h \ ../../../include/apr_errno.h ../../file_io/unix/fileio.h thread.o: thread.c threadproc.h ../../../include/apr_thread_proc.h \ ../../../include/apr_file_io.h ../../../include/apr_general.h \ ../../../include/apr_errno.h threadcancel.o: threadcancel.c threadproc.h \ ../../../include/apr_thread_proc.h ../../../include/apr_file_io.h \ ../../../include/apr_general.h ../../../include/apr_errno.h threadpriv.o: threadpriv.c threadproc.h \ ../../../include/apr_thread_proc.h ../../../include/apr_file_io.h \ ../../../include/apr_general.h ../../../include/apr_errno.h 1.1 apache-apr/apr/threadproc/os2/proc.c Index: proc.c =================================================================== /* ==================================================================== * Copyright (c) 1999 The Apache Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * 4. The names "Apache Server" and "Apache Group" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * apache@apache.org. * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Group. * For more information on the Apache Group and the Apache HTTP server * project, please see . * */ #include "threadproc.h" #include "fileio.h" #include "apr_thread_proc.h" #include "apr_file_io.h" #include "apr_general.h" #include "apr_lib.h" #include #include #include #include #define INCL_DOS #include ap_status_t ap_createprocattr_init(ap_context_t *cont, struct procattr_t **new) { (*new) = (struct procattr_t *)ap_palloc(cont, sizeof(struct procattr_t)); if ((*new) == NULL) { return APR_ENOMEM; } (*new)->cntxt = cont; (*new)->parent_in = NULL; (*new)->child_in = NULL; (*new)->parent_out = NULL; (*new)->child_out = NULL; (*new)->parent_err = NULL; (*new)->child_err = NULL; (*new)->currdir = NULL; (*new)->cmdtype = APR_PROGRAM; return APR_SUCCESS; } ap_status_t ap_setprocattr_io(struct procattr_t *attr, ap_int32_t in, ap_int32_t out, ap_int32_t err) { ap_status_t stat; if (in) { if ((stat = ap_create_pipe(attr->cntxt, &attr->child_in, &attr->parent_in)) != APR_SUCCESS) { return stat; } } if (out) { if ((stat = ap_create_pipe(attr->cntxt, &attr->parent_out, &attr->child_out)) != APR_SUCCESS) { return stat; } } if (err) { if ((stat = ap_create_pipe(attr->cntxt, &attr->parent_err, &attr->child_err)) != APR_SUCCESS) { return stat; } } return APR_SUCCESS; } ap_status_t ap_setprocattr_dir(struct procattr_t *attr, char *dir) { attr->currdir = ap_pstrdup(attr->cntxt, dir); if (attr->currdir) { return APR_SUCCESS; } return APR_ENOMEM; } ap_status_t ap_setprocattr_cmdtype(struct procattr_t *attr, ap_cmdtype_e cmd) { attr->cmdtype = cmd; return APR_SUCCESS; } ap_status_t ap_fork(ap_context_t *cont, struct proc_t **proc) { int pid; (*proc) = ap_palloc(cont, sizeof(struct proc_t)); if ((pid = fork()) < 0) { return errno; } else if (pid == 0) { (*proc)->pid = pid; (*proc)->attr = NULL; return APR_INCHILD; } (*proc)->pid = pid; (*proc)->attr = NULL; return APR_INPARENT; } ap_status_t ap_create_process(ap_context_t *cont, char *progname, char *const args[], char **env, struct procattr_t *attr, struct proc_t **new) { int i; char **newargs; char savedir[300]; HFILE save_in, save_out, save_err, dup; int criticalsection = FALSE; (*new) = (struct proc_t *)ap_palloc(cont, sizeof(struct proc_t)); if ((*new) == NULL) { return APR_ENOMEM; } (*new)->cntxt = cont; /* Prevent other threads from running while these process-wide resources are modified */ if (attr->child_in || attr->child_out || attr->child_err || attr->currdir) { criticalsection = TRUE; DosEnterCritSec(); } if (attr->child_in) { save_in = -1; DosDupHandle(STDIN_FILENO, &save_in); dup = STDIN_FILENO; DosDupHandle(attr->child_in->filedes, &dup); DosSetFHState(attr->parent_in->filedes, OPEN_FLAGS_NOINHERIT); } if (attr->child_out) { save_out = -1; DosDupHandle(STDOUT_FILENO, &save_out); dup = STDOUT_FILENO; DosDupHandle(attr->child_out->filedes, &dup); DosSetFHState(attr->parent_out->filedes, OPEN_FLAGS_NOINHERIT); } if (attr->child_err) { save_err = -1; DosDupHandle(STDERR_FILENO, &save_err); dup = STDERR_FILENO; DosDupHandle(attr->child_err->filedes, &dup); DosSetFHState(attr->parent_err->filedes, OPEN_FLAGS_NOINHERIT); } signal(SIGCHLD, SIG_DFL); /*not sure if this is needed or not */ if (attr->currdir != NULL) { _getcwd2(savedir, sizeof(savedir)); if (_chdir2(attr->currdir) < 0) { if (criticalsection) DosExitCritSec(); return errno; } } if (attr->cmdtype == APR_SHELLCMD) { i = 0; while (args[i]) { i++; } newargs = (char **)ap_palloc(cont, sizeof (char *) * (i + 3)); newargs[0] = ap_pstrdup(cont, SHELL_PATH); newargs[1] = ap_pstrdup(cont, "/c"); i = 0; while (args[i]) { newargs[i + 2] = ap_pstrdup(cont, args[i]); i++; } newargs[i + 3] = NULL; (*new)->pid = spawnve(P_NOWAIT, SHELL_PATH, newargs, env); } else { (*new)->pid = spawnve(P_NOWAIT, progname, args, env); } if (attr->currdir != NULL) { chdir(savedir); } if (attr->child_in) { ap_close(attr->child_in); dup = STDIN_FILENO; DosDupHandle(save_in, &dup); DosClose(save_in); } if (attr->child_out) { ap_close(attr->child_out); dup = STDOUT_FILENO; DosDupHandle(save_out, &dup); DosClose(save_out); } if (attr->child_err) { ap_close(attr->child_err); dup = STDERR_FILENO; DosDupHandle(save_err, &dup); DosClose(save_err); } if (criticalsection) DosExitCritSec(); (*new)->attr = attr; return APR_SUCCESS; } ap_status_t ap_get_childin(struct proc_t *proc, ap_file_t **new) { (*new) = proc->attr->parent_in; return APR_SUCCESS; } ap_status_t ap_get_childout(struct proc_t *proc, ap_file_t **new) { (*new) = proc->attr->parent_out; return APR_SUCCESS; } ap_status_t ap_get_childerr(struct proc_t *proc, ap_file_t **new) { (*new) = proc->attr->parent_err; return APR_SUCCESS; } ap_status_t ap_wait_proc(struct proc_t *proc, ap_wait_how_e wait) { pid_t stat; if (!proc) return APR_ENOPROC; if (wait == APR_WAIT) { if ((stat = waitpid(proc->pid, NULL, WUNTRACED)) > 0) { return APR_CHILD_DONE; } else if (stat == 0) { return APR_CHILD_NOTDONE; } return errno; } if ((stat = waitpid(proc->pid, NULL, WUNTRACED | WNOHANG)) > 0) { return APR_CHILD_DONE; } else if (stat == 0) { return APR_CHILD_NOTDONE; } return errno; } 1.1 apache-apr/apr/threadproc/os2/signals.c Index: signals.c =================================================================== /* ==================================================================== * Copyright (c) 1999 The Apache Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * 4. The names "Apache Server" and "Apache Group" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * apache@apache.org. * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Group. * For more information on the Apache Group and the Apache HTTP server * project, please see . * */ #include "threadproc.h" #include "fileio.h" #include "apr_thread_proc.h" #include "apr_file_io.h" #include "apr_general.h" #include #include #include #define INCL_DOS #include ap_status_t ap_kill(struct proc_t *proc, int signal) { /* SIGTERM's don't work too well in OS/2 (only affects other EMX programs). CGIs may not be, esp. REXX scripts, so use a native call instead */ ap_status_t rc; if ( signal == SIGTERM ) { rc = os2errno(DosSendSignalException(proc->pid, XCPT_SIGNAL_BREAK)); } else { rc = kill(proc->pid, signal) < 0 ? errno : APR_SUCCESS; } return rc; } 1.1 apache-apr/apr/threadproc/os2/thread.c Index: thread.c =================================================================== /* ==================================================================== * Copyright (c) 1999 The Apache Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * 4. The names "Apache Server" and "Apache Group" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * apache@apache.org. * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Group. * For more information on the Apache Group and the Apache HTTP server * project, please see . * */ #include "threadproc.h" #include "apr_thread_proc.h" #include "apr_general.h" #include "apr_lib.h" #include "fileio.h" #define INCL_DOS #include ap_status_t ap_create_threadattr(ap_context_t *cont, struct threadattr_t **new) { (*new) = (struct threadattr_t *)ap_palloc(cont, sizeof(struct threadattr_t)); if ((*new) == NULL) { return APR_ENOMEM; } (*new)->cntxt = cont; (*new)->attr = 0; return APR_SUCCESS; } ap_status_t ap_setthreadattr_detach(struct threadattr_t *attr, ap_int32_t on) { attr->attr |= APR_THREADATTR_DETACHED; return APR_SUCCESS; } ap_status_t ap_getthreadattr_detach(struct threadattr_t *attr) { return (attr->attr & APR_THREADATTR_DETACHED) ? APR_DETACH : APR_NOTDETACH; } static void ap_thread_begin(void *arg) { struct thread_t *thread = (struct thread_t *)arg; thread->rv = thread->func(thread->data); } ap_status_t ap_create_thread(ap_context_t *cont, struct threadattr_t *attr, ap_thread_start_t func, void *data, struct thread_t **new) { ap_status_t stat; ap_thread_t *thread; thread = (struct thread_t *)ap_palloc(cont, sizeof(struct thread_t)); *new = thread; if (thread == NULL) { return APR_ENOMEM; } thread->cntxt = cont; thread->attr = attr; thread->func = func; thread->data = data; stat = ap_create_context(cont, NULL, &thread->cntxt); if (stat != APR_SUCCESS) { return stat; } if (attr == NULL) { stat = ap_create_threadattr(thread->cntxt, &thread->attr); if (stat != APR_SUCCESS) { return stat; } } if (thread->attr->attr & APR_THREADATTR_DETACHED) thread->tid = _beginthread((os2_thread_start_t)func, NULL, APR_THREAD_STACKSIZE, data); else thread->tid = _beginthread(ap_thread_begin, NULL, APR_THREAD_STACKSIZE, thread); if (thread->tid < 0) { return errno; } return APR_SUCCESS; } ap_status_t ap_thread_exit(ap_thread_t *thd, ap_status_t *retval) { thd->rv = retval; _endthread(); return -1; /* If we get here something's wrong */ } ap_status_t ap_thread_join(struct thread_t *thd, ap_status_t *retval) { ULONG rc; TID waittid = thd->tid; if (thd->attr->attr & APR_THREADATTR_DETACHED) return APR_ENOSTAT; rc = DosWaitThread(&waittid, DCWW_WAIT); *retval = (ap_status_t)thd->rv; return os2errno(rc); } ap_status_t ap_thread_detach(struct thread_t *thd) { thd->attr->attr |= APR_THREADATTR_DETACHED; return APR_SUCCESS; } 1.1 apache-apr/apr/threadproc/os2/threadcancel.c Index: threadcancel.c =================================================================== /* ==================================================================== * Copyright (c) 1999 The Apache Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * 4. The names "Apache Server" and "Apache Group" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * apache@apache.org. * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Group. * For more information on the Apache Group and the Apache HTTP server * project, please see . * */ #include "threadproc.h" #include "apr_thread_proc.h" #include "apr_general.h" #include "fileio.h" ap_status_t ap_cancel_thread(struct thread_t *thd) { return os2errno(DosKillThread(thd->tid)); } ap_status_t ap_setcanceltype(ap_context_t *cont, ap_int32_t type) { ULONG rc, nesting; if (type == APR_CANCEL_DEFER) rc = DosEnterMustComplete(&nesting); else rc = DosExitMustComplete(&nesting); return os2errno(rc); } ap_status_t ap_setcancelstate(ap_context_t *cont, ap_int32_t type) { /* There's no way to ignore thread kills altogether in OS/2 (that I know of) */ return -1; } 1.1 apache-apr/apr/threadproc/os2/threadpriv.c Index: threadpriv.c =================================================================== /* ==================================================================== * Copyright (c) 1999 The Apache Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * 4. The names "Apache Server" and "Apache Group" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * apache@apache.org. * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Group. * For more information on the Apache Group and the Apache HTTP server * project, please see . * */ #include "threadproc.h" #include "apr_thread_proc.h" #include "apr_general.h" #include "apr_errno.h" #include "apr_lib.h" #include "fileio.h" ap_status_t ap_create_thread_private(ap_context_t *cont, void (*dest)(void *), struct threadkey_t **key) { (*key) = (struct threadkey_t *)ap_palloc(cont, sizeof(struct threadkey_t)); if ((*key) == NULL) { return APR_ENOMEM; } (*key)->cntxt = cont; return os2errno(DosAllocThreadLocalMemory(1, &((*key)->key))); } ap_status_t ap_get_thread_private(struct threadkey_t *key, void **new) { (*new) = (void *)*(key->key); return APR_SUCCESS; } ap_status_t ap_set_thread_private(struct threadkey_t *key, void *priv) { *(key->key) = (ULONG)priv; return APR_SUCCESS; } ap_status_t ap_delete_thread_private(struct threadkey_t *key) { return os2errno(DosFreeThreadLocalMemory(key->key)); } 1.1 apache-apr/apr/threadproc/os2/threadproc.h Index: threadproc.h =================================================================== /* ==================================================================== * Copyright (c) 1999 The Apache Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * 4. The names "Apache Server" and "Apache Group" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * apache@apache.org. * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Group. * For more information on the Apache Group and the Apache HTTP server * project, please see . * */ #include "apr_thread_proc.h" #include "apr_file_io.h" #ifndef THREAD_PROC_H #define THREAD_PROC_H #define APR_THREADATTR_DETACHED 1 #define SHELL_PATH "cmd.exe" #define APR_THREAD_STACKSIZE 65536 struct threadattr_t { ap_context_t *cntxt; unsigned long attr; }; struct thread_t { ap_context_t *cntxt; struct threadattr_t *attr; unsigned long tid; ap_thread_start_t func; void *data; void *rv; }; struct threadkey_t { ap_context_t *cntxt; unsigned long *key; }; struct procattr_t { ap_context_t *cntxt; ap_file_t *parent_in; ap_file_t *child_in; ap_file_t *parent_out; ap_file_t *child_out; ap_file_t *parent_err; ap_file_t *child_err; char *currdir; ap_int32_t cmdtype; }; struct proc_t { ap_context_t *cntxt; pid_t pid; struct procattr_t *attr; }; typedef void (*os2_thread_start_t)(void *); #endif /* ! THREAD_PROC_H */