From 5c99512c7fb1243bd5e93acd60d501de88a592d4 Mon Sep 17 00:00:00 2001 From: Junyeon LEE Date: Tue, 30 May 2017 06:17:57 +0900 Subject: [PATCH] netutils/webclient: check webclient example running status This commit addes global value for checking webclieng running status. If webclient example runs twice at a time, global values like g_https and g_async can be destroyed by latter webclient app. Change-Id: I49644810de070c09d10e5d2c4bad402d35e5e505 Signed-off-by: Junyeon LEE --- apps/examples/webclient/webclient_main.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/examples/webclient/webclient_main.c b/apps/examples/webclient/webclient_main.c index d4773bd..d47a58c 100644 --- a/apps/examples/webclient/webclient_main.c +++ b/apps/examples/webclient/webclient_main.c @@ -131,6 +131,7 @@ struct http_client_ssl_config_t g_config = { sizeof(c_ca_crt_rsa), sizeof(c_cli_crt_rsa), sizeof(c_cli_key_rsa), 2 }; +static int g_running; static int g_https; static int g_async; static int g_testentity; @@ -343,9 +344,17 @@ int webclient_main(int argc, char *argv[]) pthread_t tid; struct webclient_input arg; + if (g_running) { + printf("Previous request is in process, Please wait.\n"); + return -1; + } else { + g_running = 1; + } + status = pthread_attr_init(&attr); if (status != 0) { printf("fail to start webclient\n"); + g_running = 0; return -1; } @@ -360,11 +369,13 @@ int webclient_main(int argc, char *argv[]) status = pthread_create(&tid, &attr, webclient_cb, &arg); if (status < 0) { printf("fail to start webclient\n"); + g_running = 0; return -1; } pthread_setname_np(tid, "webclient"); pthread_join(tid, NULL); + g_running = 0; return 0; } -- 2.7.4