[Bugfix][T106][bug-view-306]Fix the issue of error when repeatedly calling the download ephemeris function

Only Configure :No
Affected branch: master
Affected module: gnss
Is it affected on both ZXIC and MTK:only ZXIC
Self-test: Yes
Doc Update: No

Change-Id: I57ac7e8de703e2eeac6567646d1ac11aaf9fbf89
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/mbtk_http.h b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/mbtk_http.h
index c1c6e9e..87ccf8a 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/mbtk_http.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/mbtk_http.h
@@ -354,7 +354,7 @@
 int mbtk_http_session_content_send(int handle_id,int session_id,
         char *data,int data_len);
 const mbtk_http_session_t* mbtk_http_session_get(int handle_id,int session_id);
-
+void http_handle_init();
 #ifdef __cplusplus
 }
 #endif
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
index dace72f..360011b 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
@@ -1156,6 +1156,7 @@
         ALOGE("malloc memory error\n");
         return -3;
     }
+    http_handle_init();
     memset(mbtk_gnss_handle, 0, sizeof(struct mbtk_gnss_handle_t));
     memset(&mopen_gnss_device_info, 0, sizeof(mopen_gnss_device_info));
     mbtk_gnss_handle->dev_fd = mopen_gnss_open(MBTK_GNSS_DEV, B115200);
@@ -1477,6 +1478,7 @@
     }
     if(mbtk_http_session_url_set(http_handle, http_session, "http://unicore-api.rx-networks.cn/rxn-api/locationApi/rtcm")) {
         printf("mbtk_http_session_url_set() fail.\n");
+        mbtk_http_handle_free(http_handle);
         return -3;
     }
 
@@ -1499,6 +1501,7 @@
 
     if(mbtk_http_session_start(http_handle, http_session)) {
         printf("mbtk_http_session_start() fail.\n");
+        mbtk_http_handle_free(http_handle);
         return -4;
     }
     if(mbtk_http_handle_free(http_handle))
@@ -1527,11 +1530,13 @@
 
     if(mbtk_http_session_url_set(http_handle, http_session, host))
     {
+        mbtk_http_handle_free(http_handle);
         printf("mbtk_http_session_url_set() fail.\n");
         return -3;
     }
     if(mbtk_http_session_start(http_handle, http_session))
     {
+        mbtk_http_handle_free(http_handle);
         printf("mbtk_http_session_start() fail.\n");
         return -4;
     }
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_http.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_http.cpp
index 1963359..8080bfa 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_http.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_http.cpp
@@ -25,15 +25,19 @@
 /*************************************************************
     Variables:local
 *************************************************************/
-static mbtk_http_handle_t http_handles[HTTP_HANDLE_MAX] =
+static mbtk_http_handle_t http_handles[HTTP_HANDLE_MAX] = {0};
+
+
+void http_handle_init()
 {
+    for (int i = 0; i < HTTP_HANDLE_MAX; i++)
     {
-        .id = -1,
-        .data_cb = NULL,
-        .session_cnt = 0,
-        .session = {NULL}
+        http_handles[i].id = -1;
+        http_handles[i].data_cb = NULL;
+        http_handles[i].session_cnt = 0;
+        http_handles[i].session[0] = NULL;
     }
-};
+}
 
 /*************************************************************
     Variables:public