-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Example] Multi-threaded programming example #39
Conversation
Append the result of valgrind: valgrind --tool=memcheck --leak-check=full ./multi_thread_bin ==32218== |
/cc @brendandburns |
Perhaps we can use https://curl.se/libcurl/c/CURLOPT_PROGRESSFUNCTION.html I really think there has to be a better approach than an endless watch thread. |
OK. I will go to investigate |
Actually looks like there is a newer callback function: https://curl.se/libcurl/c/CURLOPT_XFERINFOFUNCTION.html |
Thank you for your comments, the new code (using The change of apiClient.{h,c} will not be committed by this PR. So I label Alought there is still one memory leak, it's a previous defect existing in openapi-generator/c-libcurl. I will fix it in another PR. |
examples/multi_thread/mt.h
Outdated
#include <apiClient.h> | ||
#include <CoreV1API.h> | ||
|
||
typedef struct kube_params_t { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix indentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
This looks good to me. Thanks for finding and fixing the api client too! |
The libcurl progress function support is merged by #40 Could you please approve this PR ? I will create another PR to fix the pre memory-leak issue of openapi-generator/c-libcurl
|
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: brendandburns, ityuhui The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
All of memory-leak issues are fixed by #42 |
Alougth I use
pthread_cleanup_push()/pthread_cleanup_pop()
afterpthread_cancel()
for thewatch
thread. But some resources still leak because they are allocated in the functions from openapi-generator/c-libcurl, their handles(pointers) are hard to get.So it seems that the endless
watch
thread is better, should I change the example to removepthread_cleanup_push()/pthread_cleanup_pop()/pthread_cancel()
, run thewatch
thread for ever ?