update stellar thread main loop
This commit is contained in:
@@ -157,35 +157,55 @@ int packet_io_dumpfile_init(struct packet_io_dumpfile *handle, uint16_t thread_i
|
||||
return 0;
|
||||
}
|
||||
|
||||
int packet_io_dumpfile_recv(struct packet_io_dumpfile *handle, uint16_t thread_id, struct packet **pkt)
|
||||
int packet_io_dumpfile_recv(struct packet_io_dumpfile *handle, uint16_t thread_id, struct packet *pkts, int nr_pkts)
|
||||
{
|
||||
struct packet_queue *queue = handle->queue[thread_id];
|
||||
struct packet *pkt = NULL;
|
||||
int nr_parsed = 0;
|
||||
|
||||
packet_queue_pop(queue, pkt);
|
||||
if (*pkt == NULL)
|
||||
for (int i = 0; i < nr_pkts; i++)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ATOMIC_ADD(&handle->stat.rx_pkts, 1);
|
||||
ATOMIC_ADD(&handle->stat.rx_bytes, packet_get_len(*pkt));
|
||||
return 0;
|
||||
packet_queue_pop(queue, &pkt);
|
||||
if (pkt == NULL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
ATOMIC_ADD(&handle->stat.rx_pkts, 1);
|
||||
ATOMIC_ADD(&handle->stat.rx_bytes, packet_get_len(pkt));
|
||||
|
||||
struct packet *temp = &pkts[nr_parsed++];
|
||||
memset(temp, 0, sizeof(struct packet));
|
||||
packet_parse(temp, pkt->data_ptr, pkt->data_len);
|
||||
packet_set_io_ctx(temp, pkt);
|
||||
packet_set_type(temp, PACKET_TYPE_DATA);
|
||||
packet_set_action(temp, PACKET_ACTION_FORWARD);
|
||||
}
|
||||
}
|
||||
|
||||
return nr_parsed;
|
||||
}
|
||||
|
||||
void packet_io_dumpfile_send(struct packet_io_dumpfile *handle, uint16_t thread_id, struct packet *pkt)
|
||||
void packet_io_dumpfile_send(struct packet_io_dumpfile *handle, uint16_t thread_id, struct packet *pkts, int nr_pkts)
|
||||
{
|
||||
if (packet_get_action(pkt) == PACKET_ACTION_DROP)
|
||||
struct packet *pkt = NULL;
|
||||
for (int i = 0; i < nr_pkts; i++)
|
||||
{
|
||||
ATOMIC_ADD(&handle->stat.drop_pkts, 1);
|
||||
ATOMIC_ADD(&handle->stat.drop_bytes, packet_get_len(pkt));
|
||||
}
|
||||
else
|
||||
{
|
||||
ATOMIC_ADD(&handle->stat.tx_pkts, 1);
|
||||
ATOMIC_ADD(&handle->stat.tx_bytes, packet_get_len(pkt));
|
||||
}
|
||||
pkt = &pkts[i];
|
||||
|
||||
packet_free(pkt);
|
||||
if (packet_get_action(pkt) == PACKET_ACTION_DROP)
|
||||
{
|
||||
ATOMIC_ADD(&handle->stat.drop_pkts, 1);
|
||||
ATOMIC_ADD(&handle->stat.drop_bytes, packet_get_len(pkt));
|
||||
}
|
||||
else
|
||||
{
|
||||
ATOMIC_ADD(&handle->stat.tx_pkts, 1);
|
||||
ATOMIC_ADD(&handle->stat.tx_bytes, packet_get_len(pkt));
|
||||
}
|
||||
|
||||
packet_free((struct packet *)packet_get_io_ctx(pkt));
|
||||
packet_free(pkt);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user