Skip to content

Commit

Permalink
Implement SSL child socket contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
uNetworkingAB committed Aug 28, 2018
1 parent 4d9c3fd commit a250273
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/interfaces/ssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ WIN32_EXPORT struct us_ssl_socket *us_ssl_socket_context_adopt_socket(struct us_

/* Create a child socket context which acts much like its own socket context with its own callbacks yet still relies on the
* parent socket context for some shared resources. Child socket contexts should be used together with socket adoptions and nothing else. */
WIN32_EXPORT struct us_ssl_socket_context *us_create_child_ssl_socket_context(struct us_ssl_socket_context *context);
WIN32_EXPORT struct us_ssl_socket_context *us_create_child_ssl_socket_context(struct us_ssl_socket_context *context, int context_ext_size);

WIN32_EXPORT struct us_loop *us_ssl_socket_context_loop(struct us_ssl_socket_context *context);

Expand Down
15 changes: 10 additions & 5 deletions src/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,15 @@ void us_internal_free_loop_ssl_data(struct us_loop *loop) {
}

/* Per-context functions */
struct us_ssl_socket_context *us_create_child_ssl_socket_context(struct us_ssl_socket_context *context, int context_ext_size) {
struct us_ssl_socket_context *child_context = (struct us_ssl_socket_context *) us_create_socket_context(context->sc.loop, sizeof(struct us_ssl_socket_context) + context_ext_size);

// I think this is the only thing being shared
child_context->ssl_context = context->ssl_context;

return child_context;
}

struct us_ssl_socket_context *us_create_ssl_socket_context(struct us_loop *loop, int context_ext_size, struct us_ssl_socket_context_options options) {

us_internal_init_loop_ssl_data(loop);
Expand Down Expand Up @@ -442,11 +451,7 @@ struct us_ssl_socket *us_ssl_socket_context_adopt_socket(struct us_ssl_socket_co
return s;
}

struct us_ssl_socket_context *us_create_child_ssl_socket_context(struct us_ssl_socket_context *context) {
return context;
}

struct us_loop *us_ssl_socket_context_loop(struct us_ssl_socket_context *context, int context_ext_size) {
struct us_loop *us_ssl_socket_context_loop(struct us_ssl_socket_context *context) {
return context->sc.loop;
}

Expand Down

0 comments on commit a250273

Please sign in to comment.