nal: Fix loops & socket handle management #7
@ -194,7 +194,7 @@ where
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Blocking connect
|
||||
// Loop to wait until the socket is staying established or closed,
|
||||
// or the connection attempt has timed out.
|
||||
let mut timeout_ms: u32 = 0;
|
||||
@ -216,11 +216,13 @@ where
|
||||
return Ok(handle)
|
||||
}
|
||||
}
|
||||
|
||||
// Any TCP states other than CLOSED and ESTABLISHED are considered
|
||||
// "transient", so this function should keep waiting and let smoltcp poll
|
||||
// (e.g. for handling echo reqeust/reply) at the same time.
|
||||
timeout_ms += self.update()?;
|
||||
|
||||
self.poll()?;
|
||||
|
||||
// Time out, and return the socket for re-connection in the future.
|
||||
if timeout_ms > self.connection_timeout_ms {
|
||||
// TODO: Return Err(), but would require changes in quartiq/minimq
|
||||
|
Loading…
Reference in New Issue
Block a user
While all the other steps are very nicely documented, this fairly important
self.poll()
disappears to my eyes. How about a pair of newlines around it?Right. Before,
poll()
was simply part ofupdate()
, and I decided to separate them simply for the sake of clarity.What do you think: is it good to keep them separated?
Smaller chunks with separated logic are always better.
In
232a08f110
, I added a pair of newlines, one before the comment line (that explains polling), and one afterself.poll()
. Would that be good?