Skip to content

[WIP] add server-side C API#2807

Closed
lucifer1004 wants to merge 2 commits into
hyperium:masterfrom
lucifer1004:c-api-server
Closed

[WIP] add server-side C API#2807
lucifer1004 wants to merge 2 commits into
hyperium:masterfrom
lucifer1004:c-api-server

Conversation

@lucifer1004
Copy link
Copy Markdown

@lucifer1004 lucifer1004 commented Apr 6, 2022

Related to #2797. The API can be called but does not really work yet.

Since I am not yet familiar with the whole project, I would like to hear more advice from the community, especially those who previously worked on the C API.

@lucifer1004
Copy link
Copy Markdown
Author

@seanmonstar

Copy link
Copy Markdown
Member

@seanmonstar seanmonstar left a comment

Choose a reason for hiding this comment

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

Thanks for submitting this, this looks like a nice start! I left some comments inline to continue the discussion. <3

Comment thread src/ffi/server.rs
use super::io::hyper_io;
use super::task::{hyper_executor, hyper_task, WeakExec};

pub struct hyper_http(Http<WeakExec>);
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.

You couldn't know this, but I'm not a fan of the name that's currently Http in hyper. I think this C API type might want to follow the client-side naming, so maybe hyper_serverconn_options? And then similarly with the related functions.

Comment thread src/ffi/server.rs
}

type hyper_service_callback =
extern "C" fn(*mut c_void, *mut hyper_request, *mut hyper_response) -> ();
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.

So, it looks like this would require that in C, the callback is synchronous. It must return a response, it can't return a future. I worry that this might make servers in C just do everything in a blocking style, which would be bad for the server.

Would it be hard to have this callback return a *mut hyper_task? I haven't thought too hard about it

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