summaryrefslogtreecommitdiff
path: root/shopify.c
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-09-19 11:08:55 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-09-19 11:08:55 +0800
commit1b972e7e6321adc8d1f78a06c31d2c0468e7afcf (patch)
treef49dd5bcb697e1ad6ed4bb8ee2621a92b955c3f5 /shopify.c
parent43b303bb7c03157488992acb90eeab6f7ca79136 (diff)
Sessions array is not global
Diffstat (limited to 'shopify.c')
-rw-r--r--shopify.c10
1 files 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);