apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject cvs commit: apr-util/test testqueue.c
Date Thu, 08 May 2003 19:38:12 GMT
trawick     2003/05/08 12:38:12

  Modified:    test     testqueue.c
  Log:
  portable formatting of os thread id
  
  Revision  Changes    Path
  1.6       +21 -9     apr-util/test/testqueue.c
  
  Index: testqueue.c
  ===================================================================
  RCS file: /home/cvs/apr-util/test/testqueue.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- testqueue.c	22 Feb 2003 17:02:48 -0000	1.5
  +++ testqueue.c	8 May 2003 19:38:12 -0000	1.6
  @@ -56,6 +56,7 @@
   #include <apr_errno.h>
   #include <apr_general.h>
   #include <apr_getopt.h>
  +#include <apr_strings.h>
   #include "errno.h"
   #include <stdio.h>
   #include <stdlib.h>
  @@ -91,29 +92,35 @@
       apr_status_t rv;
       int val;
       void *v;
  +    char current_thread_str[30];
  +    apr_os_thread_t current_thread = apr_os_thread_current();
  +
  +    apr_snprintf(current_thread_str, sizeof current_thread_str,
  +                 "%pT", &current_thread);
   
       sleeprate = 1000000/consumer_activity;
       apr_sleep( (rand() % 4 ) * 1000000 ); /* sleep random seconds */
       while (1) {
           do {
               rv = apr_queue_pop(q, &v);
  -            if (rv == APR_EINTR) 
  -                fprintf(stderr, "%ld\tconsumer intr\n",apr_os_thread_current());
  +            if (rv == APR_EINTR) {
  +                fprintf(stderr, "%s\tconsumer intr\n", current_thread_str);
  +            }
   
           } while (rv == APR_EINTR) ;
           if (rv != APR_SUCCESS) {
               if (rv == APR_EOF) {
  -                fprintf(stderr, "%ld\tconsumer:queue terminated APR_EOF\n", apr_os_thread_current());
  +                fprintf(stderr, "%s\tconsumer:queue terminated APR_EOF\n", current_thread_str);
                   rv=APR_SUCCESS;
               }
               else 
  -                fprintf(stderr, "%ld\tconsumer thread exit rv %d\n", apr_os_thread_current(),rv);
  +                fprintf(stderr, "%s\tconsumer thread exit rv %d\n", current_thread_str,
rv);
               apr_thread_exit(thd, rv);
               return NULL;
           }
           val = *(int*)v;
           if (verbose)
  -            fprintf(stderr,  "%ld\tpop %d\n", apr_os_thread_current(),val);
  +            fprintf(stderr,  "%s\tpop %d\n", current_thread_str, val);
           apr_sleep( sleeprate ); /* sleep this long to acheive our rate */
       }
       /* not reached */
  @@ -127,6 +134,11 @@
       apr_queue_t *q = (apr_queue_t*)data;
       apr_status_t rv;
       int *val;
  +    char current_thread_str[30];
  +    apr_os_thread_t current_thread = apr_os_thread_current();
  +
  +    apr_snprintf(current_thread_str, sizeof current_thread_str,
  +                 "%pT", &current_thread);
   
       sleeprate = 1000000/producer_activity;
       apr_sleep( (rand() % 4 ) * 1000000 ); /* sleep random seconds */
  @@ -135,20 +147,20 @@
           val = apr_palloc(context, sizeof(int));
           *val=i;
           if (verbose)
  -            fprintf(stderr,  "%ld\tpush %d\n",apr_os_thread_current(),*val);
  +            fprintf(stderr,  "%s\tpush %d\n", current_thread_str, *val);
           do {
               rv = apr_queue_push(q, val);
               if (rv == APR_EINTR) 
  -                fprintf(stderr, "%ld\tproducer intr\n",apr_os_thread_current());
  +                fprintf(stderr, "%s\tproducer intr\n", current_thread_str);
           } while (rv == APR_EINTR);
   
           if (rv != APR_SUCCESS) {
               if (rv == APR_EOF) {
  -                fprintf(stderr, "%ld\tproducer: queue terminated APR_EOF\n", apr_os_thread_current());
  +                fprintf(stderr, "%s\tproducer: queue terminated APR_EOF\n", current_thread_str);
                   rv = APR_SUCCESS;
               }
               else
  -                fprintf(stderr, "%ld\tproducer thread exit rv %d\n", apr_os_thread_current(),rv);
  +                fprintf(stderr, "%s\tproducer thread exit rv %d\n", current_thread_str,
rv);
               apr_thread_exit(thd, rv);
               return NULL;
           }
  
  
  

Mime
View raw message