httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@hyperreal.org
Subject cvs commit: apache-apr/apr/test Makefile testsock.c
Date Wed, 12 May 1999 20:04:40 GMT
rbb         99/05/12 13:04:38

  Modified:    include  apr_thread_proc.h
               apr/threadproc/unix proc.c thread.c threadcancel.c
                        threadpriv.c threadproc.h
               apr/test Makefile testsock.c
  Added:       apr/threadproc/unix signals.c
  Log:
  Make thread/process stuff more portable.
  
  Revision  Changes    Path
  1.9       +3 -2      apache-apr/include/apr_thread_proc.h
  
  Index: apr_thread_proc.h
  ===================================================================
  RCS file: /home/cvs/apache-apr/include/apr_thread_proc.h,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- apr_thread_proc.h	1999/05/12 12:00:11	1.8
  +++ apr_thread_proc.h	1999/05/12 20:04:21	1.9
  @@ -56,7 +56,7 @@
   #ifndef APR_THREAD_PROC_H
   #define APR_THREAD_PROC_H
   
  -#include "threadproc.h"
  +#include "apr_file_io.h"
   #include "apr_general.h"
   #include "apr_errno.h"
   
  @@ -77,7 +77,7 @@
   typedef struct proc_t		  ap_proc_t;
   typedef struct procattr_t         ap_procattr_t;
   
  -typedef threadkey_t               ap_key_t;
  +typedef struct threadkey_t        ap_key_t;
   
   typedef void *(*ap_thread_start_t)(void *);
   
  @@ -109,6 +109,7 @@
   ap_proc_t *ap_create_process(ap_context_t *, char *, char *const [], char **, ap_procattr_t
*);
   ap_status_t ap_wait_proc(ap_context_t *, ap_proc_t *, ap_wait_how_e);
   
  +void ap_kill(ap_proc_t *, ap_int32_t);
   #ifdef __cplusplus
   }
   #endif
  
  
  
  1.9       +16 -15    apache-apr/apr/threadproc/unix/proc.c
  
  Index: proc.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/threadproc/unix/proc.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- proc.c	1999/05/10 15:29:40	1.8
  +++ proc.c	1999/05/12 20:04:23	1.9
  @@ -53,18 +53,19 @@
    *
    */
   
  +#include "threadproc.h"
  +#include "fileio.h"
  +
   #include "apr_thread_proc.h"
   #include "apr_file_io.h"
   #include "apr_general.h"
  -#include "threadproc.h"
  -#include "fileio.h"
   #include <signal.h>
   #include <string.h>
   #include <sys/wait.h>
   
  -ap_procattr_t *ap_createprocattr_init(ap_context_t *cont)
  +struct procattr_t *ap_createprocattr_init(ap_context_t *cont)
   {
  -    ap_procattr_t *new = (ap_procattr_t *)ap_palloc(cont->pool, sizeof(ap_procattr_t));
  +    struct procattr_t *new = (struct procattr_t *)ap_palloc(cont->pool, sizeof(struct
procattr_t));
   
       new->parent_in = NULL;
       new->child_in = NULL;
  @@ -77,7 +78,7 @@
       return new;
   }
   
  -ap_status_t ap_setprocattr_io(ap_context_t *cont, ap_procattr_t *attr, ap_int32_t in, 
  +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) {
  @@ -112,19 +113,19 @@
       } 
   }
   
  -ap_status_t ap_setprocattr_dir(ap_context_t *cont, ap_procattr_t *attr, 
  +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, ap_procattr_t *attr,
  +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, ap_proc_t *proc)
  +ap_int32_t ap_fork(ap_context_t *cont, struct proc_t *proc)
   {
       int pid;
   
  @@ -141,11 +142,11 @@
       return 1;
   }
   
  -ap_proc_t *ap_create_process(ap_context_t *cont, char *progname, 
  +struct proc_t *ap_create_process(ap_context_t *cont, char *progname, 
                                  char *const args[], char **env, 
  -                               ap_procattr_t *attr)
  +                               struct procattr_t *attr)
   {
  -    ap_proc_t *new = (ap_proc_t *)ap_palloc(cont->pool, sizeof(ap_proc_t));
  +    struct proc_t *new = (struct proc_t *)ap_palloc(cont->pool, sizeof(struct proc_t));
       int i;
       char **newargs;
   
  @@ -215,22 +216,22 @@
       return new;
   }
   
  -ap_file_t *ap_get_childin(ap_context_t *cont, ap_proc_t *proc)
  +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, ap_proc_t *proc)
  +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, ap_proc_t *proc)
  +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, ap_proc_t *proc, 
  +ap_status_t ap_wait_proc(ap_context_t *cont, struct proc_t *proc, 
                              ap_wait_how_e wait)
   {
       if (!proc)
  
  
  
  1.2       +11 -10    apache-apr/apr/threadproc/unix/thread.c
  
  Index: thread.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/threadproc/unix/thread.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- thread.c	1999/05/10 17:53:03	1.1
  +++ thread.c	1999/05/12 20:04:24	1.2
  @@ -53,20 +53,21 @@
    *
    */
   
  +#include "threadproc.h"
   #include "apr_thread_proc.h"
   #include "apr_general.h"
   
   
  -ap_threadattr_t *ap_create_threadattr(ap_context_t *cont)
  +struct threadattr_t *ap_create_threadattr(ap_context_t *cont)
   {
  -    ap_threadattr_t *new;
  +    struct threadattr_t *new;
     
  -    new = (ap_threadattr_t *)ap_palloc(cont->pool, sizeof(ap_threadattr_t));
  +    new = (struct threadattr_t *)ap_palloc(cont->pool, sizeof(struct threadattr_t));
       new->attr = (pthread_attr_t *)ap_palloc(cont->pool, sizeof(pthread_attr_t));
       pthread_attr_init(new->attr);
   }
   
  -ap_status_t ap_setthreadattr_detach(ap_context_t *cont, ap_threadattr_t *attr, ap_int32_t
on)
  +ap_status_t ap_setthreadattr_detach(ap_context_t *cont, struct threadattr_t *attr, ap_int32_t
on)
   {
       if (pthread_attr_setdetachstate(attr->attr, on) == 0) {
           return APR_SUCCESS;
  @@ -76,7 +77,7 @@
       }
   }
   
  -ap_status_t ap_getthreadattr_detach(ap_context_t *cont, ap_threadattr_t *attr)
  +ap_status_t ap_getthreadattr_detach(ap_context_t *cont, struct threadattr_t *attr)
   {
       int state;
   
  @@ -86,11 +87,11 @@
       return APR_FAILURE;
   }
   
  -ap_thread_t *ap_create_thread(ap_context_t *cont, ap_threadattr_t *attr, ap_thread_start_t
func, void *data)
  +struct thread_t *ap_create_thread(ap_context_t *cont, struct threadattr_t *attr, ap_thread_start_t
func, void *data)
   {
  -    ap_thread_t *new;
  +    struct thread_t *new;
   
  -    new = (ap_thread_t *)ap_palloc(cont->pool, sizeof(ap_thread_t));
  +    new = (struct thread_t *)ap_palloc(cont->pool, sizeof(struct thread_t));
   
       if (pthread_create(new->td, attr->attr, func, data) == 0) {
           return new;
  @@ -105,7 +106,7 @@
       pthread_exit(retval);
   }
   
  -ap_status_t ap_thread_join(ap_context_t *cont, ap_thread_t *thd, ap_status_t *retval)
  +ap_status_t ap_thread_join(ap_context_t *cont, struct thread_t *thd, ap_status_t *retval)
   {
       if (pthread_join(*thd->td,(void *)&retval) == 0) {
           return APR_SUCCESS;
  @@ -115,7 +116,7 @@
       }
   }
   
  -ap_status_t ap_thread_detach(ap_context_t *cont, ap_thread_t *thd)
  +ap_status_t ap_thread_detach(ap_context_t *cont, struct thread_t *thd)
   {
       if (pthread_detach(*thd->td) == 0) {
           return APR_SUCCESS;
  
  
  
  1.2       +2 -1      apache-apr/apr/threadproc/unix/threadcancel.c
  
  Index: threadcancel.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/threadproc/unix/threadcancel.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- threadcancel.c	1999/05/10 17:53:03	1.1
  +++ threadcancel.c	1999/05/12 20:04:25	1.2
  @@ -53,11 +53,12 @@
    *
    */
   
  +#include "threadproc.h"
   #include "apr_thread_proc.h"
   #include "apr_general.h"
   
   
  -ap_status_t ap_cancel_thread(ap_context_t *cont, ap_thread_t *thd)
  +ap_status_t ap_cancel_thread(ap_context_t *cont, struct thread_t *thd)
   {
       if (pthread_cancel(*thd->td) == 0) {
           return APR_SUCCESS;
  
  
  
  1.2       +11 -10    apache-apr/apr/threadproc/unix/threadpriv.c
  
  Index: threadpriv.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/threadproc/unix/threadpriv.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- threadpriv.c	1999/05/10 17:53:04	1.1
  +++ threadpriv.c	1999/05/12 20:04:25	1.2
  @@ -53,29 +53,30 @@
    *
    */
   
  +#include "threadproc.h"
   #include "apr_thread_proc.h"
   #include "apr_general.h"
   #include "apr_errno.h"
   
  -ap_key_t *ap_create_thread_private(ap_context_t *cont, void (*dest)(void *))
  +struct threadkey_t *ap_create_thread_private(ap_context_t *cont, void (*dest)(void *))
   {
  -    ap_key_t *key;
  -    key = (ap_key_t *)ap_palloc(cont->pool, sizeof(ap_key_t));
  +    struct threadkey_t *key;
  +    key = (struct threadkey_t *)ap_palloc(cont->pool, sizeof(struct threadkey_t));
   
  -    if (pthread_key_create(key, dest) == 0) {
  +    if (pthread_key_create(&key->key, dest) == 0) {
           return key;
       }
       return NULL;
   }
   
  -void *ap_get_thread_private(ap_context_t *cont, ap_key_t key)
  +void *ap_get_thread_private(ap_context_t *cont, struct threadkey_t *key)
   {
  -    return pthread_getspecific(key);
  +    return pthread_getspecific(key->key);
   }
   
  -ap_status_t ap_set_thread_private(ap_context_t *cont, ap_key_t key, void *priv)
  +ap_status_t ap_set_thread_private(ap_context_t *cont, struct threadkey_t *key, void *priv)
   {
  -    if (pthread_setspecific(key, priv)== 0) {
  +    if (pthread_setspecific(key->key, priv)== 0) {
           return APR_SUCCESS;
       }
       else {
  @@ -83,9 +84,9 @@
       }
   }
   
  -ap_status_t ap_delete_thread_private(ap_context_t *cont, ap_key_t key)
  +ap_status_t ap_delete_thread_private(ap_context_t *cont, struct threadkey_t *key)
   {
  -    if (pthread_key_delete(key) == 0) {
  +    if (pthread_key_delete(key->key) == 0) {
           return APR_SUCCESS; 
       }
       return APR_FAILURE;
  
  
  
  1.4       +4 -2      apache-apr/apr/threadproc/unix/threadproc.h
  
  Index: threadproc.h
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/threadproc/unix/threadproc.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- threadproc.h	1999/05/10 14:36:36	1.3
  +++ threadproc.h	1999/05/12 20:04:26	1.4
  @@ -68,14 +68,16 @@
   #define PTHREAD_CANCEL_ENABLE       CANCEL_ENABLE; 
   #define PTHREAD_CANCEL_DISABLE      CANCEL_DISABLE;
   
  -typedef pthread_key_t     threadkey_t;
  -
   struct thread_t {
       pthread_t *td;
   };
   
   struct threadattr_t {
       pthread_attr_t *attr;
  +};
  +
  +struct threadkey_t {
  +    pthread_key_t key;
   };
   
   struct procattr_t {
  
  
  
  1.1                  apache-apr/apr/threadproc/unix/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 <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>
  
  void ap_kill(struct proc_t *proc, int signal)
  {
      kill(proc->pid, signal);
  }
  
  
  
  
  1.12      +1 -1      apache-apr/apr/test/Makefile
  
  Index: Makefile
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/test/Makefile,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Makefile	1999/05/12 19:46:19	1.11
  +++ Makefile	1999/05/12 20:04:34	1.12
  @@ -17,7 +17,7 @@
   EXTRA_DEPS=
   OSDIR=
   INCDIR=../../include
  -INCLUDES0=-I $(INCDIR) -I../threadproc/unix
  +INCLUDES0=-I $(INCDIR)
   SHELL=/bin/sh
   CC=gcc
   CPP=gcc -E
  
  
  
  1.6       +2 -2      apache-apr/apr/test/testsock.c
  
  Index: testsock.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/apr/test/testsock.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- testsock.c	1999/05/12 19:46:19	1.5
  +++ testsock.c	1999/05/12 20:04:35	1.6
  @@ -102,11 +102,11 @@
           continue;
   
       if (s1 == APR_SUCCESS) {
  -        kill(proc2->pid, SIGTERM);
  +        ap_kill(proc2, SIGTERM);
           ap_wait_proc(context, proc2, APR_WAIT);
       }
       else {
  -        kill(proc1->pid, SIGTERM);
  +        ap_kill(proc1, SIGTERM);
           ap_wait_proc(context, proc1, APR_WAIT);
       }
       fprintf(stdout, "Network test completed.\n");   
  
  
  

Mime
View raw message