apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <...@rkbloom.net>
Subject Re: [PATCH] Re: apr_proc_mutex is broken
Date Tue, 19 Nov 2002 17:01:00 GMT

This patch also highlights another problem with our current test suite.
Please, stop putting assert() statements in the test suite.  Asserts are
not a valid way to determine if a test was successful, because they stop
all other tests from running.

Ryan

>  static int make_child(apr_proc_t **proc, apr_pool_t *p)
>  {
> @@ -82,14 +83,14 @@
>
>      if (apr_proc_fork(*proc, p) == APR_INCHILD) {
>          while (1) {
> -            apr_proc_mutex_lock(proc_lock);
> +            assert(apr_proc_mutex_lock(proc_lock) == APR_SUCCESS);
>              if (i == MAX_ITER) {
> -                apr_proc_mutex_unlock(proc_lock);
> +                assert(apr_proc_mutex_unlock(proc_lock) == APR_SUCCESS);
>                  exit(1);
>              }
>              i++;
>              (*x)++;
> -            apr_proc_mutex_unlock(proc_lock);
> +            assert(apr_proc_mutex_unlock(proc_lock) == APR_SUCCESS);
>          }
>          exit(1);
>      }
> @@ -155,7 +156,6 @@
>      printf("APR Proc Mutex Test\n==============\n\n");
>
>      apr_initialize();
> -    atexit(apr_terminate);
>
>      if (apr_pool_create(&pool, NULL) != APR_SUCCESS)
>          exit(-1);
> @@ -178,15 +178,22 @@
>          exit(-1);
>      }
>
> -    apr_shm_create(&shm, sizeof(int), shmname, pool);
> +    assert(apr_shm_create(&shm, 2 * sizeof(int), shmname, pool) == APR_SUCCESS);
>      x = apr_shm_baseaddr_get(shm);
> +    y = x + 1;
>
>      if ((rv = test_exclusive(lockname)) != APR_SUCCESS) {
>          fprintf(stderr,"Exclusive Lock test failed : [%d] %s\n",
>                  rv, apr_strerror(rv, (char*)errmsg, 200));
>          exit(-2);
>      }
> -
> +
> +    /* if the child processes run apr_terminate() when they exit, the
> +     * mutex will be destroyed and remaining children will be left with
> +     * a useless mutex
> +     */
> +    apr_terminate();
> +
>      return 0;
>  }
>
>
> --
> Jeff Trawick | trawick@attglobal.net
> Born in Roswell... married an alien...
>


Mime
View raw message