- h = ctdb_fetch_lock(ctdb_db, tmp_ctx, key, &data);
- if (h == NULL) {
- printf("Failed to fetch record '%s' on node %d\n",
- (const char *)key.dptr, ctdb_get_pnn(ctdb));
- talloc_free(tmp_ctx);
+ /* In the non-contended case the callback might be invoked
+ * immediately, before ctdb_readrecordlock_async() returns.
+ * In the contended case the callback will be invoked later.
+ *
+ * Normally an application would not care whether the callback
+ * has already been invoked here or not, but if the application
+ * needs to know, it can use the *private_data pointer
+ * to pass data through to the callback and back.
+ */
+ if (!ctdb_readrecordlock_async(ctdb_db, key,
+ rrl_cb, &rrl_cb_finished)) {
+ printf("Failed to send READRECORDLOCK\n");