httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dr...@locus.apache.org
Subject cvs commit: apache-2.0/src/lib/apr/test testoc.c
Date Tue, 04 Apr 2000 22:56:12 GMT
dreid       00/04/04 15:56:11

  Modified:    src/lib/apr/dso/beos dso.c
               src/lib/apr/misc/beos Makefile.in misc.h
               src/lib/apr/test testoc.c
  Added:       src/lib/apr/misc/beos otherchild.c
  Log:
  Add the other child stuff to beos, tidy up the test program a little and
  get the dso code building again.
  
  Revision  Changes    Path
  1.3       +4 -4      apache-2.0/src/lib/apr/dso/beos/dso.c
  
  Index: dso.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/dso/beos/dso.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- dso.c	2000/03/31 08:35:44	1.2
  +++ dso.c	2000/04/04 22:56:10	1.3
  @@ -59,8 +59,8 @@
       return APR_SUCCESS;
   }
   
  -ap_status_t ap_dso_load(const char *path, ap_context_t *ctx,
  -			ap_dso_handle_t **res_handle)
  +ap_status_t ap_dso_load(ap_dso_handle_t **res_handle, const char *path,
  +              ap_context_t *ctx)
   {
       image_id newid;
   
  @@ -81,8 +81,8 @@
       return APR_SUCCESS;
   }
   
  -ap_status_t ap_dso_sym(ap_dso_handle_t *handle, const char *symname,
  -		       ap_dso_handle_sym_t *ressym)
  +ap_status_t ap_dso_sym(ap_dso_handle_sym_t *ressym, ap_dso_handle_t *handle,
  +               const char *symname)
   {
       int err;
   
  
  
  
  1.8       +1 -1      apache-2.0/src/lib/apr/misc/beos/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/misc/beos/Makefile.in,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Makefile.in	2000/03/15 12:02:25	1.7
  +++ Makefile.in	2000/04/04 22:56:11	1.8
  @@ -14,7 +14,7 @@
   
   LIB=libmisc.a
   
  -OBJS=start.o misc_common.o \
  +OBJS=start.o misc_common.o otherchild.o
   
   .c.o:
   	$(CC) $(CFLAGS) -c $(INCLUDES) $<
  
  
  
  1.10      +12 -0     apache-2.0/src/lib/apr/misc/beos/misc.h
  
  Index: misc.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/misc/beos/misc.h,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- misc.h	2000/04/03 18:37:20	1.9
  +++ misc.h	2000/04/04 22:56:11	1.10
  @@ -72,6 +72,8 @@
   #include <signal.h>
   #endif
   
  +#include <kernel/OS.h>
  +
   typedef struct datastruct {
       void *data;
       char *key;
  @@ -84,6 +86,16 @@
       void *prog_data;
       int (*apr_abort)(int retcode);
   };
  +
  +
  +struct ap_other_child_rec_t {
  +    struct ap_other_child_rec_t *next;
  +    thread_id tid;
  +    void (*maintenance) (int, void *);
  +    void *data;
  +    int write_fd;
  +};
  +
   
   #endif  /* ! MISC_H */
   
  
  
  
  1.1                  apache-2.0/src/lib/apr/misc/beos/otherchild.c
  
  Index: otherchild.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000 The Apache Software Foundation.  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. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" 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 name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``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 SOFTWARE FOUNDATION 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 Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #include "misc.h"
  #include "../../threadproc/beos/threadproc.h"
  
  static ap_other_child_rec_t *other_children = NULL;
  
  API_EXPORT(void) ap_register_other_child(ap_proc_t *pid,
                       void (*maintenance) (int reason, void *),
                       void *data, int write_fd, ap_context_t *p)
  {
      ap_other_child_rec_t *ocr;
  
      ocr = ap_palloc(p, sizeof(*ocr));
      ocr->tid = pid->tid;
      ocr->maintenance = maintenance;
      ocr->data = data;
      ocr->write_fd = write_fd;
      ocr->next = other_children;
      other_children = ocr;
  }
  
  API_EXPORT(void) ap_unregister_other_child(void *data)
  {
      ap_other_child_rec_t **pocr, *nocr;
  
      for (pocr = &other_children; *pocr; pocr = &(*pocr)->next) {
          if ((*pocr)->data == data) {
              nocr = (*pocr)->next;
              (*(*pocr)->maintenance) (APR_OC_REASON_UNREGISTER, (*pocr)->data);
              *pocr = nocr;
              /* XXX: um, well we've just wasted some space in pconf ? */
              return;
          }
      }
  }
  
  /* test to ensure that the write_fds are all still writable, otherwise
   * invoke the maintenance functions as appropriate */
  static void probe_writable_fds(void)
  {
      fd_set writable_fds;
      int fd_max;
      ap_other_child_rec_t *ocr, *nocr; 
      struct timeval tv; 
      int rc;
  
      if (other_children == NULL)
          return;
  
      fd_max = 0;
      FD_ZERO(&writable_fds);
      do {
          for (ocr = other_children; ocr; ocr = ocr->next) {
              if (ocr->write_fd == -1)
                  continue;
              FD_SET(ocr->write_fd, &writable_fds);
              if (ocr->write_fd > fd_max) {
                  fd_max = ocr->write_fd;
              }
          }
          if (fd_max == 0)
              return;
  
          tv.tv_sec = 0;
          tv.tv_usec = 0;
          rc = select(fd_max + 1, NULL, &writable_fds, NULL, &tv);
      } while (rc == -1 && errno == EINTR);
  
      if (rc == -1) {
          /* XXX: uhh this could be really bad, we could have a bad file
           * descriptor due to a bug in one of the maintenance routines */
          return;
      }
      if (rc == 0)
          return;
  
      for (ocr = other_children; ocr; ocr = nocr) {
          nocr = ocr->next;
          if (ocr->write_fd == -1)
              continue;
          if (FD_ISSET(ocr->write_fd, &writable_fds))
              continue;
          (*ocr->maintenance) (APR_OC_REASON_UNWRITABLE, ocr->data);
      }
  }
  
  API_EXPORT(ap_status_t) reap_other_child(ap_proc_t *pid)
  {
      ap_other_child_rec_t *ocr, *nocr;
  
      for (ocr = other_children; ocr; ocr = nocr) {
          nocr = ocr->next;
          if (ocr->tid != pid->tid)
              continue;
          ocr->tid = -1;
          (*ocr->maintenance) (APR_OC_REASON_DEATH, ocr->data);
          return 0;
      }
      return APR_CHILD_NOTDONE;
  }
  
  API_EXPORT(void) check_other_child(void)
  {
      ap_other_child_rec_t *ocr, *nocr;
      pid_t waitret;    
  
      for (ocr = other_children; ocr; ocr = nocr) {
          nocr = ocr->next;
          if (ocr->tid == -1)
              continue;
  
          waitret = waitpid(ocr->tid, NULL, WNOHANG);
          if (waitret == ocr->tid) {
              ocr->tid = -1;
              (*ocr->maintenance) (APR_OC_REASON_DEATH, ocr->data);
          }
          else if (waitret == 0) {
              (*ocr->maintenance) (APR_OC_REASON_RESTART, ocr->data);
          }
          else if (waitret == -1) {
              /* uh what the heck? they didn't call unregister? */
              ocr->tid = -1;
              (*ocr->maintenance) (APR_OC_REASON_LOST, ocr->data);
          }
      }
  }
  
  
  
  
  1.2       +24 -5     apache-2.0/src/lib/apr/test/testoc.c
  
  Index: testoc.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/test/testoc.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- testoc.c	2000/04/04 20:26:36	1.1
  +++ testoc.c	2000/04/04 22:56:11	1.2
  @@ -64,13 +64,18 @@
   
   void ocmaint(int reason, void *data)
   {
  +    fprintf(stdout,"[CHILD]  Maintenance routine called....");
  +    fflush(stdout);
       switch (reason) {
       case APR_OC_REASON_DEATH:
  -        fprintf(stdout, "OC killed... correctly\n");
  +        fprintf(stdout, "Died correctly\n");
           break;
       case APR_OC_REASON_LOST:
  +        fprintf(stdout, "APR_OC_REASON_LOST\n");
       case APR_OC_REASON_UNWRITABLE:
  +        fprintf(stdout, "APR_OC_REASON_UNWRITEABLE\n");
       case APR_OC_REASON_RESTART:
  +        fprintf(stdout, "APR_OC_REASON_RESTART\n");
           fprintf(stdout, "OC maintentance called for reason other than death\n");
           break;
       }
  @@ -104,13 +109,16 @@
       args[1] = ap_pstrdup(context, "-X");
       args[2] = NULL;
   
  -    fprintf(stdout, "Creating procattr.......");
  +    fprintf(stdout, "[PARENT] Creating procattr.............");
  +    fflush(stdout);
       if (ap_createprocattr_init(&procattr, context) != APR_SUCCESS) {
           fprintf(stderr, "Could not create attr\n");
           exit(-1);;
       }
  +    fprintf(stdout, "OK\n");
   
  -    fprintf(stdout, "starting other child.......");
  +    fprintf(stdout, "[PARENT] Starting other child..........");
  +    fflush(stdout);
       if (ap_create_process(&newproc, "../testoc", args, NULL, procattr, context) 
                             != APR_SUCCESS) {
           fprintf(stderr, "error starting other child\n");
  @@ -118,10 +126,21 @@
       }
       fprintf(stdout, "OK\n");
   
  -    ap_register_other_child(newproc, ocmaint, NULL, -1, context);
   
  -    ap_kill(newproc, SIGKILL);
  +    ap_register_other_child(newproc, ocmaint, NULL, -1, context);
   
  +    fprintf(stdout, "[PARENT] Sending SIGKILL to child......");
  +    fflush(stdout);
  +    if (ap_kill(newproc, SIGKILL) != APR_SUCCESS) {
  +        fprintf(stderr,"couldn't send the signal!\n");
  +        exit(-1);
  +    }
  +    fprintf(stdout,"OK\n");
  +    
  +    /* allow time for things to settle... */
  +    sleep(1);
  +    
  +    fprintf(stdout, "[PARENT] Checking on children..........\n");
       check_other_child();
       
       return 1;
  
  
  

Mime
View raw message