static bool lu_check_lu_allowed(void)
{
- return true;
+ struct connection *conn;
+ time_t now = time(NULL);
+ unsigned int ta_total = 0, ta_long = 0;
+
+ list_for_each_entry(conn, &connections, list) {
+ if (conn->ta_start_time) {
+ ta_total++;
+ if (conn->ta_start_time - now >= lu_status->timeout)
+ ta_long++;
+ }
+ }
+
+ return ta_total ? (lu_status->force && ta_long == ta_total) : true;
}
static const char *lu_reject_reason(const void *ctx)
{
- return "BUSY";
+ char *ret = NULL;
+ struct connection *conn;
+ time_t now = time(NULL);
+
+ list_for_each_entry(conn, &connections, list) {
+ if (conn->ta_start_time - now >= lu_status->timeout) {
+ ret = talloc_asprintf(ctx, "%s\nDomain %u: %ld s",
+ ret ? : "Domains with long running transactions:",
+ conn->id,
+ conn->ta_start_time - now);
+ }
+ }
+
+ return ret ? (const char *)ret : "Overlapping transactions";
}
static const char *lu_dump_state(const void *ctx, struct connection *conn)
struct list_head transaction_list;
uint32_t next_transaction_id;
unsigned int transaction_started;
+ time_t ta_start_time;
/* List of delayed requests. */
struct list_head delayed;
list_add_tail(&trans->list, &conn->transaction_list);
talloc_steal(conn, trans);
talloc_set_destructor(trans, destroy_transaction);
+ if (!conn->transaction_started)
+ conn->ta_start_time = time(NULL);
conn->transaction_started++;
wrl_ntransactions++;
conn->transaction = NULL;
list_del(&trans->list);
conn->transaction_started--;
+ if (!conn->transaction_started)
+ conn->ta_start_time = 0;
/* Attach transaction to in for auto-cleanup */
talloc_steal(in, trans);
assert(conn->transaction == NULL);
conn->transaction_started = 0;
+ conn->ta_start_time = 0;
}
int check_transactions(struct hashtable *hash)