feature(packet manager): support claim packt and add test case
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "tuple.h"
|
||||
#include "uthash.h"
|
||||
#include "log_private.h"
|
||||
@@ -101,14 +103,14 @@ bool packet_is_ctrl(const struct packet *pkt)
|
||||
return pkt->meta.is_ctrl;
|
||||
}
|
||||
|
||||
void packet_set_stolen(struct packet *pkt, bool stolen)
|
||||
void packet_set_claim(struct packet *pkt, bool claim)
|
||||
{
|
||||
pkt->meta.is_stolen = stolen;
|
||||
pkt->meta.is_claim = claim;
|
||||
}
|
||||
|
||||
bool packet_is_stolen(const struct packet *pkt)
|
||||
bool packet_is_claim(const struct packet *pkt)
|
||||
{
|
||||
return pkt->meta.is_stolen;
|
||||
return pkt->meta.is_claim;
|
||||
}
|
||||
|
||||
void packet_set_direction(struct packet *pkt, enum packet_direction dir)
|
||||
@@ -929,9 +931,19 @@ struct packet *packet_dup(const struct packet *pkt)
|
||||
|
||||
void packet_free(struct packet *pkt)
|
||||
{
|
||||
if (pkt && pkt->need_free)
|
||||
if (pkt)
|
||||
{
|
||||
free((void *)pkt);
|
||||
if (packet_is_claim(pkt))
|
||||
{
|
||||
PACKET_LOG_ERROR("packet has been claimed and cannot be released, please check the module arrangement order");
|
||||
assert(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pkt->need_free)
|
||||
{
|
||||
free((void *)pkt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user