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:
Kubernetes Prow Robot
2020-10-30 21:14:51 -07:00
committed by GitHub
2 changed files with 19 additions and 4 deletions

View File

@@ -45,4 +45,16 @@ void sslConfig_free(sslConfig_t *sslConfig);
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

View File

@@ -7,7 +7,6 @@
size_t writeDataCallback(void *buffer, size_t size, size_t nmemb, void *userp);
apiClient_t *apiClient_create() {
curl_global_init(CURL_GLOBAL_ALL);
apiClient_t *apiClient = malloc(sizeof(apiClient_t));
apiClient->basePath = strdup("http://localhost");
apiClient->sslConfig = NULL;
@@ -24,7 +23,6 @@ apiClient_t *apiClient_create_with_base_path(const char *basePath
, sslConfig_t *sslConfig
, list_t *apiKeys_BearerToken
) {
curl_global_init(CURL_GLOBAL_ALL);
apiClient_t *apiClient = malloc(sizeof(apiClient_t));
if(basePath){
apiClient->basePath = strdup(basePath);
@@ -76,9 +74,7 @@ void apiClient_free(apiClient_t *apiClient) {
}
list_free(apiClient->apiKeys_BearerToken);
}
free(apiClient);
curl_global_cleanup();
}
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;
}
void apiClient_setupGlobalEnv() {
curl_global_init(CURL_GLOBAL_ALL);
}
void apiClient_unsetupGlobalEnv() {
curl_global_cleanup();
}