MCPcopy Create free account
hub / github.com/comnik/declarative-dataflow / step

Method step

server/src/networking.rs:93–310  ·  view source on GitHub ↗

Handle networking events.

(&mut self, t: u64, interests: &HashMap<String, HashSet<Token>>)

Source from the content-addressed store, hash-verified

91
92 /// Handle networking events.
93 pub fn step(&mut self, t: u64, interests: &HashMap<String, HashSet<Token>>) {
94 // We mustn't timeout here, we are not in charge of blocking.
95 self.poll
96 .poll(&mut self.events, Some(Duration::from_millis(0)))
97 .expect("failed to poll I/O events");
98
99 for event in self.events.iter() {
100 trace!("[IO] recv event on {:?}", event.token());
101
102 match event.token() {
103 SERVER => {
104 if event.readiness().is_readable() {
105 // new connection arrived on the server socket
106 match self.server_socket.accept() {
107 Err(err) => error!("[IO] error while accepting connection {:?}", err),
108 Ok((socket, addr)) => {
109 let token = {
110 let entry = self.connections.vacant_entry();
111 let token = Token(entry.key());
112 let connection_id = self.next_connection_id;
113
114 self.next_connection_id =
115 self.next_connection_id.wrapping_add(1);
116
117 entry.insert(Connection::new(
118 token,
119 socket,
120 self.ws_settings,
121 connection_id,
122 ));
123
124 token
125 };
126
127 info!("[IO] new tcp connection from {} (token {:?})", addr, token);
128
129 let conn = &mut self.connections[token.into()];
130
131 conn.as_server().unwrap();
132
133 self.poll
134 .register(
135 conn.socket(),
136 conn.token(),
137 conn.events(),
138 PollOpt::edge() | PollOpt::oneshot(),
139 )
140 .unwrap();
141 }
142 }
143 }
144 }
145 RESULTS => {
146 while let Ok(out) = self.recv.try_recv() {
147 let tokens: Box<dyn Iterator<Item = Token>> = match &out {
148 &Output::QueryDiff(ref name, ref results) => {
149 info!("[IO] {} {} results", name, results.len());
150

Callers 3

mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80

Calls 3

ErrorClass · 0.85
intoMethod · 0.80
registerMethod · 0.80

Tested by

no test coverage detected