Skip to content

Commit

Permalink
FIx ASAN build (#447)
Browse files Browse the repository at this point in the history
  • Loading branch information
drbasic committed Feb 15, 2024
1 parent 9f695e9 commit c036e18
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@ class IMigrationOwner
class TNonreplicatedPartitionMigrationCommonActor
: public NActors::TActorBootstrapped<
TNonreplicatedPartitionMigrationCommonActor>
, IPoisonPillHelperOwner
{
private:
using TBase = NActors::TActorBootstrapped<
TNonreplicatedPartitionMigrationCommonActor>;

IMigrationOwner* const MigrationOwner = nullptr;
const TStorageConfigPtr Config;
const IProfileLogPtr ProfileLog;
Expand Down Expand Up @@ -131,6 +135,12 @@ class TNonreplicatedPartitionMigrationCommonActor
// Called from the inheritor to get the next processing range.
TBlockRange64 GetNextProcessingRange() const;

// IPoisonPillHelperOwner implementation
void Die(const NActors::TActorContext& ctx) override
{
TBase::Die(ctx);
}

private:
void ScheduleCountersUpdate(const NActors::TActorContext& ctx);
void SendStats(const NActors::TActorContext& ctx);
Expand Down
21 changes: 2 additions & 19 deletions cloud/storage/core/libs/actors/poison_pill_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,10 @@
using namespace NActors;

namespace NCloud {
namespace {

////////////////////////////////////////////////////////////////////////////////

// Helps to call protected methods of IActor.
class IActorHelper: public IActor
{
public:
static void CallDie(IActor* actor, const TActorContext& ctx)
{
Y_DEBUG_ABORT_UNLESS(actor);
static_cast<IActorHelper*>(actor)->Die(ctx);
}
};

} // namespace

////////////////////////////////////////////////////////////////////////////////

TPoisonPillHelper::TPoisonPillHelper(NActors::IActor* owner)
TPoisonPillHelper::TPoisonPillHelper(IPoisonPillHelperOwner* owner)
: Owner(owner)
{}

Expand Down Expand Up @@ -90,8 +74,7 @@ void TPoisonPillHelper::ReplyAndDie(const TActorContext& ctx)
std::make_unique<TEvents::TEvPoisonTaken>(),
0, // flags
Poisoner->Cookie);

IActorHelper::CallDie(Owner, ctx);
Owner->Die(ctx);
}

} // namespace NCloud
12 changes: 10 additions & 2 deletions cloud/storage/core/libs/actors/poison_pill_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ namespace NCloud {

////////////////////////////////////////////////////////////////////////////////

// The owner of TPoisonPillHelper must implement this interface to make it
// possible to kill the parent actor.
class IPoisonPillHelperOwner
{
public:
virtual void Die(const NActors::TActorContext& ctx) = 0;
};

// Helps to handle the TEvPoisonPill for actor who owns other actors. The helper
// sends TEvPoisonPill to all owned actors and waits for a response
// TEvPoisonTaken from everyone. After that, it responds with the TEvPoisonTaken
Expand All @@ -22,12 +30,12 @@ class TPoisonPillHelper
ui64 Cookie = 0;
};

NActors::IActor* Owner;
IPoisonPillHelperOwner* Owner;
TSet<NActors::TActorId> OwnedActors;
std::optional<TPoisoner> Poisoner;

public:
explicit TPoisonPillHelper(NActors::IActor* owner);
explicit TPoisonPillHelper(IPoisonPillHelperOwner* owner);
virtual ~TPoisonPillHelper();

void TakeOwnership(
Expand Down
10 changes: 9 additions & 1 deletion cloud/storage/core/libs/actors/poison_pill_helper_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,12 @@ class TChildActor: public TActor<TChildActor>

////////////////////////////////////////////////////////////////////////////////

class TParentActor: public TActor<TParentActor>
class TParentActor
: public TActor<TParentActor>
, IPoisonPillHelperOwner
{
private:
using TBase = TActor<TParentActor>;
TPoisonPillHelper PoisonPillHelper;
ui32 ChildCount;

Expand All @@ -100,6 +103,11 @@ class TParentActor: public TActor<TParentActor>
, ChildCount(childCount)
{}

void Die(const NActors::TActorContext& ctx) override
{
TBase::Die(ctx);
}

private:
void Main(TAutoPtr<IEventHandle>& ev)
{
Expand Down

0 comments on commit c036e18

Please sign in to comment.