Prechádzať zdrojové kódy

Fix debug flags; minor docstring fixes.

scossu 17 hodín pred
rodič
commit
1e749950d9
3 zmenil súbory, kde vykonal 25 pridanie a 19 odobranie
  1. 1 1
      include/lsup/graph.h
  2. 3 2
      src/codec/Makefile
  3. 21 16
      src/store_mdb.c

+ 1 - 1
include/lsup/graph.h

@@ -54,7 +54,7 @@ LSUP_graph_new (LSUP_Store *store, const char *uri_str, LSUP_NSMap *nsm);
  * @param[in] txn Transaction handle. If not `NULL`, new child transaction will
  *  be opened under the one provided.
  *
- * @param[in] store Back end store handle. The store must exist.
+ * @param[in] store Back end store handle.
  *
  * @param[in] uri URI of the graph to retrieve.
  *

+ 3 - 2
src/codec/Makefile

@@ -23,8 +23,9 @@ DBG_OBJ = $(OBJ:%.o=%_dbg.o)
 
 INCLUDE := -I$(INCLUDE_DIR) -I../../ext/tpl/src -I../../ext/hashmap \
 	-I../../ext/log/src
-CFLAGS := -std=gnu11 -Wall -fPIC $(INCLUDE)
-DBG_CFLAGS := $(CFLAGS) -I../../test -O0 -g3 -DDEBUG
+_CFLAGS := -std=gnu11 -Wall -fPIC $(INCLUDE)
+CFLAGS := $(_CFLAGS) -O3
+DBG_CFLAGS := $(_CFLAGS) -I../../test -O0 -g3 -DDEBUG
 
 .DEFAULT_GOAL := codec
 

+ 21 - 16
src/store_mdb.c

@@ -741,10 +741,6 @@ mdbiter_next_key (MDBIterator *it)
      * it->rc is set to the result of the next iteration.
      */
     it->iter_op_fn (it);
-    LOG_TRACE(
-            "Found  spok: {%lx, %lx, %lx}",
-            it->spok[0], it->spok[1], it->spok[2]);
-
     MDB_val key, data;
     int db_rc;
 
@@ -753,25 +749,29 @@ mdbiter_next_key (MDBIterator *it)
     data.mv_size = KLEN;
 
     if (it->luc) {
-        rc = LSUP_NORESULT;  // Intermediary value, will never be returned.
-
-        while (rc == LSUP_NORESULT) {
+        rc = LSUP_NORESULT;  // Flow control value, will never be returned.
+        do {
             //LOG_DEBUG("begin ctx loop.");
-            // If ctx is specified, look if the matching triple is associated
-            // with it. If not, move on to the next triple.
-            // The loop normally exits when a triple with matching ctx is found
-            // (LSUP_OK), if there are no more triples (LSUP_END), or if there
-            // is an error (LSUP_DB_ERR).
+            /* If ctx is specified, look if the matching triple is associated
+             * with it. If not, move on to the next triple.
+             * The loop normally exits when a triple with matching ctx is found
+             * (LSUP_OK), if there are no more triples (LSUP_END), or if there
+             * is an error (LSUP_DB_ERR).
+             */
+            LOG_TRACE (
+                    "Found spok: {%lx, %lx, %lx}",
+                    it->spok[0], it->spok[1], it->spok[2]);
+
             key.mv_data = it->spok;
 
             db_rc = mdb_cursor_get (it->ctx_cur, &key, &data, MDB_GET_BOTH);
 
             if (db_rc == MDB_SUCCESS) {
                 rc = LSUP_OK;
-                LOG_TRACE("Triple found for context.");
+                LOG_TRACE("Triple found in context: %x", it->luc);
 
             } else if (db_rc == MDB_NOTFOUND) {
-                LOG_TRACE("No triples found for context: %x", it->luc);
+                LOG_TRACE("Triple not found in context: %x", it->luc);
                 if (it->rc == MDB_NOTFOUND) rc = LSUP_END;
                 else it->iter_op_fn (it);
 
@@ -779,10 +779,15 @@ mdbiter_next_key (MDBIterator *it)
                 log_error ("Database error: %s", LSUP_strerror (db_rc));
                 rc = LSUP_DB_ERR;
             }
+        } while (rc == LSUP_NORESULT);
 
-        }
+    } else {
+        LOG_TRACE (
+                "Found spok in any context: {%lx, %lx, %lx}",
+                it->spok[0], it->spok[1], it->spok[2]);
 
-    } else rc = LSUP_OK;
+        rc = LSUP_OK;
+    }
 
     // Get all contexts for a triple.
     key.mv_data = it->spok;