celluloid / reel

UNMAINTAINED: See celluloid/celluloid#779 - Celluloid::IO-powered web server
https://celluloid.io
MIT License
596 stars 87 forks source link

Do not allow transitioning out of closed #182

Closed zanker closed 9 years ago

zanker commented 9 years ago

I don't have a good way of replicating this @tarcieri, but I can do it with our internal code, so if you want to drop by and poke at it more let me know.

The FSM defaults to failing open, if you don't specify a state it can transition to, it assumes you can transition to anything. Since we shouldn't be able to transition to anything once closed, I set it to empty to stop that.

The issue I was seeing, is it would get stuck into a bad state where the socket that looked like this:

--- 127.0.0.1:58815 (AF_INET) disconnected false
HTTP/1.1 200 OK
Connection: close
Content-Length: 14

--- 127.0.0.1:58815 (AF_INET) disconnected false
HTTP/1.1 200 OK
Connection: close
Content-Length: 14

--- 127.0.0.1:58815 (AF_INET) disconnected false
HTTP/1.1 200 OK
Connection: close
Content-Length: 14

--- 127.0.0.1:58815 (AF_INET) disconnected false
HTTP/1.1 200 OK
Connection: close
Content-Length: 14

--- 127.0.0.1:58815 (AF_INET) disconnected false
HTTP/1.1 200 OK
Connection: close
Content-Length: 14

--- 127.0.0.1:58815 (AF_INET) disconnected false
HTTP/1.1 200 OK
Connection: close
Content-Length: 14

--- 127.0.0.1:58815 (AF_INET) disconnected false
HTTP/1.1 200 OK
Connection: close
Content-Length: 14

--- 127.0.0.1:58815 (AF_INET) disconnected false

After it made one connection on port 58815. The "false" is my check for @socket.closed?. When I checked on the requester side, I only have one request being received (the original one before it looped). This changes it so the actor crashes, which isn't great, but better than being stuck in a loop where it keeps trying to respond.

tarcieri commented 9 years ago

Celluloid::FSM could probably use a better API for terminal states.