Skip to content

Commit

Permalink
flowd-rs: Add GraphInOutPortHolder for runtime inport and outport cha…
Browse files Browse the repository at this point in the history
…nnels (#207)
  • Loading branch information
ERnsTL committed Sep 1, 2022
1 parent 7400dd6 commit 6c60cbd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion flowd-rs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ fn main() {
String::from("basic description"),
String::from("usd")
))); //TODO check if an RwLock is OK (multiple readers possible, but what if writer deletes that thing being read?) or if Mutex needed
let graph_inout: Arc<Mutex<GraphInportOutportHolder>> = Arc::new(Mutex::new(GraphInportOutportHolder { inports: None, outports: None, websockets: HashMap::new() }));
info!("graph initialized");

// add graph exported/published inport and outport
Expand Down Expand Up @@ -111,14 +112,15 @@ fn main() {
let graphref = graph.clone();
let runtimeref = runtime.clone();
let componentlibref = componentlib.clone();
let graph_inoutref = graph_inout.clone();
//let processesref = processes.clone();

// start thread
// since the thread name can only be 15 characters on Linux and an IP address already has up to 15, the IP address is not in the name
thread::Builder::new().name("client-handler".into()).spawn(move || {
info!("got a client from {}", stream.peer_addr().expect("get peer address failed"));
//if let Err(err) = handle_client(stream, graphref, runtimeref, componentlibref, processesref) {
if let Err(err) = handle_client(stream, graphref, runtimeref, componentlibref) {
if let Err(err) = handle_client(stream, graphref, runtimeref, componentlibref, graph_inoutref) {
match err {
Error::ConnectionClosed | Error::Protocol(_) | Error::Utf8 => (),
e => error!("test: {}", e),
Expand Down Expand Up @@ -1130,6 +1132,9 @@ fn handle_client(stream: TcpStream, graph: Arc<RwLock<Graph>>, runtime: Arc<RwLo
}
info!("--- end of message handling iteration")
}
{
graph_inout.lock().expect("could not acquire lock for removing WebSocket from connections list").websockets.remove(&peer_addr);
}
//websocket.close().expect("could not close websocket");
info!("---");
Ok(())
Expand Down

0 comments on commit 6c60cbd

Please sign in to comment.