Skip to content

Conversation

zenyanle
Copy link
Member

#772

给这个PR提供了一个解决方案,eventWorker拥有了两套生命周期设计

1.默认的定时器销毁设计

2.外部调用销毁设计

在上述PR中,为了从sock定位到对应eventWorker,可以先遍历队列,找到GetLifeCycleState()返回为LifeCycleStateSocket的worker,然后再从UUID来取出sock字段

但是有个缺点,CheckLifeCycleState(uuid string) LifeCycleState函数的设计沿用了原PR的GetSock设计,由UUID要素数量来判断是否来自SSLDataEvent,可能不是最健壮的方式

@dosubot dosubot bot added the enhancement New feature or request label May 28, 2025
@cfc4n cfc4n requested a review from Copilot May 28, 2025 15:42
@cfc4n cfc4n self-assigned this May 28, 2025
Copilot

This comment was marked as outdated.

@zenyanle
Copy link
Member Author

@chilli13 Can you help test this PR?

@cfc4n
Copy link
Member

cfc4n commented May 30, 2025

@chilli13 Can you verify this PR? Does it solve the issue of events being split?

@chilli13
Copy link
Contributor

chilli13 commented Jun 3, 2025

@chilli13 Can you verify this PR? Does it solve the issue of events being split?
No, this pr is incomplete, the issue #744 has not been completely solved
@zenyanle 这个PR只是引入LifeCycleState 决定何时destroy_ework, 但没有提供destroy socket 通知ework 以及hpack的复用,没有直接修复问题

@zenyanle
Copy link
Member Author

zenyanle commented Jun 3, 2025

@chilli13 Can you verify this PR? Does it solve the issue of events being split?
No, this pr is incomplete, the issue #744 has not been completely solved
@zenyanle 这个PR只是引入LifeCycleState 决定何时destroy_ework, 但没有提供destroy socket 通知ework 以及hpack的复用,没有直接修复问题

是的,这只是提供了一个eventWorker的抽象方式,使其在工程上更合理

@zenyanle
Copy link
Member Author

zenyanle commented Jun 3, 2025

@chilli13 如果这解决了你的一部分问题,我可以直接推送到你的分支上面吗

@chilli13
Copy link
Contributor

chilli13 commented Jun 4, 2025

感觉UUIDSSLDataCount 的定义不是很合理,只通过count == 7 判断包含socket 来决定LifeCycleState 的状态会让人迷惑,是否可以通过增加一个字段了识别event类型来决定使用哪种LifeCycleState ?
如果@cfc4n 认为这个pr是合理的,可以合入master后,我重新提交一个基于新代码的hpack复用的pr

@zenyanle
Copy link
Member Author

zenyanle commented Jun 4, 2025

我尝试看看再优化下

@zenyanle zenyanle force-pushed the refractor/eventWorker branch from 94b1f2d to dfb6f47 Compare June 5, 2025 05:09
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 5, 2025
@zenyanle
Copy link
Member Author

zenyanle commented Jun 5, 2025

改为了前缀判断逻辑

@zenyanle
Copy link
Member Author

zenyanle commented Jun 5, 2025

直接合并会导致现有逻辑无法正常工作,可以把 uuid 改为原本格式再合并

@cfc4n
Copy link
Member

cfc4n commented Jun 5, 2025

近期工作比较忙,周末我review一下。感谢

@cfc4n cfc4n requested a review from Copilot June 6, 2025 15:02
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces dual lifecycle management for eventWorker, allowing workers to be cleaned up either by an internal timer or via an external socket-driven signal.

  • Changed UUID delimiter in TcSkbEvent to underscores for consistency.
  • Added SocketLifecycleUUIDPrefix and updated ConnDataEvent.GetUUID to optionally prefix socket-bound UUIDs.
  • Extended eventWorker with a LifeCycleState, closeChan, and new methods to support external shutdown, and updated the run loop to respect both timer and external signals.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
user/event/event_openssl_tc.go Updated GetUUID delimiter from “-” to “_forTcSkbEvent`.
user/event/event_openssl.go Introduced SocketLifecycleUUIDPrefix and commented socket-prefixed UUID in ConnDataEvent.
pkg/event_processor/iworker.go Implemented LifeCycleState, added closeChan, CheckLifeCycleState, CloseEventWorker, GetLifeCycleState, and modified Run to handle socket-driven closure.
Comments suppressed due to low confidence (4)

user/event/event_openssl.go:33

  • [nitpick] This string constant is declared alongside AttachType enum values, mixing distinct types. Consider moving SocketLifecycleUUIDPrefix into its own const block or a clearly labeled grouping to avoid confusion.
SocketLifecycleUUIDPrefix = "sock"

user/event/event_openssl_tc.go:93

  • Changing the UUID delimiter from - to _ is a breaking change for any consumers parsing the old format. Ensure this is documented in release notes and update any dependent code to use the new format.
return fmt.Sprintf("%d_%d_%s", te.Pid, te.Ifindex, te.Comm)

pkg/event_processor/iworker.go:119

  • There are no tests covering the new external-close lifecycle (CloseEventWorker, closeChan, and LifeCycleStateSocket). Adding unit tests for both default timer shutdown and socket-driven shutdown would ensure this behavior remains correct.
func (ew *eventWorker) CloseEventWorker() {

pkg/event_processor/iworker.go:111

  • The code references event.SocketLifecycleUUIDPrefix but the event package isn’t imported, which will cause a compile error. Please add the correct import for the user/event package (or adjust the alias) so this line resolves.
if strings.HasPrefix(uuid, event.SocketLifecycleUUIDPrefix) {

Copy link
Member

@cfc4n cfc4n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

抱歉,最近生病了,一直没精力看PR。

刚做了回复,辛苦修改一下,谢谢。

@@ -30,6 +30,7 @@ type AttachType int64
const (
ProbeEntry AttachType = iota
ProbeRet
SocketLifecycleUUIDPrefix = "sock"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SocketLifecycleUUIDPrefix放到ievent.go里更合适。

// 导出方法,用于发送信号量
func (ew *eventWorker) CloseEventWorker() {
if ew.closeChan != nil {
close(ew.closeChan)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zenyanle 看看这个?

@zenyanle
Copy link
Member Author

抱歉,最近生病了,一直没精力看PR。

刚做了回复,辛苦修改一下,谢谢。

我已经做了修改,希望您多保重身体,感谢回复

@zenyanle zenyanle requested a review from cfc4n June 10, 2025 08:26
Copy link
Member

@cfc4n cfc4n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 10, 2025
@cfc4n cfc4n merged commit 9f1bb25 into gojue:master Jun 10, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants