Skip to content

Commit cdb2949

Browse files
authored
snitch: add counters for send and recv errors (#2533)
This is intended to help with debugging #2532, by testing whether other tasks also receive spurious notifications from the `net` task. However, it also just seems like a good thing to have in general, so I'm opening a PR for it.
1 parent 5fc4dfe commit cdb2949

1 file changed

Lines changed: 32 additions & 20 deletions

File tree

task/snitch/src/main.rs

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ task_slot!(PACKRAT, packrat);
5151
#[derive(Count, Copy, Clone)]
5252
enum Event {
5353
RecvPacket,
54+
RecvError(#[count(children)] RecvError),
5455
RequestRejected,
5556
ReadError(#[count(children)] task_packrat_api::EreportReadError),
5657
Respond,
58+
SendError(#[count(children)] SendError),
5759
}
5860

5961
struct StaticBufs {
@@ -92,14 +94,19 @@ fn main() -> ! {
9294
&mut rx_buf[..],
9395
) {
9496
Ok(meta) => meta,
95-
Err(RecvError::QueueEmpty) => {
96-
// Our incoming queue is empty. Wait for more packets.
97-
sys_recv_notification(notifications::SOCKET_MASK);
98-
continue;
99-
}
100-
Err(RecvError::ServerRestarted) => {
101-
// `net` restarted; just retry.
102-
continue;
97+
Err(e) => {
98+
count!(Event::RecvError(e));
99+
match e {
100+
RecvError::QueueEmpty => {
101+
// Our incoming queue is empty. Wait for more packets.
102+
sys_recv_notification(notifications::SOCKET_MASK);
103+
continue;
104+
}
105+
RecvError::ServerRestarted => {
106+
// `net` restarted; just retry.
107+
continue;
108+
}
109+
}
103110
}
104111
};
105112

@@ -146,18 +153,23 @@ fn main() -> ! {
146153
count!(Event::Respond);
147154
break;
148155
}
149-
// If `net` just restarted, immediately retry our send.
150-
Err(SendError::ServerRestarted) => continue,
151-
// If our tx queue is full, wait for space. This is the
152-
// same notification we get for incoming packets, so we
153-
// might spuriously wake up due to an incoming packet
154-
// (which we can't service anyway because we are still
155-
// waiting to respond to a previous request); once we
156-
// finally succeed in sending we'll peel any queued
157-
// packets off our recv queue at the top of our main
158-
// loop.
159-
Err(SendError::QueueFull) => {
160-
sys_recv_notification(notifications::SOCKET_MASK);
156+
Err(e) => {
157+
count!(Event::SendError(e));
158+
match e {
159+
// If `net` just restarted, immediately retry our send.
160+
SendError::ServerRestarted => continue,
161+
// If our tx queue is full, wait for space. This is the
162+
// same notification we get for incoming packets, so we
163+
// might spuriously wake up due to an incoming packet
164+
// (which we can't service anyway because we are still
165+
// waiting to respond to a previous request); once we
166+
// finally succeed in sending we'll peel any queued
167+
// packets off our recv queue at the top of our main
168+
// loop.
169+
SendError::QueueFull => {
170+
sys_recv_notification(notifications::SOCKET_MASK);
171+
}
172+
}
161173
}
162174
}
163175
}

0 commit comments

Comments
 (0)