Clean up callback_list, remove sentinel/active/tail, callbacks return bool for removal, register before send
This commit is contained in:
@@ -72,7 +72,7 @@ static void process_frame(std::span<const uint8_t> frame, span_writer& tx) {
|
||||
if (!mac_match(eth_hdr.dst)) return;
|
||||
|
||||
frame_callbacks.for_each([&](frame_cb_list::node* n) {
|
||||
if (n->value().fn(frame))
|
||||
if (n->value(frame))
|
||||
frame_callbacks.remove(n);
|
||||
});
|
||||
|
||||
@@ -123,7 +123,9 @@ void net_set_handler(net_handler handler) {
|
||||
}
|
||||
|
||||
frame_cb_handle net_add_frame_callback(net_frame_callback cb) {
|
||||
return frame_callbacks.insert({std::move(cb)});
|
||||
auto h = frame_callbacks.insert(std::move(cb));
|
||||
if (!h) dlog("frame callback alloc failed");
|
||||
return h;
|
||||
}
|
||||
|
||||
void net_remove_frame_callback(frame_cb_handle h) {
|
||||
@@ -135,7 +137,7 @@ void net_poll(std::span<uint8_t> tx) {
|
||||
w6300::irq_pending = false;
|
||||
w6300::clear_interrupt(w6300::ik_int_all);
|
||||
static uint8_t rx_buf[1518];
|
||||
int budget = 2;
|
||||
int budget = 10;
|
||||
while (budget-- > 0 && w6300::get_socket_recv_buf(raw_socket) > 0) {
|
||||
auto result = w6300::recv(raw_socket, std::span{rx_buf});
|
||||
if (!result) break;
|
||||
|
||||
Reference in New Issue
Block a user