Skip to content
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

S3_initialize and S3_deinitialize missing mutex in multithread situation #114

Open
sz-xuejin opened this issue Dec 31, 2024 · 0 comments
Open

Comments

@sz-xuejin
Copy link

in src/general.c, S3_initialize and S3_deinitialize using initializeCountG to decide whether s3 need to initialize or deinitialize, it will cause curl aborted issue when create multithread clients.
suggest:

`#include <ctype.h>
#include <string.h>
#include "request.h"
#include "simplexml.h"
#include "util.h"
#include "pthread.h"

static int initializeCountG = 0;
pthread_mutex_t initializeGlbMutex = PTHREAD_MUTEX_INITIALIZER;

S3Status S3_initialize(const char *userAgentInfo, int flags,
const char *defaultS3HostName)
{
pthread_mutex_lock(&initializeGlbMutex);
if (initializeCountG++) {
pthread_mutex_unlock(&initializeGlbMutex);
return S3StatusOK;
}
pthread_mutex_unlock(&initializeGlbMutex);

return request_api_initialize(userAgentInfo, flags, defaultS3HostName);

}

void S3_deinitialize()
{
pthread_mutex_lock(&initializeGlbMutex);
if (--initializeCountG) {
pthread_mutex_unlock(&initializeGlbMutex);
return;
}
pthread_mutex_unlock(&initializeGlbMutex);

request_api_deinitialize();

}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant