Skip to content

Commit

Permalink
Merge pull request #37 from ityuhui/yh-mt-from-generator
Browse files Browse the repository at this point in the history
Re-generate the client to merge the multi-thread support from openapi-generator
  • Loading branch information
k8s-ci-robot authored Oct 31, 2020
2 parents 916f56c + e8e2625 commit 0e3f44c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
12 changes: 12 additions & 0 deletions kubernetes/include/apiClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 7 additions & 4 deletions kubernetes/src/apiClient.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
}

0 comments on commit 0e3f44c

Please sign in to comment.