Merge pull request #37 from ityuhui/yh-mt-from-generator
Re-generate the client to merge the multi-thread support from openapi-generator
This commit is contained in:
@@ -45,4 +45,16 @@ void sslConfig_free(sslConfig_t *sslConfig);
|
|||||||
|
|
||||||
char *strReplace(char *orig, char *rep, char *with);
|
char *strReplace(char *orig, char *rep, char *with);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In single thread program, the function apiClient_setupGlobalEnv is not needed.
|
||||||
|
* But in multi-thread program, apiClient_setupGlobalEnv must be called before any worker thread is created
|
||||||
|
*/
|
||||||
|
void apiClient_setupGlobalEnv();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function apiClient_unsetupGlobalEnv must be called whether single or multiple program.
|
||||||
|
* In multi-thread program, it is must be called after all worker threads end.
|
||||||
|
*/
|
||||||
|
void apiClient_unsetupGlobalEnv();
|
||||||
|
|
||||||
#endif // INCLUDE_API_CLIENT_H
|
#endif // INCLUDE_API_CLIENT_H
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
size_t writeDataCallback(void *buffer, size_t size, size_t nmemb, void *userp);
|
size_t writeDataCallback(void *buffer, size_t size, size_t nmemb, void *userp);
|
||||||
|
|
||||||
apiClient_t *apiClient_create() {
|
apiClient_t *apiClient_create() {
|
||||||
curl_global_init(CURL_GLOBAL_ALL);
|
|
||||||
apiClient_t *apiClient = malloc(sizeof(apiClient_t));
|
apiClient_t *apiClient = malloc(sizeof(apiClient_t));
|
||||||
apiClient->basePath = strdup("http://localhost");
|
apiClient->basePath = strdup("http://localhost");
|
||||||
apiClient->sslConfig = NULL;
|
apiClient->sslConfig = NULL;
|
||||||
@@ -24,7 +23,6 @@ apiClient_t *apiClient_create_with_base_path(const char *basePath
|
|||||||
, sslConfig_t *sslConfig
|
, sslConfig_t *sslConfig
|
||||||
, list_t *apiKeys_BearerToken
|
, list_t *apiKeys_BearerToken
|
||||||
) {
|
) {
|
||||||
curl_global_init(CURL_GLOBAL_ALL);
|
|
||||||
apiClient_t *apiClient = malloc(sizeof(apiClient_t));
|
apiClient_t *apiClient = malloc(sizeof(apiClient_t));
|
||||||
if(basePath){
|
if(basePath){
|
||||||
apiClient->basePath = strdup(basePath);
|
apiClient->basePath = strdup(basePath);
|
||||||
@@ -76,9 +74,7 @@ void apiClient_free(apiClient_t *apiClient) {
|
|||||||
}
|
}
|
||||||
list_free(apiClient->apiKeys_BearerToken);
|
list_free(apiClient->apiKeys_BearerToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(apiClient);
|
free(apiClient);
|
||||||
curl_global_cleanup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sslConfig_t *sslConfig_create(const char *clientCertFile, const char *clientKeyFile, const char *CACertFile, int insecureSkipTlsVerify) {
|
sslConfig_t *sslConfig_create(const char *clientCertFile, const char *clientKeyFile, const char *CACertFile, int insecureSkipTlsVerify) {
|
||||||
@@ -515,3 +511,10 @@ char *strReplace(char *orig, char *rep, char *with) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void apiClient_setupGlobalEnv() {
|
||||||
|
curl_global_init(CURL_GLOBAL_ALL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void apiClient_unsetupGlobalEnv() {
|
||||||
|
curl_global_cleanup();
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user