Skip to content

Added IDs to web request to prevent incompatibilities between web mods #1040

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 13, 2024
Merged

Added IDs to web request to prevent incompatibilities between web mods #1040

merged 2 commits into from
Aug 13, 2024

Conversation

SMJSGaming
Copy link
Contributor

Currently web mods need to check for pointers to prevent hook recursion. But to prevent the request from being thrown out you also need to copy it. This makes it so there can never be 2 web mods active at the same time.

WebRequest::WebRequest() : m_impl(std::make_shared<Impl>()) {}
size_t WebRequest::m_idCounter = 0;

WebRequest::WebRequest() : m_impl(std::make_shared<Impl>()), m_id(WebRequest::m_idCounter++) {}
Copy link
Member

Choose a reason for hiding this comment

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

This is a race condition, WebRequests aren't necessarily created in the same thread

@@ -112,8 +112,9 @@ namespace geode::utils::web {
private:
class Impl;

static size_t m_idCounter;
Copy link
Member

Choose a reason for hiding this comment

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

This should be atomic_size_t

Copy link
Member

Choose a reason for hiding this comment

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

and also static members should be prefixed with s_ not m_

@HJfod HJfod merged commit 00e191a into geode-sdk:main Aug 13, 2024
5 checks passed
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