Return-Path: Delivered-To: apache-cvs-archive@hyperreal.org Received: (qmail 15541 invoked by uid 6000); 17 May 1999 18:46:55 -0000 Received: (qmail 15531 invoked by alias); 17 May 1999 18:46:50 -0000 Delivered-To: apache-apr-cvs@hyperreal.org Received: (qmail 15527 invoked by uid 236); 17 May 1999 18:46:49 -0000 Date: 17 May 1999 18:46:49 -0000 Message-ID: <19990517184649.15526.qmail@hyperreal.org> From: rbb@hyperreal.org To: apache-apr-cvs@hyperreal.org Subject: cvs commit: apache-apr/apr/threadproc/beos proc.c signals.c thread.c threadcancel.c threadpriv.c threadproc.h Sender: apache-cvs-owner@apache.org Precedence: bulk Reply-To: new-httpd@apache.org rbb 99/05/17 11:46:48 Added: apr/threadproc/beos proc.c signals.c thread.c threadcancel.c threadpriv.c threadproc.h Log: Initial implementation of BeOS thread/process functions Submitted by: David Reid Revision Changes Path 1.1 apache-apr/apr/threadproc/beos/proc.c Index: proc.c =================================================================== /* ==================================================================== * Copyright (c) 1999 The Apache Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * 4. The names "Apache Server" and "Apache Group" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * apache@apache.org. * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Group. * For more information on the Apache Group and the Apache HTTP server * project, please see . * */ #include #include #include #include "threadproc.h" #include "apr_thread_proc.h" #include "apr_file_io.h" #include "apr_general.h" ap_procattr_t *ap_createprocattr_init(ap_context_t *cont) { ap_procattr_t *new = (ap_procattr_t *)ap_palloc(cont->pool, sizeof(ap_procattr_t)); 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 new; } ap_status_t ap_setprocattr_io(ap_context_t *cont, struct procattr_t *attr, ap_int32_t in, ap_int32_t out, ap_int32_t err) { if (in) { attr->parent_in = (ap_file_t *)ap_palloc(cont->pool, sizeof(ap_file_t)); attr->child_in = (ap_file_t *)ap_palloc(cont->pool, sizeof(ap_file_t)); if (ap_create_pipe(cont, attr->child_in, attr->parent_in) == APR_FAILURE) { return APR_FAILURE; } } if (out) { attr->parent_out = (ap_file_t *)ap_palloc(cont->pool, sizeof(ap_file_t)); attr->child_out = (ap_file_t *)ap_palloc(cont->pool, sizeof(ap_file_t)); if (ap_create_pipe(cont, attr->parent_out, attr->child_out) == APR_FAILURE) { return APR_FAILURE; } } if (err) { attr->parent_err = (ap_file_t *)ap_palloc(cont->pool, sizeof(ap_file_t)); attr->child_err = (ap_file_t *)ap_palloc(cont->pool, sizeof(ap_file_t)); if (ap_create_pipe(cont, attr->parent_err, attr->child_err) == APR_FAILURE) { return APR_FAILURE; } } } ap_status_t ap_setprocattr_dir(ap_context_t *cont, struct procattr_t *attr, char *dir) { attr->currdir = strdup(dir); } ap_status_t ap_setprocattr_cmdtype(ap_context_t *cont, struct procattr_t *attr, ap_cmdtype_e cmd) { attr->cmdtype = cmd; } ap_int32_t ap_fork(ap_context_t *cont, struct proc_t *proc) { int pid; if ((pid = fork()) < 0) { return -1; } else if (pid == 0) { proc->pid = pid; proc->attr = NULL; return pid; } proc->pid = pid; proc->attr = NULL; return 1; } ap_proc_t *ap_create_process(ap_context_t *cont, char *progname, char *const args[], char **env, struct procattr_t *attr) { struct proc_t *new = (struct proc_t *)ap_palloc(cont->pool, sizeof(struct proc_t)); int i; char **newargs; if ((new->pid = fork()) < 0) { return NULL; } else if (new->pid == 0) { /* child process */ if (attr->child_in) { ap_close(cont, attr->parent_in); dup2(attr->child_in->filedes, STDIN_FILENO); ap_close(cont, attr->child_in); } if (attr->child_out) { ap_close(cont, attr->parent_out); dup2(attr->child_out->filedes, STDOUT_FILENO); ap_close(cont, attr->child_out); } if (attr->child_err) { ap_close(cont, attr->parent_err); dup2(attr->child_err->filedes, STDERR_FILENO); ap_close(cont, attr->child_err); } signal(SIGCHLD, SIG_DFL); /*not sure if this is needed or not */ if (attr->currdir != NULL) { if (chdir(attr->currdir) == -1) { free(new); exit(-1); /* We have big problems, the child should exit. */ } } if (attr->cmdtype == APR_SHELLCMD) { i = 0; while (args[i]) { i++; } newargs = (char **)malloc(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(cont, attr->child_in); } if (attr->child_out) { ap_close(cont, attr->child_out); } if (attr->child_err) { ap_close(cont, attr->child_err); } new->attr = attr; return new; } ap_file_t *ap_get_childin(ap_context_t *cont, struct proc_t *proc) { return proc->attr->parent_in; } ap_file_t *ap_get_childout(ap_context_t *cont, struct proc_t *proc) { return proc->attr->parent_out; } ap_file_t *ap_get_childerr(ap_context_t *cont, struct proc_t *proc) { return proc->attr->parent_err; } ap_status_t ap_wait_proc(ap_context_t *cont, struct proc_t *proc, ap_wait_how_e wait) { if (!proc) return APR_FAILURE; if (wait == APR_WAIT) { if (waitpid(proc->pid, NULL, WUNTRACED) > 0) return APR_SUCCESS; return APR_FAILURE; } if (waitpid(proc->pid, NULL, WUNTRACED | WNOHANG) > 0) return APR_SUCCESS; return APR_FAILURE; } void ap_exit_proc(ap_context_t *cont) { ap_destroy_pool(cont->pool); } 1.1 apache-apr/apr/threadproc/beos/signals.c Index: signals.c =================================================================== /* ==================================================================== * Copyright (c) 1999 The Apache Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * 4. The names "Apache Server" and "Apache Group" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * apache@apache.org. * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Group. * For more information on the Apache Group and the Apache HTTP server * project, please see . * */ #include "threadproc.h" #include "fileio.h" #include "apr_thread_proc.h" #include "apr_file_io.h" #include "apr_general.h" #include #include #include void ap_kill(struct proc_t *proc, int signal) { kill(proc->pid, signal); } 1.1 apache-apr/apr/threadproc/beos/thread.c Index: thread.c =================================================================== /* ==================================================================== * Copyright (c) 1999 The Apache Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * 4. The names "Apache Server" and "Apache Group" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * apache@apache.org. * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Group. * For more information on the Apache Group and the Apache HTTP server * project, please see . * */ #include "threadproc.h" #include "apr_thread_proc.h" #include "apr_general.h" struct threadattr_t *ap_create_threadattr(ap_context_t *cont) { struct threadattr_t *new; new = (struct threadattr_t *)ap_palloc(cont->pool, sizeof(struct threadattr_t)); new->attr = (int32)ap_palloc(cont->pool, sizeof(int32)); new->attr = (int32)B_NORMAL_PRIORITY; } ap_status_t ap_setthreadattr_detach(ap_context_t *cont, 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(ap_context_t *cont, struct threadattr_t *attr) { if (attr->detached == 1){ return APR_SUCCESS; } return APR_FAILURE; } struct thread_t *ap_create_thread(ap_context_t *cont, struct threadattr_t *attr, ap_thread_start_t func, void *data) { struct thread_t *new; new = (struct thread_t *)ap_palloc(cont->pool, sizeof(struct thread_t)); /* First we create the new thread...*/ if (attr == NULL){ attr = ap_create_threadattr(cont); } new->td = spawn_thread((thread_func)func, "apr thread", attr->attr, data); /* Now we try to run it...*/ if (resume_thread((thread_id)new->td) == B_NO_ERROR) { return new; } else { return NULL; } } void ap_thread_exit(ap_context_t *cont, ap_status_t *retval) { exit_thread ((status_t)retval); } ap_status_t ap_thread_join(ap_context_t *cont, ap_thread_t *thd, ap_status_t *retval) { if (wait_for_thread(thd->td,(void *)&retval) == B_NO_ERROR) { return APR_SUCCESS; } else { return APR_FAILURE; } } ap_status_t ap_thread_detach(ap_context_t *cont, ap_thread_t *thd) { if (suspend_thread(thd->td) == B_NO_ERROR){ return APR_SUCCESS; } else { return APR_FAILURE; } } 1.1 apache-apr/apr/threadproc/beos/threadcancel.c Index: threadcancel.c =================================================================== /* ==================================================================== * Copyright (c) 1999 The Apache Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * 4. The names "Apache Server" and "Apache Group" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * apache@apache.org. * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Group. * For more information on the Apache Group and the Apache HTTP server * project, please see . * */ #include "threadproc.h" #include "apr_thread_proc.h" #include "apr_general.h" ap_status_t ap_cancel_thread(ap_context_t *cont, struct thread_t *thd) { if (kill_thread(thd->td) == 0) { return APR_SUCCESS; } else { return APR_FAILURE; } } 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; }*/ } 1.1 apache-apr/apr/threadproc/beos/threadpriv.c Index: threadpriv.c =================================================================== /* ==================================================================== * Copyright (c) 1999 The Apache Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * 4. The names "Apache Server" and "Apache Group" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * apache@apache.org. * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Group. * For more information on the Apache Group and the Apache HTTP server * project, please see . * */ #include "threadproc.h" #include "apr_thread_proc.h" #include "apr_general.h" #include "apr_errno.h" static struct beos_key key_table[BEOS_MAX_DATAKEYS]; static struct beos_private_data *beos_data[BEOS_MAX_DATAKEYS]; static sem_id lock; struct threadkey_t *ap_create_thread_private(ap_context_t *cont, void (*dest)(void *)) { struct threadkey_t *key; key = (struct threadkey_t *)ap_palloc(cont->pool, sizeof(struct threadkey_t)); 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 key; } } release_sem(lock); return NULL; } void *ap_get_thread_private(ap_context_t *cont, struct threadkey_t *key) { void * data; thread_id tid; int i, index=0; tid = find_thread(NULL); for (i=0;idata){ /* 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 NULL; } if ((key->key < BEOS_MAX_DATAKEYS) && (key_table)){ acquire_sem(key_table[key->key].lock); if (key_table[key->key].count){ data = (void*)beos_data[index]->data[key->key]; } else { data = NULL; } release_sem(key_table[key->key].lock); } else { data = NULL; } return data; } ap_status_t ap_set_thread_private(ap_context_t *cont, 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_FAILURE; } 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_FAILURE; } ap_status_t ap_delete_thread_private(ap_context_t *cont, 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_FAILURE; } return APR_SUCCESS; } 1.1 apache-apr/apr/threadproc/beos/threadproc.h Index: threadproc.h =================================================================== /* ==================================================================== * Copyright (c) 1999 The Apache Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * 4. The names "Apache Server" and "Apache Group" must not be used to * endorse or promote products derived from this software without * prior written permission. For written permission, please contact * apache@apache.org. * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the Apache Group * for use in the Apache HTTP server project (http://www.apache.org/)." * * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Group. * For more information on the Apache Group and the Apache HTTP server * project, please see . * */ #include "apr_thread_proc.h" #include "fileio.h" #include "apr_file_io.h" #include #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 { thread_id td; }; struct threadattr_t { int32 attr; int detached; int joinable; }; struct threadkey_t { 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_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 { pid_t pid; struct procattr_t *attr; }; #endif /* ! THREAD_PROC_H */