forked from M-Labs/artiq
runtime: remove useless handshaking in analyzer.
This commit is contained in:
parent
b52ecda1d5
commit
4f11b071a5
|
@ -29,7 +29,6 @@ def initialize_connection(host, port):
|
||||||
sock.settimeout(None)
|
sock.settimeout(None)
|
||||||
set_keepalive(sock, 3, 2, 3)
|
set_keepalive(sock, 3, 2, 3)
|
||||||
logger.debug("connected to host %s on port %d", host, port)
|
logger.debug("connected to host %s on port %d", host, port)
|
||||||
sock.sendall(b"ARTIQ coredev\n")
|
|
||||||
return sock
|
return sock
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,6 +43,7 @@ class Comm(CommGeneric):
|
||||||
if hasattr(self, "socket"):
|
if hasattr(self, "socket"):
|
||||||
return
|
return
|
||||||
self.socket = initialize_connection(self.host, self.port)
|
self.socket = initialize_connection(self.host, self.port)
|
||||||
|
self.socket.sendall(b"ARTIQ coredev\n")
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
if not hasattr(self, "socket"):
|
if not hasattr(self, "socket"):
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use std::io::{self, Read, Write};
|
use std::io::{self, Write};
|
||||||
use board::{self, csr};
|
use board::{self, csr};
|
||||||
use sched::{Waiter, Spawner};
|
use sched::{Waiter, Spawner};
|
||||||
use sched::{TcpListener, TcpStream, SocketAddr, IP_ANY};
|
use sched::{TcpListener, TcpStream, SocketAddr, IP_ANY};
|
||||||
|
@ -68,19 +68,6 @@ fn worker(mut stream: TcpStream) -> io::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove this, it's pointless in analyzer
|
|
||||||
fn check_magic(stream: &mut TcpStream) -> io::Result<()> {
|
|
||||||
const MAGIC: &'static [u8] = b"ARTIQ coredev\n";
|
|
||||||
|
|
||||||
let mut magic: [u8; 14] = [0; 14];
|
|
||||||
try!(stream.read_exact(&mut magic));
|
|
||||||
if magic != MAGIC {
|
|
||||||
Err(io::Error::new(io::ErrorKind::InvalidData, "unrecognized magic"))
|
|
||||||
} else {
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn thread(waiter: Waiter, _spawner: Spawner) {
|
pub fn thread(waiter: Waiter, _spawner: Spawner) {
|
||||||
// verify that the hack above works
|
// verify that the hack above works
|
||||||
assert!(::core::mem::align_of::<Buffer>() == 64);
|
assert!(::core::mem::align_of::<Buffer>() == 64);
|
||||||
|
@ -92,11 +79,7 @@ pub fn thread(waiter: Waiter, _spawner: Spawner) {
|
||||||
loop {
|
loop {
|
||||||
arm();
|
arm();
|
||||||
|
|
||||||
let (mut stream, addr) = listener.accept().expect("cannot accept client");
|
let (stream, addr) = listener.accept().expect("cannot accept client");
|
||||||
match check_magic(&mut stream) {
|
|
||||||
Ok(()) => (),
|
|
||||||
Err(_) => continue
|
|
||||||
}
|
|
||||||
info!("connection from {}", addr);
|
info!("connection from {}", addr);
|
||||||
|
|
||||||
disarm();
|
disarm();
|
||||||
|
|
Loading…
Reference in New Issue