Skip to content

Add civetweb user-connection-data bindings to Http.alusus#8

Open
heshammahamed wants to merge 1 commit into
masterfrom
feature/civetweb-conn-userdata-bindings
Open

Add civetweb user-connection-data bindings to Http.alusus#8
heshammahamed wants to merge 1 commit into
masterfrom
feature/civetweb-conn-userdata-bindings

Conversation

@heshammahamed

Copy link
Copy Markdown
Contributor

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_data
  • getUserConnectionData → mg_get_user_connection_data

These 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

@heshammahamed heshammahamed requested a review from sarmadka July 5, 2026 22:53
Comment thread بـننت.أسس

عرف اتـصال: لقب Connection؛

عرف عين_بيانات_إتصال_المستخدم: لقب setUserConnectionData؛

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

هل يمكن تغيير هذه إلى حدد_بيانات_إتصال_المستخدم، أي استخدام المصطلح "حدد" بدل "عين" كترجمة لset كي تكون متوافقة مع الترجمات في المكتبات الأخرى؟
عموما نحن نترجم "حدد" إلى set و "عين" إلى assign.

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.

2 participants