diff options
Diffstat (limited to 'threadproc')
31 files changed, 0 insertions, 4659 deletions
diff --git a/threadproc/beos/Makefile.in b/threadproc/beos/Makefile.in deleted file mode 100644 index 4aabf1b6d..000000000 --- a/threadproc/beos/Makefile.in +++ /dev/null @@ -1,73 +0,0 @@ -#CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS) -#LIBS=$(EXTRA_LIBS) $(LIBS1) -#INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES) -#LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS) - -CC=@CC@ -RANLIB=@RANLIB@ -CFLAGS=@CFLAGS@ @OPTIM@ -LIBS=@LIBS@ -LDFLAGS=@LDFLAGS@ $(LIBS) -INCDIR=../../inc -INCDIR1=../../include -INCDIR2=../../file_io/@OSDIR@ -INCLUDES=-I$(INCDIR) -I$(INCDIR1) -I$(INCDIR2) -I. - -LIB=../libthreadproc.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/beos/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/beos/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 ../../file_io/beos/fileio.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 \ - ../../file_io/beos/fileio.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 \ - ../../file_io/beos/fileio.h diff --git a/threadproc/beos/proc.c b/threadproc/beos/proc.c deleted file mode 100644 index dedf399ed..000000000 --- a/threadproc/beos/proc.c +++ /dev/null @@ -1,264 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ - - -#include <signal.h> -#include <string.h> -#include <sys/wait.h> -#include "threadproc.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include "apr_general.h" - -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 = (char *)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) = (struct proc_t *)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; - (*new) = (struct proc_t *)ap_palloc(cont, sizeof(struct proc_t)); - - if ((*new) == NULL){ - return APR_ENOMEM; - } - - (*new)->cntxt = cont; - if (((*new)->pid = fork()) < 0) { - return errno; - } - else if ((*new)->pid == 0) { - /* child process */ - if (attr->child_in) { - ap_close(attr->parent_in); - dup2(attr->child_in->filedes, STDIN_FILENO); - ap_close(attr->child_in); - } - if (attr->child_out) { - ap_close(attr->parent_out); - dup2(attr->child_out->filedes, STDOUT_FILENO); - ap_close(attr->child_out); - } - if (attr->child_err) { - ap_close(attr->parent_err); - dup2(attr->child_err->filedes, STDERR_FILENO); - ap_close(attr->child_err); - } - - signal(SIGCHLD, SIG_DFL); /*not sure if this is needed or not */ - - if (attr->currdir != NULL) { - if (chdir(attr->currdir) == -1) { - exit(-1); /* We have big problems, the child should exit. */ - } - } - if (attr->cmdtype == APR_SHELLCMD) { - i = 0; - while (args[i]) { - i++; - } - newargs = (char **)ap_palloc(cont, sizeof (char *) * (i + 3)); - newargs[0] = strdup(SHELL_PATH); - newargs[1] = strdup("-c"); - i = 0; - while (args[i]) { - newargs[i + 2] = strdup(args[i]); - i++; - } - newargs[i + 3] = NULL; - execve(SHELL_PATH, newargs, env); - } - else { - execve(progname, args, env); - } - exit(-1); /* if we get here, there is a problem, so exit with an */ - /* error code. */ - } - /* Parent process */ - if (attr->child_in) { - ap_close(attr->child_in); - } - if (attr->child_out) { - ap_close(attr->child_out); - } - if (attr->child_err) { - ap_close(attr->child_err); - } - - (*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; -} diff --git a/threadproc/beos/signals.c b/threadproc/beos/signals.c deleted file mode 100644 index 014964230..000000000 --- a/threadproc/beos/signals.c +++ /dev/null @@ -1,72 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ - -#include "threadproc.h" -#include "fileio.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include <signal.h> -#include <string.h> -#include <sys/wait.h> - -ap_status_t ap_kill(struct proc_t *proc, int signal) -{ - if (kill(proc->pid, signal) == -1){ - return errno; - } - return APR_SUCCESS; -} - diff --git a/threadproc/beos/thread.c b/threadproc/beos/thread.c deleted file mode 100644 index e086aad50..000000000 --- a/threadproc/beos/thread.c +++ /dev/null @@ -1,162 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ - -#include "threadproc.h" -#include "apr_thread_proc.h" -#include "apr_general.h" - - -ap_status_t ap_create_threadattr(ap_context_t *cont, struct threadattr_t **new) -{ - ap_status_t stat; - - (*new) = (struct threadattr_t *)ap_palloc(cont, - sizeof(struct threadattr_t)); - (*new)->attr = (int32)ap_palloc(cont, - sizeof(int32)); - - if ((*new) == NULL) { - return APR_ENOMEM; - } - - (*new)->cntxt = cont; - (*new)->attr = (int32)B_NORMAL_PRIORITY; - - return APR_SUCCESS; -} - -ap_status_t ap_setthreadattr_detach(struct threadattr_t *attr, ap_int32_t on) -{ - if (on == 1){ - attr->detached = 1; - } else { - attr->detached = 0; - } - return APR_SUCCESS; -} - -ap_status_t ap_getthreadattr_detach(struct threadattr_t *attr) -{ - if (attr->detached == 1){ - return APR_DETACH; - } - return APR_NOTDETACH; -} - -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) -{ - int32 temp; - ap_status_t stat; - - (*new) = (struct thread_t *)ap_palloc(cont, sizeof(struct thread_t)); - if ((*new) == NULL) { - return APR_ENOMEM; - } - - (*new)->td = (thread_id) ap_palloc(cont, sizeof(thread_id)); - if ((*new)->td == (thread_id)NULL) { - return APR_ENOMEM; - } - - (*new)->cntxt = cont; - - /* First we create the new thread...*/ - if (attr) - temp = attr->attr; - else - temp = B_NORMAL_PRIORITY; - - stat = ap_create_context(cont, NULL, &(*new)->cntxt); - if (stat != APR_SUCCESS) { - return stat; - } - - (*new)->td = spawn_thread((thread_func)func, "apr thread", temp, data); - /* Now we try to run it...*/ - if (resume_thread((*new)->td) == B_NO_ERROR) { - return APR_SUCCESS; - } - else { - return errno; - } -} - -ap_status_t ap_thread_exit(ap_thread_t *thd, ap_status_t *retval) -{ - ap_destroy_pool(thd->cntxt); - exit_thread ((status_t)retval); -} - -ap_status_t ap_thread_join(ap_thread_t *thd, ap_status_t *retval) -{ - if (wait_for_thread(thd->td,(void *)&retval) == B_NO_ERROR) { - return APR_SUCCESS; - } - else { - return errno; - } -} - -ap_status_t ap_thread_detach(ap_thread_t *thd) -{ - if (suspend_thread(thd->td) == B_NO_ERROR){ - return APR_SUCCESS; - } - else { - return errno; - } -} diff --git a/threadproc/beos/threadcancel.c b/threadproc/beos/threadcancel.c deleted file mode 100644 index a3a245879..000000000 --- a/threadproc/beos/threadcancel.c +++ /dev/null @@ -1,91 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ - -#include "threadproc.h" -#include "apr_thread_proc.h" -#include "apr_general.h" - - -ap_status_t ap_cancel_thread(struct thread_t *thd) -{ - if (kill_thread(thd->td) == 0) { - return APR_SUCCESS; - } - else { - return errno; - } -} - - -ap_status_t ap_setcanceltype(ap_context_t *cont, ap_int32_t type) -{ -/* if (pthread_setcanceltype(type, NULL) == 0) {*/ - return APR_SUCCESS; -/* } - else { - return APR_FAILURE; - }*/ -} - -ap_status_t ap_setcancelstate(ap_context_t *cont, ap_int32_t type) -{ -/* if (pthread_setcanceltype(type, NULL) == 0) {*/ - return APR_SUCCESS; -/* } - else { - return APR_FAILURE; - }*/ -} - diff --git a/threadproc/beos/threadpriv.c b/threadproc/beos/threadpriv.c deleted file mode 100644 index 8b3b7e1cf..000000000 --- a/threadproc/beos/threadpriv.c +++ /dev/null @@ -1,189 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ - -#include "threadproc.h" -#include "apr_thread_proc.h" -#include "apr_general.h" -#include "apr_errno.h" - -static struct beos_key key_table[BEOS_MAX_DATAKEYS]; -static struct beos_private_data *beos_data[BEOS_MAX_DATAKEYS]; -static sem_id lock; - -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; - - acquire_sem(lock); - for ((*key)->key=0; (*key)->key < BEOS_MAX_DATAKEYS; (*key)->key++){ - if (key_table[(*key)->key].assigned == 0){ - key_table[(*key)->key].assigned = 1; - key_table[(*key)->key].destructor = dest; - release_sem(lock); - return APR_SUCCESS; - } - - } - release_sem(lock); - return APR_ENOMEM; -} - -ap_status_t ap_get_thread_private(struct threadkey_t *key, void **new) -{ - thread_id tid; - int i, index=0; - tid = find_thread(NULL); - for (i=0;i<BEOS_MAX_DATAKEYS;i++){ - if (beos_data[i]->data){ - /* it's been used */ - if (beos_data[i]->td == tid){ - index = i; - } - } - } - if (index == 0){ - /* no storage for thread so we can't get anything... */ - return APR_ENOMEM; - } - - if ((key->key < BEOS_MAX_DATAKEYS) && (key_table)){ - acquire_sem(key_table[key->key].lock); - if (key_table[key->key].count){ - (*new) = (void*)beos_data[index]->data[key->key]; - } else { - (*new) = NULL; - } - release_sem(key_table[key->key].lock); - } else { - (*new) = NULL; - } - return APR_SUCCESS; -} - -ap_status_t ap_set_thread_private(struct threadkey_t *key, void *priv) -{ - thread_id tid; - int i,index = 0, ret; - - tid = find_thread(NULL); - for (i=0; i < BEOS_MAX_DATAKEYS; i++){ - if (beos_data[i]->data){ - if (beos_data[i]->td = tid){index = i;} - } - } - if (index==0){ - /* not yet been allocated */ - for (i=0; i< BEOS_MAX_DATAKEYS; i++){ - if (! beos_data[i]->data){ - /* we'll take this one... */ - index = i; - beos_data[i]->data = (const void **)malloc(sizeof(void *) * BEOS_MAX_DATAKEYS); - memset((void *)beos_data[i]->data, 0, sizeof(void *) * BEOS_MAX_DATAKEYS); - beos_data[i]->count = (int)malloc(sizeof(int)); - beos_data[i]->td = (thread_id)malloc(sizeof(thread_id)); - beos_data[i]->td = tid; - } - } - } - if (index == 0){ - /* we're out of luck.. */ - return APR_ENOMEM; - } - if ((key->key < BEOS_MAX_DATAKEYS) && (key_table)){ - acquire_sem(key_table[key->key].lock); - if (key_table[key->key].count){ - if (beos_data[index]->data[key->key] == NULL){ - if (priv != NULL){ - beos_data[index]->count++; - key_table[key->key].count++; - } - } else { - if (priv == NULL){ - beos_data[index]->count--; - key_table[key->key].count--; - } - } - beos_data[index]->data[key->key] = priv; - ret = 1; - } else { - ret = 0; - } - release_sem(key_table[key->key].lock); - } - if (ret) - return APR_SUCCESS; - return APR_ENOMEM; -} - -ap_status_t ap_delete_thread_private(struct threadkey_t *key) -{ - if (key->key < BEOS_MAX_DATAKEYS){ - acquire_sem(key_table[key->key].lock); - if (key_table[key->key].count == 1){ - key_table[key->key].destructor = NULL; - key_table[key->key].count = 0; - } - release_sem(key_table[key->key].lock); - } else { - return APR_ENOMEM; - } - return APR_SUCCESS; -} diff --git a/threadproc/beos/threadproc.h b/threadproc/beos/threadproc.h deleted file mode 100644 index 64e87052f..000000000 --- a/threadproc/beos/threadproc.h +++ /dev/null @@ -1,124 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ - -#include "apr_thread_proc.h" -#include "fileio.h" -#include "apr_file_io.h" -#include <kernel/OS.h> - -#ifndef THREAD_PROC_H -#define THREAD_PROC_H - -#define SHELL_PATH "/bin/sh" - -#define PTHREAD_CANCEL_AYNCHRONOUS CANCEL_ASYNCH; -#define PTHREAD_CANCEL_DEFERRED CANCEL_DEFER; - -#define PTHREAD_CANCEL_ENABLE CANCEL_ENABLE; -#define PTHREAD_CANCEL_DISABLE CANCEL_DISABLE; - -#define BEOS_MAX_DATAKEYS 128 - -struct thread_t { - ap_context_t *cntxt; - thread_id td; -}; - -struct threadattr_t { - ap_context_t *cntxt; - int32 attr; - int detached; - int joinable; -}; - -struct threadkey_t { - ap_context_t *cntxt; - int32 key; -}; - -struct beos_private_data { - const void ** data; - int count; - volatile thread_id td; -}; - -struct beos_key { - int assigned; - int count; - sem_id lock; - int32 ben_lock; - void (* destructor) (); -}; - -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; -}; - -#endif /* ! THREAD_PROC_H */ - diff --git a/threadproc/os2/Makefile.in b/threadproc/os2/Makefile.in deleted file mode 100644 index 91d4249c2..000000000 --- a/threadproc/os2/Makefile.in +++ /dev/null @@ -1,71 +0,0 @@ -#CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS) -#LIBS=$(EXTRA_LIBS) $(LIBS1) -#INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES) -#LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS) - -CC=@CC@ -RANLIB=@RANLIB@ -CFLAGS=@CFLAGS@ @OPTIM@ -LIBS=@LIBS@ -LDFLAGS=@LDFLAGS@ $(LIBS) -INCDIR=../../inc -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 diff --git a/threadproc/os2/proc.c b/threadproc/os2/proc.c deleted file mode 100644 index 5767d898c..000000000 --- a/threadproc/os2/proc.c +++ /dev/null @@ -1,321 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ - -#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 <signal.h> -#include <string.h> -#include <sys/wait.h> -#include <unistd.h> -#define INCL_DOS -#include <os2.h> - -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; - (*proc)->running = TRUE; - return APR_INCHILD; - } - - (*proc)->pid = pid; - (*proc)->attr = NULL; - (*proc)->running = TRUE; - 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; - ap_status_t stat; - 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; - (*new)->running = FALSE; - -/* 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); - } - - stat = (*new)->pid < 0 ? errno : APR_SUCCESS; - - 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; - (*new)->running = stat == APR_SUCCESS; - return stat; -} - - - -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 (!proc->running) - return APR_CHILD_DONE; - - if (wait == APR_WAIT) { - if ((stat = waitpid(proc->pid, NULL, WUNTRACED)) > 0) { - proc->running = FALSE; - return APR_CHILD_DONE; - } else if (stat == 0) { - return APR_CHILD_NOTDONE; - } - return errno; - } - - if ((stat = waitpid(proc->pid, NULL, WUNTRACED | WNOHANG)) > 0) { - proc->running = FALSE; - return APR_CHILD_DONE; - } else if (stat == 0) { - return APR_CHILD_NOTDONE; - } - - return errno; -} - diff --git a/threadproc/os2/signals.c b/threadproc/os2/signals.c deleted file mode 100644 index d0014f695..000000000 --- a/threadproc/os2/signals.c +++ /dev/null @@ -1,82 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ - -#include "threadproc.h" -#include "fileio.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include <signal.h> -#include <string.h> -#include <sys/wait.h> -#define INCL_DOS -#include <os2.h> - -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; -} - diff --git a/threadproc/os2/thread.c b/threadproc/os2/thread.c deleted file mode 100644 index 14cf980c5..000000000 --- a/threadproc/os2/thread.c +++ /dev/null @@ -1,178 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ - -#include "threadproc.h" -#include "apr_thread_proc.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "fileio.h" -#define INCL_DOS -#include <os2.h> - -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; -} - - diff --git a/threadproc/os2/threadcancel.c b/threadproc/os2/threadcancel.c deleted file mode 100644 index 5f4766bc5..000000000 --- a/threadproc/os2/threadcancel.c +++ /dev/null @@ -1,86 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ - -#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; -} diff --git a/threadproc/os2/threadpriv.c b/threadproc/os2/threadpriv.c deleted file mode 100644 index 049f93896..000000000 --- a/threadproc/os2/threadpriv.c +++ /dev/null @@ -1,92 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ - -#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)); -} - diff --git a/threadproc/os2/threadproc.h b/threadproc/os2/threadproc.h deleted file mode 100644 index 215a7f9fd..000000000 --- a/threadproc/os2/threadproc.h +++ /dev/null @@ -1,108 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ - -#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; - int running; -}; - -typedef void (*os2_thread_start_t)(void *); - -#endif /* ! THREAD_PROC_H */ - diff --git a/threadproc/unix/.cvsignore b/threadproc/unix/.cvsignore deleted file mode 100644 index f3c7a7c5d..000000000 --- a/threadproc/unix/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Makefile diff --git a/threadproc/unix/Makefile.in b/threadproc/unix/Makefile.in deleted file mode 100644 index 51640cde1..000000000 --- a/threadproc/unix/Makefile.in +++ /dev/null @@ -1,90 +0,0 @@ -#CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS) -#LIBS=$(EXTRA_LIBS) $(LIBS1) -#INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES) -#LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS) - -RM=@RM@ -CC=@CC@ -RANLIB=@RANLIB@ -CFLAGS=@CFLAGS@ @OPTIM@ -LIBS=@LIBS@ -LDFLAGS=@LDFLAGS@ $(LIBS) -INCDIR=../../inc -INCDIR1=../../include -INCDIR2=../../file_io/unix -INCLUDES=-I$(INCDIR) -I$(INCDIR1) -I$(INCDIR2) -I. - -LIB=../libthreadproc.a - -OBJS=proc.o \ - procsup.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_config.h ../../include/apr_errno.h \ - ../../include/apr_win.h ../../file_io/unix/fileio.h \ - ../../include/apr_lib.h ../../include/hsregex.h \ - ../../include/apr_portable.h ../../include/apr_network_io.h \ - ../../include/apr_lock.h ../../include/apr_time.h -procsup.o: procsup.c threadproc.h ../../include/apr_thread_proc.h \ - ../../include/apr_file_io.h ../../include/apr_general.h \ - ../../include/apr_config.h ../../include/apr_errno.h \ - ../../include/apr_win.h ../../file_io/unix/fileio.h \ - ../../include/apr_lib.h ../../include/hsregex.h -signals.o: signals.c threadproc.h ../../include/apr_thread_proc.h \ - ../../include/apr_file_io.h ../../include/apr_general.h \ - ../../include/apr_config.h ../../include/apr_errno.h \ - ../../include/apr_win.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_config.h ../../include/apr_errno.h \ - ../../include/apr_win.h ../../include/apr_portable.h \ - ../../include/apr_network_io.h ../../include/apr_lock.h \ - ../../include/apr_time.h -threadcancel.o: threadcancel.c threadproc.h \ - ../../include/apr_thread_proc.h ../../include/apr_file_io.h \ - ../../include/apr_general.h ../../include/apr_config.h \ - ../../include/apr_errno.h ../../include/apr_win.h -threadpriv.o: threadpriv.c threadproc.h \ - ../../include/apr_thread_proc.h ../../include/apr_file_io.h \ - ../../include/apr_general.h ../../include/apr_config.h \ - ../../include/apr_errno.h ../../include/apr_win.h \ - ../../include/apr_portable.h ../../include/apr_network_io.h \ - ../../include/apr_lock.h ../../include/apr_time.h diff --git a/threadproc/unix/proc.c b/threadproc/unix/proc.c deleted file mode 100644 index 3022350e5..000000000 --- a/threadproc/unix/proc.c +++ /dev/null @@ -1,410 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ - -#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 "apr_portable.h" -#include <signal.h> -#include <string.h> -#include <sys/wait.h> -#include <unistd.h> - -/* ***APRDOC******************************************************** - * ap_status_t ap_createprocattr_init(ap_context_t *, ap_procattr_t **) - * Create and initialize a new procattr variable - * arg 1) The context to use - * arg 2) The newly created procattr. - */ -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; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_setprocattr_io(ap_procattr_t *, ap_int32_t, ap_int32_t - * ap_int32_t) - * Determine if any of stdin, stdout, or stderr should be linked - * to pipes when starting a child process. - * arg 1) The procattr we care about. - * arg 2) Should stdin be a pipe bnack to the parent? - * arg 3) Should stdout be a pipe bnack to the parent? - * arg 4) Should stderr be a pipe bnack to the parent? - */ -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; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_setprocattr_dir(ap_procattr_t *, char *) - * Set which directory the child process should start executing in. - * arg 1) The procattr we care about. - * arg 2) Which dir to start in. By default, this is the same dir as - * the parent currently resides in, when the createprocess call - * is made. - */ -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; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_setprocattr_cmdtype(ap_procattr_t *, ap_cmdtype_e) - * Set what type of command the child process will call. - * arg 1) The procattr we care about. - * arg 2) The type of command. One of: - * APR_SHELLCMD -- Shell script - * APR_PROGRAM -- Executable program (default) - */ -ap_status_t ap_setprocattr_cmdtype(struct procattr_t *attr, - ap_cmdtype_e cmd) -{ - attr->cmdtype = cmd; - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_setprocattr_detach(ap_procattr_t *, ap_int32_t) - * Determine if the chlid should start in detached state. - * arg 1) The procattr we care about. - * arg 2) Should the child start in detached state? Default is no. - */ -ap_status_t ap_setprocattr_detach(struct procattr_t *attr, ap_int32_t detach) -{ - attr->detached = detach; - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_fork_detach(ap_context_t *, ap_proc_t **) - * This is currently the only non-portable call in APR. This executes - * a standard unix fork. - * arg 1) The context to use. - * arg 2) The resulting process handle. - */ -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; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_create_process(ap_context_t *, char *, char *const [], - char **, ap_procattr_t *, ap_proc_t **) - * Create a new process and execute a new program within that process. - * arg 1) The context to use. - * arg 2) The program to run - * arg 3) the arguments to pass to the new program. The first one should - * be the program name. - * arg 4) The new environment table for the new process. This should be a - * list of NULL-terminated strings. - * arg 5) the procattr we should use to determine how to create the new - * process - * arg 6) The resulting process handle. - */ -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; - struct proc_t *pgrp; - - (*new) = (struct proc_t *)ap_palloc(cont, sizeof(struct proc_t)); - - if ((*new) == NULL) { - return APR_ENOMEM; - } - - (*new)->cntxt = cont; - - if (((*new)->pid = fork()) < 0) { - return errno; - } - else if ((*new)->pid == 0) { - /* child process */ - if (attr->child_in) { - ap_close(attr->parent_in); - dup2(attr->child_in->filedes, STDIN_FILENO); - ap_close(attr->child_in); - } - if (attr->child_out) { - ap_close(attr->parent_out); - dup2(attr->child_out->filedes, STDOUT_FILENO); - ap_close(attr->child_out); - } - if (attr->child_err) { - ap_close(attr->parent_err); - dup2(attr->child_err->filedes, STDERR_FILENO); - ap_close(attr->child_err); - } - - signal(SIGCHLD, SIG_DFL); /*not sure if this is needed or not */ - - if (attr->currdir != NULL) { - if (chdir(attr->currdir) == -1) { - exit(-1); /* We have big problems, the child should exit. */ - } - } - if (attr->cmdtype == APR_SHELLCMD) { - i = 0; - while (args[i]) { - i++; - } - newargs = (char **)ap_palloc(cont, sizeof (char *) * (i + 3)); - newargs[0] = strdup(SHELL_PATH); - newargs[1] = strdup("-c"); - i = 0; - while (args[i]) { - newargs[i + 2] = strdup(args[i]); - i++; - } - newargs[i + 3] = NULL; - if (attr->detached) { - ap_detach(attr->cntxt, &pgrp); - } - execve(SHELL_PATH, newargs, env); - } - else { - if (attr->detached) { - ap_detach(attr->cntxt, &pgrp); - } - execve(progname, args, env); - } - exit(-1); /* if we get here, there is a problem, so exit with an */ - /* error code. */ - } - /* Parent process */ - if (attr->child_in) { - ap_close(attr->child_in); - } - if (attr->child_out) { - ap_close(attr->child_out); - } - if (attr->child_err) { - ap_close(attr->child_err); - } - - (*new)->attr = attr; - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_childin(ap_proc_t *, ap_file_t **) - * Get the file handle that is assocaited with a child's stdin. - * arg 1) The process handle that corresponds to the desired child process - * arg 2) The returned file handle. - */ -ap_status_t ap_get_childin(struct proc_t *proc, ap_file_t **new) -{ - (*new) = proc->attr->parent_in; - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_childout(ap_proc_t *, ap_file_t **) - * Get the file handle that is assocaited with a child's stdout. - * arg 1) The process handle that corresponds to the desired child process - * arg 2) The returned file handle. - */ -ap_status_t ap_get_childout(struct proc_t *proc, ap_file_t **new) -{ - (*new) = proc->attr->parent_out; - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_childerr(ap_proc_t *, ap_file_t **) - * Get the file handle that is assocaited with a child's stderr. - * arg 1) The process handle that corresponds to the desired child process - * arg 2) The returned file handle. - */ -ap_status_t ap_get_childerr(struct proc_t *proc, ap_file_t **new) -{ - (*new) = proc->attr->parent_err; - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_wait_proc(ap_proc_t *, ap_wait_how) - * Wait for a child process to die - * arg 1) The process handle that corresponds to the desired child process - * arg 2) How should we wait. One of: - * APR_WAIT -- block until the child process dies. - * APR_NOWAIT -- return immediately regardless of if the - * child is dead or not. - * NOTE: The childs status is in the return code to this process. It is - * one of: - * APR_CHILD_DONE -- child is no longer running. - * APR_CHILD_NOTDONE -- child is still running. - */ -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; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_os_proc(ap_proc_t *, ap_os_proc_t *) - * convert the proc from os specific type to apr type. - * arg 1) The apr proc to converting - * arg 2) The os specific proc we are converting to - */ -ap_status_t ap_get_os_proc(ap_proc_t *proc, ap_os_proc_t *theproc) -{ - if (proc == NULL) { - return APR_ENOPROC; - } - theproc = &(proc->pid); - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_put_os_proc(ap_context_t *, ap_proc_t *, ap_os_proc_t *) - * convert the proc from os specific type to apr type. - * arg 1) The context to use if it is needed. - * arg 2) The apr proc we are converting to. - * arg 3) The os specific proc to convert - */ -ap_status_t ap_put_os_proc(ap_context_t *cont, struct proc_t **proc, - ap_os_proc_t *theproc) -{ - if (cont == NULL) { - return APR_ENOCONT; - } - if ((*proc) == NULL) { - (*proc) = (struct proc_t *)ap_palloc(cont, sizeof(struct proc_t)); - (*proc)->cntxt = cont; - } - (*proc)->pid = *theproc; - return APR_SUCCESS; -} - diff --git a/threadproc/unix/procsup.c b/threadproc/unix/procsup.c deleted file mode 100644 index ddf6020e7..000000000 --- a/threadproc/unix/procsup.c +++ /dev/null @@ -1,166 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ - -#include "threadproc.h" -#include "fileio.h" - -#include "apr_config.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include "apr_lib.h" - -/* ***APRDOC******************************************************** - * ap_status_t ap_detach(ap_context_t *, ap_proc_t *) - * Detach the process from the controlling terminal. - * arg 1) The context to use if it is needed. - * arg 2) The new process handler - */ -ap_status_t ap_detach(ap_context_t *cont, struct proc_t **new) -{ - int x; - - (*new) = (struct proc_t *)ap_palloc(cont, sizeof(struct proc_t)); - (*new)->cntxt = cont; - (*new)->attr = NULL; - - chdir("/"); -#if !defined(MPE) && !defined(OS2) && !defined(TPF) -/* Don't detach for MPE because child processes can't survive the death of - the parent. */ - if ((x = fork()) > 0) - exit(0); - else if (x == -1) { - perror("fork"); - fprintf(stderr, "unable to fork new process\n"); - exit(1); /* we can't do anything here, so just exit. */ - } -/* RAISE_SIGSTOP(DETACH);*/ -#endif -#if HAVE_SETSID - if (((*new)->pid = setsid()) == -1) { - return errno; - } -#elif defined(NEXT) || defined(NEWSOS) - if (setpgrp(0, getpid()) == -1 || ((*new)->pid = getpgrp(0)) == -1) { - return errno; - } -#elif defined(OS2) || defined(TPF) - /* OS/2 don't support process group IDs */ - (*new)->pid = getpid(); -#elif defined(MPE) - /* MPE uses negative pid for process group */ - (*new)->pid = -getpid(); -#else - if (((*new)->pid = setpgrp(getpid(), 0)) == -1) { - return errno; - } -#endif - - /* close out the standard file descriptors */ - if (freopen("/dev/null", "r", stdin) == NULL) { - return APR_ALLSTD; - /* continue anyhow -- note we can't close out descriptor 0 because we - * have nothing to replace it with, and if we didn't have a descriptor - * 0 the next file would be created with that value ... leading to - * havoc. - */ - } - if (freopen("/dev/null", "w", stdout) == NULL) { - return APR_STDOUT; - } - /* We are going to reopen this again in a little while to the error - * log file, but better to do it twice and suffer a small performance - * hit for consistancy than not reopen it here. - */ - if (freopen("/dev/null", "w", stderr) == NULL) { - return APR_STDERR; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_procdata(ap_proc_t *, void *) - * Return the context associated with the current proc. - * arg 1) The currently open proc. - * arg 2) The user data associated with the proc. - */ -ap_status_t ap_get_procdata(struct proc_t *proc, void *data) -{ - if (proc != NULL) { - return ap_get_userdata(proc->cntxt, &data); - } - else { - data = NULL; - return APR_ENOPROC; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_set_procdata(ap_proc_t *, void *) - * Return the context associated with the current proc. - * arg 1) The currently open proc. - * arg 2) The user data to associate with the proc. -*/ -ap_status_t ap_set_procdata(struct proc_t *proc, void *data) -{ - if (proc != NULL) { - return ap_set_userdata(proc->cntxt, data); - } - else { - data = NULL; - return APR_ENOPROC; - } -} - diff --git a/threadproc/unix/signals.c b/threadproc/unix/signals.c deleted file mode 100644 index 529dcad8d..000000000 --- a/threadproc/unix/signals.c +++ /dev/null @@ -1,72 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ - -#include "threadproc.h" -#include "fileio.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include <signal.h> -#include <string.h> -#include <sys/wait.h> - -ap_status_t ap_kill(struct proc_t *proc, int signal) -{ - if (kill(proc->pid, signal) == -1) { - return errno; - } - return APR_SUCCESS; -} - diff --git a/threadproc/unix/thread.c b/threadproc/unix/thread.c deleted file mode 100644 index d79359a0b..000000000 --- a/threadproc/unix/thread.c +++ /dev/null @@ -1,364 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ - -#include "threadproc.h" -#include "apr_thread_proc.h" -#include "apr_general.h" -#include "apr_portable.h" - -#ifdef HAVE_PTHREAD_H -/* ***APRDOC******************************************************** - * ap_status_t ap_create_threadattr(ap_context_t *, ap_threadattr_t **) - * Create and initialize a new threadattr variable - * arg 1) The context to use - * arg 2) The newly created threadattr. - */ -ap_status_t ap_create_threadattr(ap_context_t *cont, struct threadattr_t **new) -{ - ap_status_t stat; - - (*new) = (struct threadattr_t *)ap_palloc(cont, - sizeof(struct threadattr_t)); - (*new)->attr = (pthread_attr_t *)ap_palloc(cont, - sizeof(pthread_attr_t)); - - if ((*new) == NULL || (*new)->attr == NULL) { - return APR_ENOMEM; - } - - (*new)->cntxt = cont; - stat = pthread_attr_init((*new)->attr); - - if (stat == 0) { - return APR_SUCCESS; - } - return stat; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_setthreadattr_detach(ap_threadattr_t *, ap_int32_t) - * Set if newly created threads should be created in detach mode. - * arg 1) The threadattr to affect - * arg 2) Thread detach state on or off - */ -ap_status_t ap_setthreadattr_detach(struct threadattr_t *attr, ap_int32_t on) -{ - ap_status_t stat; - if ((stat = pthread_attr_setdetachstate(attr->attr, on)) == 0) { - return APR_SUCCESS; - } - else { - return stat; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_getthreadattr_detach(ap_threadattr_t *, ap_int32_t *) - * Get the detach mode for this threadattr. - * arg 1) The threadattr to reference - * arg 2) Thread detach state on or off - */ -ap_status_t ap_getthreadattr_detach(struct threadattr_t *attr) -{ - int state; - - pthread_attr_getdetachstate(attr->attr, &state); - if (state == 1) - return APR_DETACH; - return APR_NOTDETACH; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_create_thread(ap_context_t *, ap_threadattr_t *, - * ap_thread_start_t, coid *, ap_thread_t **) - * Create a new thread of execution - * arg 1) The context to use - * arg 2) The threadattr to use to determine how to create the thread - * arg 3) The function to start the new thread in - * arg 4) Any data to be passed to the starting function - * arg 5) The newly created thread handle. - */ -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; - pthread_attr_t *temp; - - (*new) = (struct thread_t *)ap_palloc(cont, sizeof(struct thread_t)); - - if ((*new) == NULL) { - return APR_ENOMEM; - } - - (*new)->td = (pthread_t *)ap_palloc(cont, sizeof(pthread_t)); - - if ((*new)->td == NULL) { - return APR_ENOMEM; - } - - (*new)->cntxt = cont; - - if (attr) - temp = attr->attr; - else - temp = NULL; - - stat = ap_create_context(cont, NULL, &(*new)->cntxt); - if (stat != APR_SUCCESS) { - return stat; - } - - if ((stat = pthread_create((*new)->td, temp, func, data)) == 0) { - return APR_SUCCESS; - } - else { - return stat; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_thread_exit(ap_thread_t *, ap_status_t *) - * stop the current thread - * arg 1) The thread to stop - * arg 2) The return value to pass back to any thread that cares - */ -ap_status_t ap_thread_exit(ap_thread_t *thd, ap_status_t *retval) -{ - ap_destroy_pool(thd->cntxt); - pthread_exit(retval); -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_thread_join(ap_thread_t *, ap_status_t *) - * block until the desired thread stops executing. - * arg 1) The thread to join - * arg 2) The return value from the dead thread. - */ -ap_status_t ap_thread_join(struct thread_t *thd, ap_status_t *retval) -{ - ap_status_t stat; - - if ((stat = pthread_join(*thd->td,(void *)&retval)) == 0) { - return APR_SUCCESS; - } - else { - return stat; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_thread_detach(ap_thread_t *) - * detach a thread - * arg 1) The thread to detach - */ -ap_status_t ap_thread_detach(struct thread_t *thd) -{ - ap_status_t stat; - - if ((stat = pthread_detach(*thd->td)) == 0) { - return APR_SUCCESS; - } - else { - return stat; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_threaddata(ap_thread_t *, void *) - * Return the context associated with the current thread. - * arg 1) The currently open thread. - * arg 2) The user data associated with the thread. - */ -ap_status_t ap_get_threaddata(struct thread_t *thread, void *data) -{ - if (thread != NULL) { - return ap_get_userdata(thread->cntxt, &data); - } - else { - data = NULL; - return APR_ENOTHREAD; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_set_threaddata(ap_thread_t *, void *) - * Return the context associated with the current thread. - * arg 1) The currently open thread. - * arg 2) The user data to associate with the thread. - */ -ap_status_t ap_set_threaddata(struct thread_t *thread, void *data) -{ - if (thread != NULL) { - return ap_set_userdata(thread->cntxt, data); - } - else { - data = NULL; - return APR_ENOTHREAD; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_os_thread(ap_thread_t *, ap_os_thread_t *) - * convert the thread to os specific type from apr type. - * arg 1) The apr thread to convert - * arg 2) The os specific thread we are converting to - */ -ap_status_t ap_get_os_thread(struct thread_t *thd, ap_os_thread_t *thethd) -{ - if (thd == NULL) { - return APR_ENOTHREAD; - } - thethd = thd->td; - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_put_os_thread(ap_context_t *, ap_thread_t *, ap_os_thread_t *) - * convert the thread from os specific type to apr type. - * arg 1) The context to use if it is needed. - * arg 2) The apr thread we are converting to. - * arg 3) The os specific thread to convert - */ -ap_status_t ap_put_os_thread(ap_context_t *cont, struct thread_t **thd, - ap_os_thread_t *thethd) -{ - if (cont == NULL) { - return APR_ENOCONT; - } - if ((*thd) == NULL) { - (*thd) = (struct thread_t *)ap_palloc(cont, sizeof(struct thread_t)); - (*thd)->cntxt = cont; - } - (*thd)->td = thethd; - return APR_SUCCESS; -} -#else - /* No pthread.h, no threads for right now.*/ -ap_status_t ap_create_threadattr(ap_context_t *cont, struct threadattr_t **new) -{ - *new = NULL; - return APR_SUCCESS; -} - -ap_status_t ap_setthreadattr_detach(struct threadattr_t *attr, ap_int32_t on) -{ - return APR_SUCCESS; -} - -ap_status_t ap_getthreadattr_detach(struct threadattr_t *attr) -{ - return APR_NOTDETACH; -} - -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) -{ - *new = NULL; - return stat; -} - -ap_status_t ap_thread_exit(ap_thread_t *thd, ap_status_t *retval) -{ - APR_SUCCESS; -} - -ap_status_t ap_thread_join(struct thread_t *thd, ap_status_t *retval) -{ - return APR_SUCCESS; -} - -ap_status_t ap_thread_detach(struct thread_t *thd) -{ - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_threaddata(ap_thread_t *, void *) - * Return the context associated with the current thread. - * arg 1) The currently open thread. - * arg 2) The user data associated with the thread. - */ -ap_status_t ap_get_threaddata(struct thread_t *thread, void *data) -{ - data = NULL; - return APR_ENOTHREAD; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_set_threaddata(ap_thread_t *, void *) - * Return the context associated with the current thread. - * arg 1) The currently open thread. - * arg 2) The user data to associate with the thread. - */ -ap_status_t ap_set_threaddata(struct thread_t *thread, void *data) -{ - return APR_ENOTHREAD; -} - -ap_status_t ap_get_os_thread(struct thread_t *thd, ap_os_thread_t *thethd) -{ - thethd = NULL; - return APR_SUCCESS; -} - -ap_status_t ap_put_os_thread(ap_context_t *cont, struct thread_t **thd, - ap_os_thread_t *thethd) -{ - return APR_SUCCESS; -} -#endif - diff --git a/threadproc/unix/threadcancel.c b/threadproc/unix/threadcancel.c deleted file mode 100644 index b6b5104fb..000000000 --- a/threadproc/unix/threadcancel.c +++ /dev/null @@ -1,128 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ - -#include "threadproc.h" -#include "apr_thread_proc.h" -#include "apr_general.h" - -#ifdef HAVE_PTHREAD_H -/* ***APRDOC******************************************************** - * ap_status_t ap_cancel_thread(ap_thread_t *) - * Asynchronously kill a thread - * arg 1) The thread to kill. - */ -ap_status_t ap_cancel_thread(struct thread_t *thd) -{ - ap_status_t stat; - if ((stat = pthread_cancel(*thd->td)) == 0) { - return APR_SUCCESS; - } - else { - return stat; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_setcanceltype(ap_context_t *, ap_int32_t) - * Determine how threads are cancelable. - * arg 1) The context to operate on - * arg 2) how are threads cancelable. One of: - * APR_CANCEL_ASYNCH -- cancel it no matter where it is - * APR_CANCEL_DEFER -- only cancel the thread if it is safe. - */ -ap_status_t ap_setcanceltype(ap_context_t *cont, ap_int32_t type) -{ - ap_status_t stat; - if ((stat = pthread_setcanceltype(type, NULL)) == 0) { - return APR_SUCCESS; - } - else { - return stat; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_setcancelstate(ap_context_t *, ap_int32_t) - * Determine if threads will be cancelable. - * arg 1) The context to operate on - * arg 2) Are threads cancelable. - */ -ap_status_t ap_setcancelstate(ap_context_t *cont, ap_int32_t type) -{ - ap_status_t stat; - if ((stat = pthread_setcanceltype(type, NULL)) == 0) { - return APR_SUCCESS; - } - else { - return stat; - } -} -#else -ap_status_t ap_cancel_thread(struct thread_t *thd) -{ - return APR_SUCCESS; -} - -ap_status_t ap_setcanceltype(ap_context_t *cont, ap_int32_t type) -{ - return APR_SUCCESS; -} - -ap_status_t ap_setcancelstate(ap_context_t *cont, ap_int32_t type) -{ - return APR_SUCCESS; -} -#endif - diff --git a/threadproc/unix/threadpriv.c b/threadproc/unix/threadpriv.c deleted file mode 100644 index eaa4a348d..000000000 --- a/threadproc/unix/threadpriv.c +++ /dev/null @@ -1,260 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ - -#include "threadproc.h" -#include "apr_thread_proc.h" -#include "apr_general.h" -#include "apr_errno.h" -#include "apr_portable.h" - -#ifdef HAVE_PTHREAD_H -/* ***APRDOC******************************************************** - * ap_status_t ap_create_thread_private(ap_context_t *, void *(void *), - * ap_key_t) - * Create and initialize a new thread private address space - * arg 1) The context to use - * arg 2) The destructor to use when freeing the private memory. - * arg 3) The thread private handle. - */ -ap_status_t ap_create_thread_private(ap_context_t *cont, void (*dest)(void *), - struct threadkey_t **key) -{ - ap_status_t stat; - (*key) = (struct threadkey_t *)ap_palloc(cont, sizeof(struct threadkey_t)); - - if ((*key) == NULL) { - return APR_ENOMEM; - } - - (*key)->cntxt = cont; - - if ((stat = pthread_key_create(&(*key)->key, dest)) == 0) { - return stat; - } - return stat; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_thread_private(ap_key_t *, void **) - * Get a pointer to the thread private memory - * arg 1) The handle for the desired thread private memory - * arg 2) The data stored in private memory - */ -ap_status_t ap_get_thread_private(struct threadkey_t *key, void **new) -{ - (*new) = pthread_getspecific(key->key); - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_set_thread_private(ap_key_t *, void *) - * Set the data to be stored in thread private memory - * arg 1) The handle for the desired thread private memory - * arg 2) The data to be stored in private memory - */ -ap_status_t ap_set_thread_private(struct threadkey_t *key, void *priv) -{ - ap_status_t stat; - if ((stat = pthread_setspecific(key->key, priv)) == 0) { - return APR_SUCCESS; - } - else { - return stat; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_delete_thread_private(ap_key_t *) - * Free the thread private memory - * arg 1) The handle for the desired thread private memory - */ -ap_status_t ap_delete_thread_private(struct threadkey_t *key) -{ - ap_status_t stat; - if ((stat = pthread_key_delete(key->key)) == 0) { - return APR_SUCCESS; - } - return stat; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_threadkeydata(ap_threadkey_t *, void *) - * Return the context associated with the current threadkey. - * arg 1) The currently open threadkey. - * arg 2) The user data associated with the threadkey. - */ -ap_status_t ap_get_threadkeydata(struct threadkey_t *threadkey, void *data) -{ - if (threadkey != NULL) { - return ap_get_userdata(threadkey->cntxt, &data); - } - else { - data = NULL; - return APR_ENOTHDKEY; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_set_threadkeydata(ap_threadkey_t *, void *) - * Return the context associated with the current threadkey. - * arg 1) The currently open threadkey. - * arg 2) The user data to associate with the threadkey. - */ -ap_status_t ap_set_threadkeydata(struct threadkey_t *threadkey, void *data) -{ - if (threadkey != NULL) { - return ap_set_userdata(threadkey->cntxt, data); - } - else { - data = NULL; - return APR_ENOTHDKEY; - } -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_os_threadkey(ap_key_t *, ap_os_threadkey_t *) - * convert the thread private memory key to os specific type - * from an apr type. - * arg 1) The apr handle we are converting from. - * arg 2) The os specific handle we are converting to. - */ -ap_status_t ap_get_os_threadkey(struct threadkey_t *key, ap_os_threadkey_t *thekey) -{ - if (key == NULL) { - return APR_ENOFILE; - } - thekey = &(key->key); - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_put_os_threadkey(ap_context_t *, ap_key_t *, - * ap_os_threadkey_t *) - * convert the thread private memory key from os specific type to apr type. - * arg 1) The context to use if it is needed. - * arg 2) The apr handle we are converting to. - * arg 3) The os specific handle to convert - */ -ap_status_t ap_put_os_threadkey(ap_context_t *cont, struct threadkey_t **key, - ap_os_threadkey_t *thekey) -{ - if (cont == NULL) { - return APR_ENOCONT; - } - if ((*key) == NULL) { - (*key) = (struct threadkey_t *)ap_palloc(cont, sizeof(struct threadkey_t)); - (*key)->cntxt = cont; - } - (*key)->key = *thekey; - return APR_SUCCESS; -} -#else -ap_status_t ap_create_thread_private(ap_context_t *cont, void (*dest)(void *), - struct threadkey_t **key) -{ - *key = NULL; - return APR_SUCCESS; -} - -ap_status_t ap_get_thread_private(struct threadkey_t *key, void **new) -{ - (*new) = NULL; - return APR_SUCCESS; -} - -ap_status_t ap_set_thread_private(struct threadkey_t *key, void *priv) -{ - return APR_SUCCESS; -} - -ap_status_t ap_delete_thread_private(struct threadkey_t *key) -{ - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_threadkeydata(ap_threadkey_t *, void *) - * Return the context associated with the current threadkey. - * arg 1) The currently open threadkey. - * arg 2) The user data associated with the threadkey. - */ -ap_status_t ap_get_threadkeydata(struct threadkey_t *threadkey, void *data) -{ - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_set_threadkeydata(ap_threadkey_t *, void *) - * Return the context associated with the current threadkey. - * arg 1) The currently open threadkey. - * arg 2) The user data to associate with the threadkey. - */ -ap_status_t ap_set_threadkeydata(struct threadkey_t *threadkey, void *data) -{ - return APR_SUCCESS; -} - -ap_status_t ap_get_os_threadkey(struct threadkey_t *key, ap_os_threadkey_t *thekey) -{ - thekey = NULL; - return APR_SUCCESS; -} - -ap_status_t ap_put_os_threadkey(ap_context_t *cont, struct threadkey_t **key, - ap_os_threadkey_t *thekey) -{ - return APR_SUCCESS; -} -#endif diff --git a/threadproc/unix/threadproc.h b/threadproc/unix/threadproc.h deleted file mode 100644 index fc9755011..000000000 --- a/threadproc/unix/threadproc.h +++ /dev/null @@ -1,105 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ - -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include <pthread.h> - -#ifndef THREAD_PROC_H -#define THREAD_PROC_H - -#define SHELL_PATH "/bin/sh" - -struct thread_t { - ap_context_t *cntxt; - pthread_t *td; -}; - -struct threadattr_t { - ap_context_t *cntxt; - pthread_attr_t *attr; -}; - -struct threadkey_t { - ap_context_t *cntxt; - pthread_key_t 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; - ap_int32_t detached; -}; - -struct proc_t { - ap_context_t *cntxt; - pid_t pid; - struct procattr_t *attr; -}; - -/*This will move to apr_threadproc.h in time, but I need to figure it out - * on windows first. :) - */ -ap_status_t ap_detach(ap_context_t *, struct proc_t **); - -#endif /* ! THREAD_PROC_H */ - diff --git a/threadproc/win32/proc.c b/threadproc/win32/proc.c deleted file mode 100644 index 50c454a35..000000000 --- a/threadproc/win32/proc.c +++ /dev/null @@ -1,384 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ - -#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 "apr_portable.h" -#include <stdlib.h> -#include <signal.h> -#include <string.h> -#include <process.h> - -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; - (*new)->detached = TRUE; - - memset(&(*new)->si, 0, sizeof((*new)->si)); - - 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_setprocattr_detach(struct procattr_t *attr, - ap_int32_t det) -{ - attr->detached = det; - return APR_SUCCESS; -} - -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, iEnvBlockLen; - char *cmdline; - HANDLE hCurrentProcess; - HANDLE hParentindup, hParentoutdup,hParenterrdup; - char ppid[20]; - char *envstr; - char *pEnvBlock, *pNext; - - - - (*new) = (struct proc_t *)ap_palloc(cont, sizeof(struct proc_t)); - - if ((*new) == NULL) { - return APR_ENOMEM; - } - - (*new)->cntxt = cont; - (*new)->attr = attr; - - attr->si.cb = sizeof(attr->si); - if (attr->detached) { - /* If we are creating ourselves detached, Then we should hide the - * window we are starting in. And we had better redfine our - * handles for STDIN, STDOUT, and STDERR. - */ - attr->si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; - attr->si.wShowWindow = SW_HIDE; - - if (attr->child_in) { - attr->si.hStdInput = attr->child_in->filehand; - } - - if (attr->child_out) { - attr->si.hStdOutput = attr->child_out->filehand; - } - - if (attr->child_err) { - attr->si.hStdError = attr->child_err->filehand; - } - } - - cmdline = args[0]; - i = 1; - while (args[i]) { - cmdline = ap_pstrcat(cont, cmdline, " ", args[i], NULL); - i++; - } - /* - * When the pipe handles are created, the security descriptor - * indicates that the handle can be inherited. However, we do not - * want the server side handles to the pipe to be inherited by the - * child CGI process. If the child CGI does inherit the server - * side handles, then the child may be left around if the server - * closes its handles (e.g. if the http connection is aborted), - * because the child will have a valid copy of handles to both - * sides of the pipes, and no I/O error will occur. Microsoft - * recommends using DuplicateHandle to turn off the inherit bit - * under NT and Win95. - */ - hCurrentProcess = GetCurrentProcess(); - if ((attr->child_in && !DuplicateHandle(hCurrentProcess, attr->parent_in->filehand, - hCurrentProcess, - &hParentindup, 0, FALSE, - DUPLICATE_SAME_ACCESS)) - || (attr->child_out && !DuplicateHandle(hCurrentProcess, attr->parent_out->filehand, - hCurrentProcess, &hParentoutdup, - 0, FALSE, DUPLICATE_SAME_ACCESS)) - || (attr->child_err && !DuplicateHandle(hCurrentProcess, attr->parent_err->filehand, - hCurrentProcess, &hParenterrdup, - 0, FALSE, DUPLICATE_SAME_ACCESS))) { - if (attr->child_in) { - ap_close(attr->child_in); - ap_close(attr->parent_in); - } - if (attr->child_out) { - ap_close(attr->child_out); - ap_close(attr->parent_out); - } - if (attr->child_err) { - ap_close(attr->child_err); - ap_close(attr->parent_err); - } - return APR_EEXIST; - } - else { - if (attr->child_in) { - ap_close(attr->parent_in); - attr->parent_in->filehand = hParentindup; - } - if (attr->child_out) { - ap_close(attr->parent_out); - attr->parent_out->filehand = hParentoutdup; - } - if (attr->child_err) { - ap_close(attr->parent_err); - attr->parent_err->filehand = hParenterrdup; - } - } - - _itoa(_getpid(), ppid, 10); - if (env) { - - envstr = ap_pstrcat(cont, "parentpid=", ppid, NULL); - /* - * Win32's CreateProcess call requires that the environment - * be passed in an environment block, a null terminated block of - * null terminated strings. - */ - i = 0; - iEnvBlockLen = 1; - while (env[i]) { - iEnvBlockLen += strlen(env[i]) + 1; - i++; - } - - pEnvBlock = (char *)ap_pcalloc(cont, iEnvBlockLen + strlen(envstr)); - - i = 0; - pNext = pEnvBlock; - while (env[i]) { - strcpy(pNext, env[i]); - pNext = pNext + strlen(pNext) + 1; - i++; - } - strcpy(pNext, envstr); - } - else { - SetEnvironmentVariable("parentpid", ppid); - pEnvBlock = NULL; - } - - - if (CreateProcess(NULL, cmdline, NULL, NULL, TRUE, 0, pEnvBlock, attr->currdir, - &attr->si, &(*new)->pi)) { - if (attr->detached) { - CloseHandle((*new)->pi.hProcess); - } - if (attr->child_in) { - ap_close(attr->child_in); - } - if (attr->child_out) { - ap_close(attr->child_out); - } - if (attr->child_err) { - ap_close(attr->child_err); - } - CloseHandle((*new)->pi.hThread); - return APR_SUCCESS; - } - - return GetLastError(); -} - -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 = WaitForSingleObject(proc->pi.hProcess, INFINITE)) == WAIT_OBJECT_0) { - return APR_CHILD_DONE; - } - else if (stat == WAIT_TIMEOUT) { - return APR_CHILD_NOTDONE; - } - return APR_EEXIST; - } - if ((stat = WaitForSingleObject(proc->pi.hProcess, 0)) == WAIT_OBJECT_0) { - return APR_CHILD_DONE; - } - else if (stat == WAIT_TIMEOUT) { - return APR_CHILD_NOTDONE; - } - return APR_EEXIST; -} - -ap_status_t ap_get_procdata(struct proc_t *proc, void *data) -{ - if (proc != NULL) { - return ap_get_userdata(proc->cntxt, &data); - } - else { - data = NULL; - return APR_ENOPROC; - } -} - -ap_status_t ap_set_procdata(struct proc_t *proc, void *data) -{ - if (proc != NULL) { - return ap_set_userdata(proc->cntxt, data); - } - else { - data = NULL; - return APR_ENOPROC; - } -} - -ap_status_t ap_get_os_proc(ap_proc_t *proc, ap_os_proc_t *theproc) -{ - if (proc == NULL) { - return APR_ENOPROC; - } - theproc = &(proc->pi); - return APR_SUCCESS; -} - -ap_status_t ap_put_os_proc(ap_context_t *cont, struct proc_t **proc, - ap_os_proc_t *theproc) -{ - if (cont == NULL) { - return APR_ENOCONT; - } - if ((*proc) == NULL) { - (*proc) = (struct proc_t *)ap_palloc(cont, sizeof(struct proc_t)); - (*proc)->cntxt = cont; - } - (*proc)->pi = *theproc; - return APR_SUCCESS; -} diff --git a/threadproc/win32/signals.c b/threadproc/win32/signals.c deleted file mode 100644 index 9aefad4d6..000000000 --- a/threadproc/win32/signals.c +++ /dev/null @@ -1,75 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ - -#include "threadproc.h" -#include "fileio.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include "apr_general.h" -#include <signal.h> -#include <string.h> -#ifdef HAVE_SYS_WAIT -#include <sys/wait.h> -#endif - -/* Windows only really support killing process, but that will do for now. */ -ap_status_t ap_kill(struct proc_t *proc, int signal) -{ - if (TerminateProcess(proc->pi.hProcess, signal) == 0) { - return errno; - } - return APR_SUCCESS; -} - diff --git a/threadproc/win32/thread.c b/threadproc/win32/thread.c deleted file mode 100644 index 79fc083cb..000000000 --- a/threadproc/win32/thread.c +++ /dev/null @@ -1,203 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ -#include "apr_win.h" -#include "threadproc.h" -#include "apr_thread_proc.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_portable.h" -#include <process.h> - - -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; - return APR_SUCCESS; -} - -ap_status_t ap_setthreadattr_detach(struct threadattr_t *attr, ap_int32_t on) -{ - attr->detach = on; - return APR_SUCCESS; -} - -ap_status_t ap_getthreadattr_detach(struct threadattr_t *attr) -{ - if (attr->detach == 1) - return APR_DETACH; - return APR_NOTDETACH; -} - -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; - unsigned temp; - int lasterror; - - (*new) = (struct thread_t *)ap_palloc(cont, sizeof(struct thread_t)); - - if ((*new) == NULL) { - return APR_ENOMEM; - } - - (*new)->cntxt = cont; - - stat = ap_create_context(cont, NULL, &(*new)->cntxt); - if (stat != APR_SUCCESS) { - return stat; - } - - /* Use 0 for Thread Stack Size, because that will default the stack to the - * same size as the calling thread. - */ - if (((*new)->td = (HANDLE *)_beginthreadex(NULL, 0, (unsigned int (API_THREAD_FUNC *)(void *))func, - data, 0, &temp)) == 0) { - lasterror = GetLastError(); - return APR_EEXIST; - } - - if (attr && attr->detach) { - CloseHandle((*new)->td); - } - - return APR_SUCCESS; -} - -ap_status_t ap_thread_exit(ap_thread_t *thd, ap_status_t *retval) -{ - ap_destroy_pool(thd->cntxt); - _endthreadex(*retval); - return APR_SUCCESS; -} - -ap_status_t ap_thread_join(struct thread_t *thd, ap_status_t *retval) -{ - ap_status_t stat; - - if ((stat = WaitForSingleObject(thd->td, INFINITE)) == WAIT_OBJECT_0) { - if (GetExitCodeThread(thd->td, retval) == 0) { - return APR_SUCCESS; - } - return APR_EEXIST; - } - else { - return stat; - } -} - -ap_status_t ap_thread_detach(struct thread_t *thd) -{ - if (CloseHandle(thd->td)) { - return APR_SUCCESS; - } - else { - return APR_EEXIST; - } -} - -ap_status_t ap_get_threaddata(struct thread_t *thread, void *data) -{ - if (thread != NULL) { - return ap_get_userdata(thread->cntxt, &data); - } - else { - data = NULL; - return APR_ENOTHREAD; - } -} - -ap_status_t ap_set_threaddata(struct thread_t *thread, void *data) -{ - if (thread != NULL) { - return ap_set_userdata(thread->cntxt, data); - } - else { - data = NULL; - return APR_ENOTHREAD; - } -} - -ap_status_t ap_get_os_thread(struct thread_t *thd, ap_os_thread_t *thethd) -{ - if (thd == NULL) { - return APR_ENOTHREAD; - } - thethd = thd->td; - return APR_SUCCESS; -} - -ap_status_t ap_put_os_thread(ap_context_t *cont, struct thread_t **thd, - ap_os_thread_t *thethd) -{ - if (cont == NULL) { - return APR_ENOCONT; - } - if ((*thd) == NULL) { - (*thd) = (struct thread_t *)ap_palloc(cont, sizeof(struct thread_t)); - (*thd)->cntxt = cont; - } - (*thd)->td = thethd; - return APR_SUCCESS; -} - diff --git a/threadproc/win32/threadcancel.c b/threadproc/win32/threadcancel.c deleted file mode 100644 index a1e4d8ea1..000000000 --- a/threadproc/win32/threadcancel.c +++ /dev/null @@ -1,87 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ - -#include "threadproc.h" -#include "apr_thread_proc.h" -#include "apr_general.h" - - -ap_status_t ap_cancel_thread(struct thread_t *thd) -{ - if (TerminateThread(thd->td, APR_SUCCESS) == 0) { - return APR_EEXIST; - } - else { - return APR_SUCCESS; - } -} - -/* Not sure of the best way to do this just yet. -ap_status_t ap_setcanceltype(ap_context_t *cont, ap_int32_t type) -{ - -} - -ap_status_t ap_setcancelstate(ap_context_t *cont, ap_int32_t type) -{ - ap_status_t stat; - if ((stat = pthread_setcanceltype(type, NULL)) == 0) { - return APR_SUCCESS; - } - else { - return stat; - } -} -*/ diff --git a/threadproc/win32/threadpriv.c b/threadproc/win32/threadpriv.c deleted file mode 100644 index a6b7813d4..000000000 --- a/threadproc/win32/threadpriv.c +++ /dev/null @@ -1,138 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ - -#include "threadproc.h" -#include "apr_thread_proc.h" -#include "apr_general.h" -#include "apr_lib.h" -#include "apr_errno.h" -#include "apr_portable.h" - -ap_status_t ap_create_thread_private(ap_context_t *cont, void (*dest)(void *), - struct threadkey_t **key) -{ - (*key)->key = TlsAlloc(); - return APR_SUCCESS; -} - -ap_status_t ap_get_thread_private(struct threadkey_t *key, void **new) -{ - if ((*new) = TlsGetValue(key->key)) { - return APR_SUCCESS; - } - return APR_EEXIST; -} - -ap_status_t ap_set_thread_private(struct threadkey_t *key, void *priv) -{ - if (TlsSetValue(key->key, priv)) { - return APR_SUCCESS; - } - return APR_EEXIST; -} - -ap_status_t ap_delete_thread_private(struct threadkey_t *key) -{ - if (TlsFree(key->key)) { - return APR_SUCCESS; - } - return APR_EEXIST; -} - -ap_status_t ap_get_threadkeydata(struct threadkey_t *threadkey, void *data) -{ - if (threadkey != NULL) { - return ap_get_userdata(threadkey->cntxt, &data); - } - else { - data = NULL; - return APR_ENOTHDKEY; - } -} - -ap_status_t ap_set_threadkeydata(struct threadkey_t *threadkey, void *data) -{ - if (threadkey != NULL) { - return ap_set_userdata(threadkey->cntxt, data); - } - else { - data = NULL; - return APR_ENOTHDKEY; - } -} - -ap_status_t ap_get_os_threadkey(struct threadkey_t *key, ap_os_threadkey_t *thekey) -{ - if (key == NULL) { - return APR_ENOFILE; - } - thekey = &(key->key); - return APR_SUCCESS; -} - -ap_status_t ap_put_os_threadkey(ap_context_t *cont, struct threadkey_t **key, - ap_os_threadkey_t *thekey) -{ - if (cont == NULL) { - return APR_ENOCONT; - } - if ((*key) == NULL) { - (*key) = (struct threadkey_t *)ap_palloc(cont, sizeof(struct threadkey_t)); - (*key)->cntxt = cont; - } - (*key)->key = *thekey; - return APR_SUCCESS; -} - diff --git a/threadproc/win32/threadproc.def b/threadproc/win32/threadproc.def deleted file mode 100644 index 5a6e12bb9..000000000 --- a/threadproc/win32/threadproc.def +++ /dev/null @@ -1,39 +0,0 @@ -; threadproc.def : - -LIBRARY threadproc -DESCRIPTION '' - -EXPORTS - ; Add new API calls to the end of this list. - ap_createprocattr_init @1 - ap_setprocattr_io @2 - ap_setprocattr_dir @3 - ap_setprocattr_cmdtype @4 - ap_setprocattr_detach @5 - ap_create_process @6 - ap_get_childin @7 - ap_get_childout @8 - ap_get_childerr @9 - ap_wait_proc @10 - ap_kill @11 - ap_create_threadattr @12 - ap_setthreadattr_detach @13 - ap_getthreadattr_detach @14 - ap_create_thread @15 - ap_thread_exit @16 - ap_thread_join @17 - ap_thread_detach @18 - ap_cancel_thread @19 - ap_create_thread_private @20 - ap_get_thread_private @21 - ap_set_thread_private @22 - ap_delete_thread_private @23 - ap_get_threaddata @24 - ap_set_threaddata @25 - ap_get_threadkeydata @26 - ap_set_threadkeydata @27 - ap_get_procdata @28 - ap_set_procdata @29 - ap_get_os_proc @30 - ap_get_os_thread @31 - ap_get_os_threadkey @32 diff --git a/threadproc/win32/threadproc.dsp b/threadproc/win32/threadproc.dsp deleted file mode 100644 index b4340b31c..000000000 --- a/threadproc/win32/threadproc.dsp +++ /dev/null @@ -1,119 +0,0 @@ -# Microsoft Developer Studio Project File - Name="threadproc" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 5.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=threadproc - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "threadproc.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "threadproc.mak" CFG="threadproc - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "threadproc - Win32 Release" (based on\ - "Win32 (x86) Dynamic-Link Library") -!MESSAGE "threadproc - Win32 Debug" (based on\ - "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "threadproc - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\include ..\..\inc" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 - -!ELSEIF "$(CFG)" == "threadproc - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /I "..\..\file_io\win32" /I "..\..\include" /I "..\..\inc" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "NEED_TLS_SPEC" /YX /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\..\file_io\win32\Debug\file_io.lib ..\..\lib\Debug\lib.lib ..\..\misc\win32\Debug\misc.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "threadproc - Win32 Release" -# Name "threadproc - Win32 Debug" -# Begin Source File - -SOURCE=.\proc.c -# End Source File -# Begin Source File - -SOURCE=.\signals.c -# End Source File -# Begin Source File - -SOURCE=.\thread.c -# End Source File -# Begin Source File - -SOURCE=.\threadcancel.c -# End Source File -# Begin Source File - -SOURCE=.\threadpriv.c -# End Source File -# Begin Source File - -SOURCE=.\threadproc.def -# End Source File -# Begin Source File - -SOURCE=.\threadproc.h -# End Source File -# End Target -# End Project diff --git a/threadproc/win32/threadproc.h b/threadproc/win32/threadproc.h deleted file mode 100644 index 72d71af1d..000000000 --- a/threadproc/win32/threadproc.h +++ /dev/null @@ -1,105 +0,0 @@ -/* ==================================================================== - * 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 <http://www.apache.org/>. - * - */ -#include "apr_win.h" -#include "apr_thread_proc.h" -#include "apr_file_io.h" -#include <windows.h> - -#ifndef THREAD_PROC_H -#define THREAD_PROC_H - -#define SHELL_PATH "/bin/sh" - -struct thread_t { - ap_context_t *cntxt; - HANDLE td; - ap_int32_t cancel; - ap_int32_t cancel_how; -}; - -struct threadattr_t { - ap_context_t *cntxt; - ap_int32_t detach; - -}; - -struct threadkey_t { - ap_context_t *cntxt; - DWORD key; - -}; - -struct procattr_t { - ap_context_t *cntxt; - STARTUPINFO si; - 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; - ap_int32_t detached; -}; - -struct proc_t { - ap_context_t *cntxt; - PROCESS_INFORMATION pi; - struct procattr_t *attr; -}; - -#endif /* ! THREAD_PROC_H */ - |