1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

plat combine inits into single lws_plat_init and provide info

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2015-12-10 07:14:16 +08:00
parent 4fee9de6bc
commit 4386e36b0b
5 changed files with 9 additions and 30 deletions

View file

@ -157,10 +157,7 @@ lws_create_context(struct lws_context_creation_info *info)
goto bail;
}
if (lws_plat_init_lookup(context))
goto bail;
if (lws_plat_init_fd_tables(context))
if (lws_plat_init(context, info))
goto bail;
lws_context_init_extensions(info, context);

View file

@ -106,16 +106,9 @@ lws_plat_drop_app_privileges(struct lws_context_creation_info *info)
}
LWS_VISIBLE int
lws_plat_init_lookup(struct lws_context *context)
lws_plat_init(struct lws_context *context,
struct lws_context_creation_info *info)
{
(void)context;
return 0;
}
LWS_VISIBLE int
lws_plat_init_fd_tables(struct lws_context *context)
{
(void)context;
return 0;
}

View file

@ -272,7 +272,8 @@ lws_plat_drop_app_privileges(struct lws_context_creation_info *info)
}
LWS_VISIBLE int
lws_plat_init_lookup(struct lws_context *context)
lws_plat_init(struct lws_context *context,
struct lws_context_creation_info *info)
{
context->lws_lookup = lws_zalloc(sizeof(struct lws *) * context->max_fds);
if (context->lws_lookup == NULL) {
@ -282,12 +283,6 @@ lws_plat_init_lookup(struct lws_context *context)
return 1;
}
return 0;
}
LWS_VISIBLE int
lws_plat_init_fd_tables(struct lws_context *context)
{
context->fd_random = open(SYSTEM_RANDOM_FILEPATH, O_RDONLY);
if (context->fd_random < 0) {
lwsl_err("Unable to open random device %s %d\n",

View file

@ -257,7 +257,8 @@ lws_plat_drop_app_privileges(struct lws_context_creation_info *info)
}
LWS_VISIBLE int
lws_plat_init_lookup(struct lws_context *context)
lws_plat_init(struct lws_context *context,
struct lws_context_creation_info *info)
{
int i;
@ -269,12 +270,6 @@ lws_plat_init_lookup(struct lws_context *context)
}
}
return 0;
}
LWS_VISIBLE int
lws_plat_init_fd_tables(struct lws_context *context)
{
context->events = lws_malloc(sizeof(WSAEVENT) * (context->max_fds + 1));
if (context->events == NULL) {
lwsl_err("Unable to allocate events array for %d connections\n",

View file

@ -1291,9 +1291,8 @@ lws_poll_listen_fd(struct lws_pollfd *fd);
LWS_EXTERN int
lws_plat_service(struct lws_context *context, int timeout_ms);
LWS_EXTERN int
lws_plat_init_lookup(struct lws_context *context);
LWS_EXTERN int
lws_plat_init_fd_tables(struct lws_context *context);
lws_plat_init(struct lws_context *context,
struct lws_context_creation_info *info);
LWS_EXTERN void
lws_plat_drop_app_privileges(struct lws_context_creation_info *info);
LWS_EXTERN unsigned long long