summaryrefslogtreecommitdiffstats
path: root/src/H5C2journal.c
diff options
context:
space:
mode:
authorMike McGreevy <mamcgree@hdfgroup.org>2008-05-20 22:19:34 (GMT)
committerMike McGreevy <mamcgree@hdfgroup.org>2008-05-20 22:19:34 (GMT)
commit93343e5abee605701f910abed0065d6b6bd59c11 (patch)
tree5dce174b2a76bf47da1e89017301089783ac4224 /src/H5C2journal.c
parentf9857027e327cac5b356da2c6c3ac94e3a773b29 (diff)
downloadhdf5-93343e5abee605701f910abed0065d6b6bd59c11.zip
hdf5-93343e5abee605701f910abed0065d6b6bd59c11.tar.gz
hdf5-93343e5abee605701f910abed0065d6b6bd59c11.tar.bz2
[svn-r15050] Purpose: Bug Fixes
Description: Fixing a couple of bugs in the journal logging code. Primarily, H5C2_jb__bin2hex was WAY inefficient. I've cleaned it up a bit. cache2_journal now finishes in less than a minute on kagiso. Also, __DATE__ preprocessor macros are no longer used to generate journal file headers. Tested: kagiso
Diffstat (limited to 'src/H5C2journal.c')
-rw-r--r--src/H5C2journal.c49
1 files changed, 25 insertions, 24 deletions
diff --git a/src/H5C2journal.c b/src/H5C2journal.c
index 3445c4f..53fd63a 100644
--- a/src/H5C2journal.c
+++ b/src/H5C2journal.c
@@ -2589,6 +2589,7 @@ H5C2_jb__init(H5C2_jbrb_t * struct_ptr,
char temp[150];
int i;
herr_t ret_value = SUCCEED;
+ time_t current_date;
FUNC_ENTER_NOAPI(H5C2_jb__init, FAIL)
@@ -2690,13 +2691,16 @@ H5C2_jb__init(H5C2_jbrb_t * struct_ptr,
/* Define head pointer to point at where we are writing to in the buffer */
struct_ptr->head = (*struct_ptr->buf)[struct_ptr->put];
+ /* Get the current date */
+ current_date = time(NULL);
+
/* Format the header message into a temporary buffer */
HDsnprintf(temp,
(size_t)150,
- "0 ver_num %ld target_file_name %s creation_date %s human_readable %d\n",
+ "0 ver_num %ld target_file_name %s creation_date %010.10s human_readable %d\n",
struct_ptr->jvers,
struct_ptr->hdf5_file_name,
- __DATE__,
+ ctime(&current_date),
struct_ptr->human_readable);
/* Write the header message into the ring buffer */
@@ -2746,6 +2750,7 @@ H5C2_jb__start_transaction(H5C2_jbrb_t * struct_ptr,
{
char temp[150];
herr_t ret_value = SUCCEED;
+ time_t current_date;
FUNC_ENTER_NOAPI(H5C2_jb__start_transaction, FAIL)
#if 0 /* JRM */
@@ -2780,12 +2785,15 @@ H5C2_jb__start_transaction(H5C2_jbrb_t * struct_ptr,
*/
if ( struct_ptr->header_present == FALSE ) {
+ /* Get the current date */
+ current_date = time(NULL);
+
HDsnprintf(temp,
(size_t)150,
- "0 ver_num %ld target_file_name %s creation_date %s human_readable %d\n",
+ "0 ver_num %ld target_file_name %s creation_date %010.10s human_readable %d\n",
struct_ptr->jvers,
struct_ptr->hdf5_file_name,
- __DATE__,
+ ctime(&current_date),
struct_ptr->human_readable);
if ( H5C2_jb__write_to_buffer(struct_ptr, HDstrlen(temp), temp,
@@ -2893,7 +2901,7 @@ H5C2_jb__journal_entry(H5C2_jbrb_t * struct_ptr,
} /* end if */
/* Convert data from binary to hex */
- H5C2_jb__bin2hex(body, hexdata, &hexlength, 0, length);
+ H5C2_jb__bin2hex(body, hexdata, &hexlength, length);
if ( H5C2_jb__write_to_buffer(struct_ptr, hexlength, hexdata, FALSE, trans_num) < 0 ) {
@@ -3362,36 +3370,29 @@ herr_t
H5C2_jb__bin2hex(const uint8_t * buf,
char * hexdata,
size_t * hexlength,
- size_t buf_offset,
size_t buf_size)
{
- size_t u, v; /* Local index variable */
+ size_t v; /* Local index variable */
uint8_t c;
+ char * t;
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5C2_jb__bin2hex)
- HDsnprintf(hexdata, (size_t)2, " ");
-
- for(u = 0; u < buf_size; u += 16) {
-
- /* Print the hex values */
- for(v = 0; v < 16; v++) {
-
- if(u + v < buf_size) {
+ t = hexdata;
+ t[0] = ' ';
+ for (v = 0; v < buf_size; v++) {
- c = buf[buf_offset + u + v];
- sprintf(hexdata, "%s%02x ", hexdata, c);
-
- } /* end if */
-
- } /* end for */
+ t = &hexdata[v * 3 + 1];
+ c = buf[v];
+ HDsnprintf(t, (size_t)3, "%02x ", c);
+ t[2] = ' ';
} /* end for */
-
- sprintf(hexdata, "%s\n", hexdata);
+ t[3] = '\n';
+ t[4] = 0;
- * hexlength = HDstrlen(hexdata);
+ * hexlength = v * 3 + 2;
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5C2_jb__bin2hex*/