Add civetweb user-connection-data bindings to Http.alusus#8
Open
heshammahamed wants to merge 1 commit into
Open
Add civetweb user-connection-data bindings to Http.alusus#8heshammahamed wants to merge 1 commit into
heshammahamed wants to merge 1 commit into
Conversation
sarmadka
reviewed
Jul 8, 2026
|
|
||
| عرف اتـصال: لقب Connection؛ | ||
|
|
||
| عرف عين_بيانات_إتصال_المستخدم: لقب setUserConnectionData؛ |
Member
There was a problem hiding this comment.
هل يمكن تغيير هذه إلى حدد_بيانات_إتصال_المستخدم، أي استخدام المصطلح "حدد" بدل "عين" كترجمة لset كي تكون متوافقة مع الترجمات في المكتبات الأخرى؟
عموما نحن نترجم "حدد" إلى set و "عين" إلى assign.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
WebPlatform currently tracks the mapping between a raw connection
pointer and its WsConnection object (the object handed to the user
for each WebSocket connection) using a shared Map. Civetweb runs each
connection's callbacks on that connection's own dedicated thread for
its entire lifetime, so different connections' ready/data/close
handlers run concurrently on different threads — meaning this shared
Map is read and written from multiple threads at once, which make a race condition.
What this PR does
Adds two new bindings in Http.alusus:
setUserConnectionData→ mg_set_user_connection_datagetUserConnectionData→ mg_get_user_connection_dataThese let civetweb store a per-connection pointer directly on the
connection object itself. Since each connection is handled by its own
dedicated thread for its whole life, this per-connection data is only
ever touched by that one thread — so no lock needed.
This will let us map each connection directly to its WsConnection
without a shared Map at all.
References