Skip to content

add per-client close hook#47

Open
tyr1k wants to merge 1 commit intovjeantet:masterfrom
tyr1k:feat/client-close-hook
Open

add per-client close hook#47
tyr1k wants to merge 1 commit intovjeantet:masterfrom
tyr1k:feat/client-close-hook

Conversation

@tyr1k
Copy link
Copy Markdown

@tyr1k tyr1k commented Apr 10, 2026

This PR adds an optional per-client close hook for deterministic cleanup of connection-scoped resources.

Why:
ldapserver already supports per-connection state via SetData / GetData, but there is currently no explicit callback when a frontend client session ends. In proxy scenarios this makes backend resource cleanup indirect and timing-dependent.

What:

  • add Server.OnClientClose
  • invoke it once during client.close()
  • pass the frontend net.Conn and client-scoped data
  • call the hook after request processing/output shutdown and before closing the frontend connection
  • recover from hook panic so server shutdown is not blocked

Tests:

  • hook fires on LDAP Unbind
  • hook fires on abrupt TCP disconnect
  • hook receives data set through SetData
  • hook runs once per client lifecycle
  • panic inside hook does not break Stop()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant