struct ctdb_persistent_state *state;
int i;
- state = talloc_zero(c, struct ctdb_persistent_state);
+ state = talloc_zero(ctdb, struct ctdb_persistent_state);
CTDB_NO_MEMORY(ctdb, state);
state->ctdb = ctdb;
ret = ctdb_persistent_store(state);
ctdb_request_control_reply(state->ctdb_db->ctdb, state->c, NULL, ret, NULL);
tdb_chainlock_unmark(state->tdb, state->key);
+
+ talloc_free(state);
}
/*
talloc_free(state);
}
-
/*
update a record on this node if the new record has a higher rsn than the
current record
struct ctdb_rec_data *rec = (struct ctdb_rec_data *)&recdata.dptr[0];
struct ctdb_db_context *ctdb_db;
uint32_t db_id = rec->reqid;
- struct lockwait_handle *handle;
struct ctdb_persistent_lock_state *state;
+ struct lockwait_handle *handle;
if (ctdb->recovery_mode != CTDB_RECOVERY_NORMAL) {
DEBUG(DEBUG_DEBUG,("rejecting ctdb_control_update_record when recovery active\n"));
return -1;
}
- state = talloc(c, struct ctdb_persistent_lock_state);
+ state = talloc(ctdb, struct ctdb_persistent_lock_state);
CTDB_NO_MEMORY(ctdb, state);
state->ctdb_db = ctdb_db;
if (state->data.dsize < sizeof(struct ctdb_ltdb_header)) {
DEBUG(DEBUG_CRIT,("Invalid data size %u in ctdb_control_update_record\n",
(unsigned)state->data.dsize));
+ talloc_free(state);
return -1;
}
if (ret == 0) {
ret = ctdb_persistent_store(state);
tdb_chainunlock(state->tdb, state->key);
+ talloc_free(state);
return ret;
}
#endif
handle = ctdb_lockwait(ctdb_db, state->key, ctdb_persistent_lock_callback, state);
if (handle == NULL) {
DEBUG(DEBUG_ERR,("Failed to setup lockwait handler in ctdb_control_update_record\n"));
+ talloc_free(state);
return -1;
}
+ /* we need to wait for the replies */
*async_reply = true;
- event_add_timed(ctdb->ev, state, timeval_current_ofs(ctdb->tunable.control_timeout, 0),
+ /* need to keep the control structure around */
+ talloc_steal(state, c);
+
+ /* but we won't wait forever */
+ event_add_timed(ctdb->ev, state, timeval_current_ofs(3, 0),
ctdb_persistent_lock_timeout, state);
return 0;