summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwangmenglan <[email protected]>2023-05-31 19:41:18 +0800
committerwangmenglan <[email protected]>2023-05-31 20:17:22 +0800
commit0973d8c35a57bfcb8044b18d5dd674657d0a159a (patch)
tree030525c5a6f18347a840445f17ee251d9c3c400d
parent657456627667239d2ee1b0983fbe7f46cd577032 (diff)
🐞 fix(TSG-15308): 修复packet io thread启动时,intercept_policy_enforcer为空导致corev4.8.19-20230602
-rw-r--r--platform/include/internal/proxy.h1
-rw-r--r--platform/src/acceptor_kni_v4.cpp8
-rw-r--r--platform/src/proxy.cpp2
3 files changed, 9 insertions, 2 deletions
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;