Add name parameter to uasync_set_timeout for timer identification in dumps
This commit is contained in:
1 parent
3c0b5f501a
commit
d74ab1c1c6
28 files changed
+102
-93
No files matched your search
+20
-12
@@ -32,6 +32,7 @@
|
||||
|
||||
// Timeout node with safe cancellation
|
||||
struct timeout_node {
|
||||
char name[16];
|
||||
void* arg;
|
||||
timeout_callback_t callback;
|
||||
uint64_t expiration_ms; // absolute expiration time in milliseconds
|
||||
@@ -491,22 +492,28 @@ static void get_next_timeout(struct UASYNC* ua, struct timeval* tv) {
|
||||
|
||||
|
||||
|
||||
// Instance version
|
||||
void* uasync_set_timeout(struct UASYNC* ua, int timeout_tb, void* arg, timeout_callback_t callback) {
|
||||
if (!ua || timeout_tb < 0 || !callback) return NULL;
|
||||
if (!ua->timeout_heap) return NULL;
|
||||
|
||||
// DEBUG_DEBUG(DEBUG_CATEGORY_TIMERS, "uasync_set_timeout: timeout=%d.%d ms, arg=%p, callback=%p", timeout_tb/10, timeout_tb%10, arg, callback);
|
||||
|
||||
// Instance version
|
||||
void* uasync_set_timeout(struct UASYNC* ua, int timeout_tb, void* arg, timeout_callback_t callback, const char* name) {
|
||||
if (!ua || timeout_tb < 0 || !callback) return NULL;
|
||||
if (!ua->timeout_heap) return NULL;
|
||||
|
||||
// DEBUG_DEBUG(DEBUG_CATEGORY_TIMERS, "uasync_set_timeout: timeout=%d.%d ms, arg=%p, callback=%p", timeout_tb/10, timeout_tb%10, arg, callback);
|
||||
|
||||
struct timeout_node* node = memory_pool_alloc(ua->timeout_pool);
|
||||
if (!node) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_TIMERS, "uasync_set_timeout: failed to allocate node");
|
||||
return NULL;
|
||||
}
|
||||
ua->timer_alloc_count++;
|
||||
|
||||
node->arg = arg;
|
||||
node->callback = callback;
|
||||
}
|
||||
ua->timer_alloc_count++;
|
||||
|
||||
if (name) {
|
||||
strncpy(node->name, name, sizeof(node->name) - 1);
|
||||
node->name[sizeof(node->name) - 1] = '\0';
|
||||
} else {
|
||||
node->name[0] = '\0';
|
||||
}
|
||||
node->arg = arg;
|
||||
node->callback = callback;
|
||||
node->ua = ua;
|
||||
|
||||
// Calculate expiration time in milliseconds
|
||||
@@ -538,6 +545,7 @@ void* uasync_call_soon(struct UASYNC* ua, void* user_arg, timeout_callback_t cal
|
||||
}
|
||||
ua->timer_alloc_count++;
|
||||
|
||||
node->name[0] = '\0';
|
||||
node->arg = user_arg;
|
||||
node->callback = callback;
|
||||
node->ua = ua;
|
||||
|
||||
Reference in new issue
Block a user