apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject cvs commit: apr/test testflock.c
Date Sat, 31 Mar 2001 22:38:28 GMT
trawick     01/03/31 14:38:28

  Modified:    test     testflock.c
  Log:
  minor improvements in error reporting so as to help somebody
  that wants to get this to work on non-Unix
  
  Revision  Changes    Path
  1.6       +16 -3     apr/test/testflock.c
  
  Index: testflock.c
  ===================================================================
  RCS file: /home/cvs/apr/test/testflock.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- testflock.c	2001/02/16 04:16:09	1.5
  +++ testflock.c	2001/03/31 22:38:28	1.6
  @@ -94,6 +94,18 @@
       exit(1);
   }
   
  +static void errmsg2(const char *msg, apr_status_t rv)
  +{
  +    char *newmsg;
  +    char errstr[120];
  +
  +    apr_strerror(rv, errstr, sizeof errstr);
  +    newmsg = apr_psprintf(pool, "%s: %s (%d)\n",
  +                          msg, errstr, rv);
  +    errmsg(newmsg);
  +    exit(1);
  +}
  +
   static void do_read(void)
   {
       apr_file_t *file;
  @@ -124,18 +136,19 @@
   static void do_write(void)
   {
       apr_file_t *file;
  +    apr_status_t rv;
   
       if (apr_file_open(&file, TESTFILE, APR_WRITE|APR_CREATE, APR_OS_DEFAULT,
                    pool) != APR_SUCCESS)
           errmsg("Could not create file.\n");
       printf("Test file created.\n");
   
  -    if (apr_file_lock(file, APR_FLOCK_EXCLUSIVE) != APR_SUCCESS)
  -        errmsg("Could not lock the file.\n");
  +    if ((rv = apr_file_lock(file, APR_FLOCK_EXCLUSIVE)) != APR_SUCCESS)
  +        errmsg2("Could not lock the file", rv);
       printf("Lock created.\nSleeping...");
       fflush(stdout);
   
  -    apr_sleep(30000000);        /* 30 seconds */
  +    apr_sleep(30 * APR_USEC_PER_SEC);
   
       (void) apr_file_close(file);
       printf(" done.\nExiting.\n");
  
  
  

Mime
View raw message