From 1b972e7e6321adc8d1f78a06c31d2c0468e7afcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Mon, 19 Sep 2022 11:08:55 +0800 Subject: Sessions array is not global --- shopify.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/shopify.c b/shopify.c index bea6b1d..3074123 100644 --- a/shopify.c +++ b/shopify.c @@ -71,10 +71,9 @@ struct container { const char *scope; const char *index; const struct shopify_api *apis; + struct shopify_session *sessions; }; -static struct shopify_session *sessions; - static enum MHD_Result iterate(void *cls, enum MHD_ValueKind kind, const char *key, const char *val) { @@ -185,6 +184,7 @@ static enum MHD_Result handle_request(void *cls, struct MHD_Connection *con, return MHD_NO; } free(query); + struct shopify_session *sessions = container->sessions; int nsessions = 0; while (sessions[nsessions].shop) nsessions++; @@ -343,7 +343,8 @@ void shopify_app(const char *api_key, const char *api_secret_key, { crypt_init(); request_init(); - sessions = malloc(sizeof(struct shopify_session)); + struct shopify_session *sessions + = malloc(sizeof(struct shopify_session)); sessions[0].shop = NULL; struct MHD_Daemon *daemon = MHD_start_daemon(MHD_USE_INTERNAL_POLLING_THREAD, 3000, NULL, @@ -355,7 +356,8 @@ void shopify_app(const char *api_key, const char *api_secret_key, app_id, scope, index, - apis + apis, + sessions }, MHD_OPTION_END); getchar(); MHD_stop_daemon(daemon); -- cgit v1.2.3