diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2012-10-18 21:14:35 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2012-10-18 21:14:35 (GMT) |
commit | b624395cca176d28a89ad91b84fa19d5e7d36c55 (patch) | |
tree | 4c5d56fcf37206229b96848295e6e7f767dd8a8e | |
parent | ddced9ab1d4f0fee92e6e4d1a244c6a85303b373 (diff) | |
download | hdf5-b624395cca176d28a89ad91b84fa19d5e7d36c55.zip hdf5-b624395cca176d28a89ad91b84fa19d5e7d36c55.tar.gz hdf5-b624395cca176d28a89ad91b84fa19d5e7d36c55.tar.bz2 |
[svn-r22922] Purpose:
Moved the file open/close back inside the loop in the SWMR reader
code. Without the open/close, the cache never refreshes so we
always see the initial amount.
Made a couple of other minor changes to the SWMR code.
Tested on:
jam
-rw-r--r-- | test/swmr_addrem_writer.c | 5 | ||||
-rw-r--r-- | test/swmr_common.c | 4 | ||||
-rw-r--r-- | test/swmr_reader.c | 34 | ||||
-rw-r--r-- | test/swmr_remove_reader.c | 32 | ||||
-rw-r--r-- | test/swmr_sparse_writer.c | 2 | ||||
-rw-r--r-- | test/swmr_writer.c | 2 |
6 files changed, 39 insertions, 40 deletions
diff --git a/test/swmr_addrem_writer.c b/test/swmr_addrem_writer.c index e80cea9..b2cee81 100644 --- a/test/swmr_addrem_writer.c +++ b/test/swmr_addrem_writer.c @@ -49,8 +49,7 @@ /* Local Prototypes */
/********************/
-static hid_t
-open_skeleton(const char *filename, unsigned verbose);
+static hid_t open_skeleton(const char *filename, unsigned verbose);
static int addrem_records(hid_t fid, unsigned verbose, unsigned long nops,
unsigned long flush_count);
static void usage(void);
@@ -135,7 +134,7 @@ open_skeleton(const char *filename, unsigned verbose) symbol_info[u][v].nrecords = dim[1];
} /* end for */
- return(fid);
+ return fid;
}
diff --git a/test/swmr_common.c b/test/swmr_common.c index b921d15..cdac4c9 100644 --- a/test/swmr_common.c +++ b/test/swmr_common.c @@ -101,7 +101,7 @@ choose_dataset(void) /* Determine the offset of the level */ offset = random() % symbol_count[level]; - return(&symbol_info[level][offset]); + return &symbol_info[level][offset]; } /* end choose_dataset() */ @@ -142,7 +142,7 @@ create_symbol_datatype(void) if(H5Tclose(opaq_type_id) < 0) return -1; - return(sym_type_id); + return sym_type_id; } /* end create_symbol_datatype() */ diff --git a/test/swmr_reader.c b/test/swmr_reader.c index 14e91ca..0ce368a 100644 --- a/test/swmr_reader.c +++ b/test/swmr_reader.c @@ -252,23 +252,23 @@ read_records(const char *filename, unsigned verbose, unsigned long nseconds, /* Emit informational message */ if(verbose) - printf("Reading records\n"); + fprintf(stderr, "Reading records\n"); /* Get the starting time */ start_time = time(NULL); curr_time = start_time; - - /* Emit informational message */ - if(verbose) - fprintf(stderr, "Opening file: %s\n", filename); - - /* Open the file */ - if((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, H5P_DEFAULT)) < 0) - return -1; /* Loop over reading records until [at least] the correct # of seconds have passed */ while(curr_time < (time_t)(start_time + (time_t)nseconds)) { + /* Emit informational message */ + if(verbose) + fprintf(stderr, "Opening file: %s\n", filename); + + /* Open the file */ + if((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, H5P_DEFAULT)) < 0) + return -1; + /* Check 'common' datasets, if any */ if(ncommon > 0) { /* Emit informational message */ @@ -299,6 +299,14 @@ read_records(const char *filename, unsigned verbose, unsigned long nseconds, } /* end for */ } /* end if */ + /* Emit informational message */ + if(verbose) + fprintf(stderr, "Closing file\n"); + + /* Close the file */ + if(H5Fclose(fid) < 0) + return -1; + /* Sleep for the appropriate # of seconds */ sleep(poll_time); @@ -306,14 +314,6 @@ read_records(const char *filename, unsigned verbose, unsigned long nseconds, curr_time = time(NULL); } /* end while */ - /* Emit informational message */ - if(verbose) - fprintf(stderr, "Closing file\n"); - - /* Close the file */ - if(H5Fclose(fid) < 0) - return -1; - /* Close the memory dataspace */ if(H5Sclose(mem_sid) < 0) return -1; diff --git a/test/swmr_remove_reader.c b/test/swmr_remove_reader.c index e8a1194..93bd55c 100644 --- a/test/swmr_remove_reader.c +++ b/test/swmr_remove_reader.c @@ -273,17 +273,17 @@ read_records(const char *filename, unsigned verbose, unsigned long nseconds, start_time = time(NULL);
curr_time = start_time;
- /* Emit informational message */
- if(verbose)
- fprintf(stderr, "Opening file: %s\n", filename);
-
- /* Open the file */
- if((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, H5P_DEFAULT)) < 0)
- return -1;
-
/* Loop over reading records until [at least] the correct # of seconds have passed */
while(curr_time < (time_t)(start_time + (time_t)nseconds)) {
+ /* Emit informational message */
+ if(verbose)
+ fprintf(stderr, "Opening file: %s\n", filename);
+
+ /* Open the file */
+ if((fid = H5Fopen(filename, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, H5P_DEFAULT)) < 0)
+ return -1;
+
/* Check 'common' datasets, if any */
if(ncommon > 0) {
/* Emit informational message */
@@ -314,6 +314,14 @@ read_records(const char *filename, unsigned verbose, unsigned long nseconds, } /* end for */
} /* end if */
+ /* Emit informational message */
+ if(verbose)
+ fprintf(stderr, "Closing file\n");
+
+ /* Close the file */
+ if(H5Fclose(fid) < 0)
+ return -1;
+
/* Sleep for the appropriate # of seconds */
sleep(poll_time);
@@ -321,14 +329,6 @@ read_records(const char *filename, unsigned verbose, unsigned long nseconds, curr_time = time(NULL);
} /* end while */
- /* Emit informational message */
- if(verbose)
- fprintf(stderr, "Closing file\n");
-
- /* Close the file */
- if(H5Fclose(fid) < 0)
- return -1;
-
/* Close the memory dataspace */
if(H5Sclose(mem_sid) < 0)
return -1;
diff --git a/test/swmr_sparse_writer.c b/test/swmr_sparse_writer.c index 00a0256..dda9c98 100644 --- a/test/swmr_sparse_writer.c +++ b/test/swmr_sparse_writer.c @@ -114,7 +114,7 @@ open_skeleton(const char *filename, unsigned verbose) /* Emit informational message */
if(verbose)
- printf("Opening datasets\n");
+ fprintf(stderr, "Opening datasets\n");
/* Seed the random number generator with the attribute in the file */
if((aid = H5Aopen(fid, "seed", H5P_DEFAULT)) < 0)
diff --git a/test/swmr_writer.c b/test/swmr_writer.c index 8ff7312..445932d 100644 --- a/test/swmr_writer.c +++ b/test/swmr_writer.c @@ -116,7 +116,7 @@ open_skeleton(const char *filename, unsigned verbose) symbol_info[u][v].nrecords = 0; } /* end for */ - return(fid); + return fid; } |