]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
- fixed the sort function to include the exsting data
authorAndrew Tridgell <tridge@samba.org>
Thu, 30 Nov 2006 22:02:17 +0000 (09:02 +1100)
committerAndrew Tridgell <tridge@samba.org>
Thu, 30 Nov 2006 22:02:17 +0000 (09:02 +1100)
- use numbers below 1000 in test code to make debug easier

- use ctdb_connect_wait()

(This used to be ctdb commit 216850e63e335de7d7cbe6c351d948bb8f1565e7)

ctdb/ctdb_test.c

index 452fa558b1f64f4fc615099680ce662c884f5a52..0d4df26f9f0b7600b99d632356106f5d5fe6b0c8 100644 (file)
@@ -50,10 +50,14 @@ static int sort_func(struct ctdb_call *call)
                return CTDB_ERR_NOMEM;
        }
        call->new_data->dsize = call->record_data.dsize + call->call_data->dsize;
+       memcpy(call->new_data->dptr,
+              call->record_data.dptr, call->record_data.dsize);
        memcpy(call->new_data->dptr+call->record_data.dsize,
               call->call_data->dptr, call->call_data->dsize);
+
        qsort(call->new_data->dptr, call->new_data->dsize / sizeof(int),
              sizeof(int), (comparison_fn_t)int_compare);
+
        return 0;
 }
 
@@ -156,21 +160,17 @@ int main(int argc, const char *argv[])
 
        /* start the protocol running */
        ret = ctdb_start(ctdb);
+
+       /* wait until all nodes are connected (should not be needed
+          outide of test code) */
+       ctdb_connect_wait(ctdb);
        
        key.dptr = "test";
        key.dsize = strlen("test")+1;
 
-
-#if 1
-       /* loop for testing */
-       while (1) {
-               event_loop_once(ev);
-       }
-#endif
-
        /* add some random data */
        for (i=0;i<100;i++) {
-               int v = random();
+               int v = random() % 1000;
                data.dptr = (uint8_t *)&v;
                data.dsize = sizeof(v);
                ret = ctdb_call(ctdb, key, FUNC_SORT, &data, NULL);