diff --git a/platform/include/internal/proxy.h b/platform/include/internal/proxy.h index d5cbab5..8257c0d 100644 --- a/platform/include/internal/proxy.h +++ b/platform/include/internal/proxy.h @@ -177,6 +177,7 @@ struct tfe_proxy }; extern struct tfe_proxy * g_default_proxy; +extern int worker_thread_ready; #define TFE_PROXY_STAT_INCREASE(field, val) \ do { __atomic_fetch_add(&g_default_proxy->stat_val[field], val, __ATOMIC_RELAXED); } while(0) diff --git a/platform/src/acceptor_kni_v4.cpp b/platform/src/acceptor_kni_v4.cpp index 05e5d43..18902ba 100644 --- a/platform/src/acceptor_kni_v4.cpp +++ b/platform/src/acceptor_kni_v4.cpp @@ -93,15 +93,19 @@ static void *worker_thread_cycle(void *arg) void * logger = thread_ctx->logger; int pkg_len = 0; - char thread_name[32]; + char thread_name[16]; int n_pkt_recv_from_nf = 0; int n_pkt_recv_from_tap = 0; int n_pkt_recv_from_tap_c = 0; int n_pkt_recv_from_tap_s = 0; - snprintf(thread_name, sizeof(thread_name), "packet-io:worker-%d", thread_ctx->thread_index); + snprintf(thread_name, sizeof(thread_name), "pkt:worker-%d", thread_ctx->thread_index); prctl(PR_SET_NAME, (unsigned long long)thread_name, NULL, NULL, NULL); + while (!worker_thread_ready) { + sleep(1); + } + if (packet_io_thread_init(handle, thread_ctx, logger) != 0) { goto error_out; diff --git a/platform/src/proxy.cpp b/platform/src/proxy.cpp index 1a2cac4..7c57f99 100644 --- a/platform/src/proxy.cpp +++ b/platform/src/proxy.cpp @@ -72,6 +72,7 @@ static int signals[] = {SIGHUP, SIGPIPE, SIGUSR1, SIGUSR2}; void * g_default_logger = NULL; struct tfe_proxy * g_default_proxy = NULL; bool g_print_to_stderr = true; +int worker_thread_ready = 0; /* Per thread resource */ thread_local unsigned int __currect_thread_id = 0; @@ -749,6 +750,7 @@ int main(int argc, char * argv[]) g_print_to_stderr = false; sleep(1); } + worker_thread_ready = 1; event_base_dispatch(g_default_proxy->evbase); return 0;