为什么MonitoringManager :: OnRequestSucceeded()中的assert(s_monitors)失败?

时间:2019-01-21 12:31:51

标签: c++ amazon-s3 assertion aws-sdk-cpp

我将文件上传到S3。在请求之后,我立即从MonitoringManager收到异常,我不知道自己在做什么错。我们正在应用程序中使用多个线程。

异常:断言失败。程序:... Monitor ... ger.cpp 55行 展示次数:s_monitors

cpp文件:https://github.com/aws/aws-sdk-cpp/blob/master/aws-cpp-sdk-core/source/monitoring/MonitoringManager.cpp第55行

uploadFileToS3(...);

方法“ uploadFileToS3”:

bool result = false;

const Aws::SDKOptions options;
Aws::InitAPI(options);
{
    std::shared_ptr<Aws::Utils::Threading::Executor> m_executor = Aws::MakeShared<Aws::Utils::Threading::PooledThreadExecutor>("TransferTests", 4);
    Aws::Transfer::TransferManagerConfiguration config(m_executor.get());
    config.s3Client = client;
    auto transmanager = Aws::Transfer::TransferManager::Create(config);

    std::shared_ptr<Aws::Transfer::TransferHandle> handle = transmanager->UploadFile(fileDestination, Aws::String(S3_BUCKET_NAME),
        Aws::String(s3key), Aws::String("multipart/form-data"), metadata);

    handle->WaitUntilFinished();

    result = isAwsActionSuccessful(handle) && boost::filesystem::remove(fileDestination);

}
Aws::ShutdownAPI(options);
return result;

1 个答案:

答案 0 :(得分:0)

问题是我的应用程序使用了多个线程,因此API被初始化并多次关闭。当我仅在应用程序中执行一次API的初始化/关闭时,该问题就解决了。