Skip to content
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

Posix net.hpp refactor for reference #96

Closed
wants to merge 3 commits into from

Conversation

MarkReedZ
Copy link
Contributor

My thought for the refactor was to create a net.hpp ( later net-uring.hpp / net-posix.hpp ) to handle the networking using a common engine.cpp. This is a prototype for the posix engine only. Not expected to be merged though tests pass and python works though I didn't add python tests.

net_init is called passing an on_data function.

  fd = net_init(config, on_data);

 int on_data(conn_t *conn, char *buf, int data_left) {
    engine_t& engine = *reinterpret_cast<engine_t*>(conn->user_data);

Interesting things:

  • Posix now handles large requests > 4096 and partial requests. In the on_data function you return the data left after parsing and the next on_data call will contain the remaining + new data.
  • I use a map for the callbacks. I updated engine-uring.cpp with this so you can see it below
  • We detect json by looking at the first character and handle json and http separately
  • take_call is not supported so python uses take_calls

@MarkReedZ MarkReedZ closed this May 13, 2024
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