{
struct thread_table_field *ptr = NULL;
- // TODO: Is this needed?
- if (g_thread_table == NULL)
- return 0;
-
hash_for_each_possible(g_thread_table->data, ptr, next, tid) {
if (ptr->tid == tid && ptr->is_stdout == is_stdout)
return ptr->blk;
{
struct thread_table_field *ptr = NULL;
- // TODO: Is this needed?
- if (g_thread_table == NULL)
- return;
-
hash_for_each_possible(g_thread_table->data, ptr, next, tid) {
if (ptr->tid == tid && ptr->is_stdout == is_stdout) {
ptr->blk = blk;
static int zlog_task(void *user_data)
{
- int i;
- int is_stdout;
- uint16_t blk;
+ struct thread_table_field *ptr = NULL;
+ struct hlist_node *tmp_iter = NULL;
+ int tmp_bkt;
+ int blk;
do {
- // TODO: Consider hash_for_each_safe
- for (i = 1; i <= g_max_thread_id; i++) {
- for (is_stdout = 0; is_stdout <= 1; ++is_stdout) {
- blk = get_thread_table(i, is_stdout);
- // TODO: g_start_time should be under some kind of mutex.
- if (blk && get_block(blk)->head.ts < g_start_time) {
- mutex_lock(&g_block_mutex);
- get_block(blk)->head.tid = 0;
- queue_push(&g_free_q, blk);
- set_thread_table(i, is_stdout, 0);
- // TODO: The userspace might very well be using this block right now.
- mutex_unlock(&g_block_mutex);
- g_free_count++;
- }
+
+ hash_for_each_safe(g_thread_table->data, tmp_bkt, tmp_iter, ptr, next) {
+ blk = ptr->blk;
+ // TODO: g_start_time should be under some kind of mutex.
+ if (blk && get_block(blk)->head.ts < g_start_time) {
+ mutex_lock(&g_block_mutex);
+ get_block(blk)->head.tid = 0;
+ queue_push(&g_free_q, blk);
+ ptr->blk = 0;
+ // TODO: The userspace might very well be using this block right now.
+ mutex_unlock(&g_block_mutex);
+ g_free_count++;
}
}