Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
id-iot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Per Lindgren
id-iot
Commits
b5469213
Commit
b5469213
authored
8 years ago
by
Covertness
Browse files
Options
Downloads
Patches
Plain Diff
put the response back in the queue when socket needs to wait
parent
cf433d01
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/server.rs
+15
-3
15 additions, 3 deletions
src/server.rs
with
15 additions
and
3 deletions
src/server.rs
+
15
−
3
View file @
b5469213
...
...
@@ -172,10 +172,11 @@ impl CoAPServer {
let
(
tx
,
rx
)
=
mpsc
::
channel
();
let
(
tx_send
,
tx_recv
):
(
TxQueue
,
RxQueue
)
=
mpsc
::
channel
();
let
tx_only
=
self
.socket
.try_clone
()
.unwrap
();
let
tx_send2
=
tx_send
.clone
();
// Setup and spawn single TX thread
let
tx_thread
=
thread
::
spawn
(
move
||
{
transmit_handler
(
tx_recv
,
tx_only
);
transmit_handler
(
tx_send2
,
tx_recv
,
tx_only
);
});
// Setup and spawn event loop thread, which will spawn
...
...
@@ -220,7 +221,7 @@ impl CoAPServer {
}
}
fn
transmit_handler
(
tx_recv
:
RxQueue
,
tx_only
:
UdpSocket
)
{
fn
transmit_handler
(
tx_send
:
TxQueue
,
tx_recv
:
RxQueue
,
tx_only
:
UdpSocket
)
{
// Note! We should only transmit with this UDP Socket
// TODO: Add better support for failure detection or logging
loop
{
...
...
@@ -228,7 +229,18 @@ fn transmit_handler(tx_recv: RxQueue, tx_only: UdpSocket) {
Ok
(
q_res
)
=>
{
match
q_res
.response.message
.to_bytes
()
{
Ok
(
bytes
)
=>
{
let
_
=
tx_only
.send_to
(
&
bytes
[
..
],
&
q_res
.address
);
match
tx_only
.send_to
(
&
bytes
[
..
],
&
q_res
.address
)
{
Ok
(
None
)
=>
{
// try to send again, look at https://github.com/Covertness/coap-rs/issues/8 in detail
tx_send
.send
(
q_res
)
.unwrap
()
}
Ok
(
_
)
=>
{
continue
;
}
Err
(
_
)
=>
{
error!
(
"Failed to send response"
);
}
}
}
Err
(
_
)
=>
{
error!
(
"Failed to decode response"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment