rcuja range: range add return error value
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sun, 9 Jun 2013 21:15:11 +0000 (17:15 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sun, 9 Jun 2013 21:15:11 +0000 (17:15 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
rcuja/rcuja-range.c
tests/test_urcu_ja_range.c
urcu/rcuja-range.h

index faf60ce48feb86335a669d4de17973f2a2e93ad0..00d68befa20d35b552f314bc680a3a3de81a310d 100644 (file)
@@ -209,7 +209,7 @@ void rcu_free_range(struct cds_ja *ja, struct cds_ja_range *range)
                        free_range_cb);
 }
 
-struct cds_ja_range *cds_ja_range_add(struct cds_ja *ja,
+int cds_ja_range_add(struct cds_ja *ja,
                uint64_t start,         /* inclusive */
                uint64_t end,           /* inclusive */
                void *priv)
@@ -230,7 +230,7 @@ retry:
        old_range = caa_container_of(old_node, struct cds_ja_range, ja_node);
        switch (CMM_LOAD_SHARED(old_range->type)) {
        case CDS_JA_RANGE_ALLOCATED:
-               return NULL;
+               return -EEXIST;
        case CDS_JA_RANGE_FREE:
                break;
        case CDS_JA_RANGE_REMOVED:
@@ -245,7 +245,7 @@ retry:
                switch (CMM_LOAD_SHARED(old_range->type)) {
                case CDS_JA_RANGE_ALLOCATED:
                case CDS_JA_RANGE_FREE:         /* fall-through */
-                       return NULL;
+                       return -EEXIST;
                case CDS_JA_RANGE_REMOVED:
                        goto retry;
                }
@@ -315,7 +315,7 @@ retry:
 
        rcu_free_range(ja, old_range);
 
-       return new_range;
+       return 0;
 }
 
 int cds_ja_range_del(struct cds_ja *ja, struct cds_ja_range *range)
index b36e346af60eae81ea843373d35b01d9b5e10b84..ddd52dce71cd438b418db0a997c61303bdf26ed3 100644 (file)
@@ -296,9 +296,13 @@ void *test_ja_rw_thr_writer(void *_count)
                                end = tmp;
                        }
                        rcu_read_lock();
-                       range = cds_ja_range_add(test_ja, start, end, NULL);
-                       if (!range) {
-                               fprintf(stderr, "Error in cds_ja_range_add\n");
+                       ret = cds_ja_range_add(test_ja, start, end, NULL);
+                       if (ret) {
+                               if (ret == -EEXIST) {
+                                       URCU_TLS(nr_addexist)++;
+                               } else {
+                                       assert(0);
+                               }
                        } else {
                                URCU_TLS(nr_add)++;
                        }
@@ -371,13 +375,13 @@ int do_mt_populate_ja(void)
                key = (unsigned long) iter;
                key *= key_mul;
                rcu_read_lock();
-               range = cds_ja_range_add(test_ja, key, key, NULL);
+               ret = cds_ja_range_add(test_ja, key, key, NULL);
                URCU_TLS(nr_add)++;
                URCU_TLS(nr_writes)++;
                rcu_read_unlock();
-               if (!range) {
-                       fprintf(stderr, "Error adding range %" PRIu64 "\n",
-                               key);
+               if (ret) {
+                       fprintf(stderr, "Error (%d) adding range %" PRIu64 "\n",
+                               ret, key);
                        assert(0);
                }
        }
index a1ef3af0a3fbcf2b5c6354a7eb755aca44e550dd..feedc5b676cb86273200ab7f67d20b44904465e5 100644 (file)
@@ -38,7 +38,7 @@ struct cds_ja_range *cds_ja_range_lock(struct cds_ja_range *range);
 
 void cds_ja_range_unlock(struct cds_ja_range *range);
 
-struct cds_ja_range *cds_ja_range_add(struct cds_ja *ja,
+int cds_ja_range_add(struct cds_ja *ja,
                uint64_t start,         /* inclusive */
                uint64_t end,           /* inclusive */
                void *priv);
This page took 0.028516 seconds and 4 git commands to generate.