summaryrefslogtreecommitdiff
path: root/src/itf_http.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/itf_http.rs')
-rw-r--r--src/itf_http.rs14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/itf_http.rs b/src/itf_http.rs
index a89d9e0..cda923f 100644
--- a/src/itf_http.rs
+++ b/src/itf_http.rs
@@ -22,15 +22,16 @@ pub struct ItfHttp {
impl ItfHttp {
- pub fn new(itf: Arc<Interface>, sock: TcpStream, addr: SocketAddr) -> ItfHttp {
+ pub fn new(ctx: &mut Context, itf: Arc<Interface>, sock: TcpStream, addr: SocketAddr) -> ItfHttp {
+ let io = ctx.register(&sock, Ready::readable());
ItfHttp {
sock: sock,
addr: addr,
- io: Token(0),
+ io: io,
ioreg: Ready::readable(),
rbuf: Buf::new(),
wbuf: Buf::new(),
- iotimeout: TToken(0),
+ iotimeout: ctx.set_timeout(itf.cfg.io_timeout),
itf: itf,
}
}
@@ -47,7 +48,7 @@ impl ItfHttp {
}
return;
},
- Ok(0) => { // This behaviour isn't documented, unsure if it's intended.
+ Ok(0) => {
debug!("{}: Connection closed", self.addr);
self.remove(ctx);
return;
@@ -106,11 +107,6 @@ impl ItfHttp {
impl Machine for ItfHttp {
- fn init(&mut self, ctx: &mut Context) {
- self.io = ctx.register(&self.sock, self.ioreg);
- self.iotimeout = ctx.set_timeout(self.itf.cfg.io_timeout);
- }
-
fn handle(&mut self, ctx: &mut Context, ev: Event) {
if ev.kind().is_readable() {
self.handle_read(ctx);