@@ -466,64 +466,4 @@ TEST_F(FunctionalTests, AampCurlDownloader_Retry_502)
466466 EXPECT_EQ (408 , respData->iHttpRetValue );
467467 respData->show ();
468468 respData->clear ();
469- }
470-
471- /* *
472- * @brief Test case to verify calling order: Release() before CleanupCurlHeaderResources()
473- *
474- * This test demonstrates the recommended sequence where Release() is called first to stop
475- * downloads (sets mDownloadActive=false), followed by CleanupCurlHeaderResources() to free
476- * curl header resources. This ordering prevents potential race conditions where header
477- * resources could be freed while curl callbacks are still executing.
478- *
479- */
480- TEST_F (FunctionalTests, Release_BeforeCleanupCurlHeaderResources_PreventRaceCondition) {
481- DownloadConfigPtr config = std::make_shared<DownloadConfig>();
482-
483- EXPECT_CALL (*g_mockCurl, curl_easy_init ()).WillOnce (Return (mCurlEasyHandle ));
484- EXPECT_CALL (*g_mockCurl, curl_easy_cleanup (mCurlEasyHandle ));
485- EXPECT_CALL (*g_mockCurl, curl_easy_setopt_ptr (mCurlEasyHandle , CURLOPT_PROGRESSDATA, mAampCurlDownloader ))
486- .WillOnce (Return (CURLE_OK));
487- EXPECT_CALL (*g_mockCurl, curl_easy_setopt_func_xferinfo (mCurlEasyHandle , CURLOPT_XFERINFOFUNCTION, NotNull ()))
488- .WillOnce (DoAll (SaveArgPointee<2 >(&mCurlProgressCallback ), Return (CURLE_OK)));
489- EXPECT_CALL (*g_mockCurl, curl_easy_setopt_ptr (mCurlEasyHandle , CURLOPT_WRITEDATA, mAampCurlDownloader ))
490- .WillOnce (Return (CURLE_OK));
491- EXPECT_CALL (*g_mockCurl, curl_easy_setopt_func_write (mCurlEasyHandle , CURLOPT_WRITEFUNCTION, NotNull ()))
492- .WillOnce (DoAll (SaveArgPointee<2 >(&mCurlWriteFunc ), Return (CURLE_OK)));
493-
494- mAampCurlDownloader ->Initialize (config);
495-
496- std::atomic<bool > releaseCompleted (false );
497- std::atomic<bool > headerCleanupStarted (false );
498- std::atomic<bool > raceConditionDetected (false );
499-
500- // Thread 1: Simulates download activity
501- std::thread downloadThread ([&]() {
502- for (int i = 0 ; i < 100 && !releaseCompleted.load (); ++i) {
503- if (headerCleanupStarted.load () && !releaseCompleted.load ()) {
504- raceConditionDetected.store (true );
505- }
506- std::this_thread::sleep_for (std::chrono::milliseconds (1 ));
507- }
508- });
509-
510- // Allow download thread to start
511- std::this_thread::sleep_for (std::chrono::milliseconds (10 ));
512-
513- // Step 1: Call Release() first to stop downloads
514- mAampCurlDownloader ->Release ();
515- releaseCompleted.store (true );
516-
517- // Step 2: Call CleanupCurlHeaderResources() after downloads stopped
518- headerCleanupStarted.store (true );
519- mAampCurlDownloader ->CleanupCurlHeaderResources ();
520-
521- downloadThread.join ();
522-
523- // Verify no race condition detected
524- EXPECT_FALSE (raceConditionDetected.load ())
525- << " Race condition detected: CleanupCurlHeaderResources() called before Release() completed" ;
526-
527- // Verify download is stopped
528- EXPECT_FALSE (mAampCurlDownloader ->IsDownloadActive ());
529- }
469+ }
0 commit comments