summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishwanath Venkatesan <vish@hdfgroup.org>2013-07-15 23:12:21 (GMT)
committerVishwanath Venkatesan <vish@hdfgroup.org>2013-07-15 23:12:21 (GMT)
commit971d7291c2f2bd68015caa59b881ebc42e00f979 (patch)
tree449670e2e5585ebc18824f0b5fc12cd9c1491a23
parent7cff8dd993d2fa6226850311c9ed6abef30509b5 (diff)
downloadhdf5-971d7291c2f2bd68015caa59b881ebc42e00f979.zip
hdf5-971d7291c2f2bd68015caa59b881ebc42e00f979.tar.gz
hdf5-971d7291c2f2bd68015caa59b881ebc42e00f979.tar.bz2
[svn-r23904] Handling a race condition.
-rw-r--r--src/H5VLiod_dset.c20
-rw-r--r--src/H5VLiod_server.c17
2 files changed, 25 insertions, 12 deletions
diff --git a/src/H5VLiod_dset.c b/src/H5VLiod_dset.c
index 915fa39..9e086b4 100644
--- a/src/H5VLiod_dset.c
+++ b/src/H5VLiod_dset.c
@@ -659,13 +659,17 @@
FUNC_ENTER_NOAPI_NOINIT
#if DEBUG_COMPACTOR
- fprintf(stderr, "Enters Call BACK!\n");
- fprintf (stderr, "Number of requests : %d from call back in queue : %p\n",
+ fprintf(stderr, " COMPACTOR CB: Enters Call BACK!\n");
+ fprintf (stderr, "COMPACTOR CB: Number of requests : %d from call back in queue : %p\n",
H5VL_iod_get_number_of_requests(cqueue), (void *)cqueue);
fflush(stderr);
- #endif
-
- pthread_mutex_lock(&lock);
+ fprintf (stderr, "COMPACTOR CB: Sleeping NOW \n");
+ #endif
+ usleep(1000);
+#if DEBUG_COMPACTOR
+ fprintf (stderr, "COMPACTOR CB: Done Sleeping! \n");
+#endif
+ while(pthread_mutex_trylock(&lock) != 0);
compactor_queue_flag = 0;
curr_queue = NULL;
pthread_mutex_unlock(&lock);
@@ -776,6 +780,7 @@ int H5VL_iod_server_compactor_write (void *_list, int num_requests)
/*When the request was used in merging we have to just
manage the handle*/
if (list[request_counter].merged == NOT_MERGED){
+
op_data = (op_data_t *)list[request_counter].op_data;
input = (dset_io_in_t *)op_data->input;
iod_oh = input->iod_oh;
@@ -805,6 +810,7 @@ int H5VL_iod_server_compactor_write (void *_list, int num_requests)
}
if (list[request_counter].merged == MERGED){
+
op_data = (op_data_t *)list[request_counter].op_data;
input = (dset_io_in_t *)op_data->input;
iod_oh = input->iod_oh;
@@ -874,7 +880,7 @@ int H5VL_iod_server_compactor_write (void *_list, int num_requests)
num_descriptors, n);
num_bytes = 0;
- num_elems = 1;
+ num_elems = 0;
/* determine how many bytes the current descriptor holds */
for(i=0 ; i<ndims ; i++){
@@ -894,7 +900,7 @@ int H5VL_iod_server_compactor_write (void *_list, int num_requests)
#if 1
/* set the memory descriptor */
mem_desc = (iod_mem_desc_t *) malloc (sizeof (iod_mem_desc_t));
- mem_desc->frag = (iod_mem_frag_t *) malloc (sizeof (iod_mem_desc_t));
+ mem_desc->frag = (iod_mem_frag_t *) malloc (sizeof (iod_mem_frag_t));
mem_desc->nfrag = 1;
mem_desc->frag[0].addr = (void *)buf_ptr;
mem_desc->frag[0].len = (iod_size_t)num_bytes;
diff --git a/src/H5VLiod_server.c b/src/H5VLiod_server.c
index c9d28e6..8d34eaf 100644
--- a/src/H5VLiod_server.c
+++ b/src/H5VLiod_server.c
@@ -1385,8 +1385,15 @@ int H5VL_iod_server_dset_compactor(op_data_t *op_data, int request_type)
compactor_queue_flag);
fflush(stderr);
- if (NULL == curr_queue)
- fprintf(stderr,"Compactor Not present\n");
+ if (NULL == curr_queue){
+ if (compactor_queue_flag){
+ fprintf (stderr, "Compactor queue cannot be NULL when compactor_flag is %d\n",
+ compactor_queue_flag);
+ compactor_queue_flag = 0;
+ }
+ fprintf(stderr,"Compactor Not present with flag : %d\n",
+ compactor_queue_flag);
+ }
else
fprintf(stderr,"Queue exists with compactor_flag : %d, and %d reqs\n",
compactor_queue_flag,
@@ -1405,7 +1412,6 @@ int H5VL_iod_server_dset_compactor(op_data_t *op_data, int request_type)
fprintf (stderr, "Completed creating a queue : %p\n", (void *)curr_queue);
fflush(stderr);
-
}
@@ -1439,10 +1445,11 @@ int H5VL_iod_server_dset_compactor(op_data_t *op_data, int request_type)
fprintf (stderr, "Completed Adding a barrier task\n");
fflush(stderr);
#endif
-
pthread_mutex_lock(&lock);
compactor_queue_flag = 1;
pthread_mutex_unlock(&lock);
+
+
}
#if DEBUG_COMPACTOR
@@ -2680,7 +2687,7 @@ H5VL_iod_get_file_desc(hid_t space_id, hssize_t *count, iod_hyperslab_t *hslabs)
if(NULL != hslabs) {
hsize_t *blocks;
-
+ fprintf (stderr, "num_descriptors from : %llu get file desc \n", num_descriptors);
if(NULL == (blocks = (hsize_t *)malloc(sizeof(hsize_t) * 2 *
ndims * num_descriptors)))
HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "can't allocate array for points coords");