#define WORKER_VERIFY
#endif
+static _Thread_local fr_worker_t *thread_local_worker;
/**
* A worker which takes packets from a master, and processes them.
fr_channel_responder_ack_close(worker->channel[i]);
}
+
+ thread_local_worker = NULL;
talloc_free(worker);
}
goto fail;
}
+ thread_local_worker = worker;
+
return worker;
}
worker_run_request(worker, fr_time()); /* Event loop time can be too old, and trigger asserts */
}
+/** Asynchronously add a REQUEST to a worker thread
+ *
+ * When we don't know what the worker is...
+ */
+int fr_worker_request_add(REQUEST *request, module_method_t process, void *ctx)
+{
+ fr_worker_t *worker;
+ fr_time_t now;
+
+ if (!request || !process) {
+ fr_strerror_printf("Invalid arguments");
+ return -1;
+ }
+ worker = thread_local_worker;
+ if (!worker) {
+ fr_strerror_printf("No worker has been defined");
+ return -1;
+ }
+
+ now = fr_time();
+
+ worker_request_init(worker, request, now);
+
+ request->async->fake = true;
+ request->async->process = process;
+ request->async->process_inst = ctx;
+
+ worker_request_time_tracking_start(worker, request, now);
+
+ return 0;
+}
/** Print debug information about the worker structure
*
fr_channel_t *fr_worker_channel_create(fr_worker_t *worker, TALLOC_CTX *ctx, fr_control_t *master) CC_HINT(nonnull);
int fr_worker_stats(fr_worker_t const *worker, int num, uint64_t *stats) CC_HINT(nonnull);
+
+/*
+ * From src/lib/server/module.h. Copied here as that file
+ * includes schedule.h, which includes this file. But that
+ * inclusion is done before module_method_t is defined. So we
+ * just copy it for simplicity.
+ */
+typedef rlm_rcode_t (*module_method_t)(void *instance, void *thread, REQUEST *request);
+
+int fr_worker_request_add(REQUEST *request, module_method_t process, void *ctx);
+
#ifdef __cplusplus
}
#endif