snapframework/cufp2011 — Issue #1: writeMessage could cause messages in queue to be dropped.
Author: qzchenwl
Created: 2011-10-13 08:10:11+00:00
State: open

[_ <- readAllFromChan 1 chan](https://github.com/snapframework/cufp2011/blob/master/src/Snap/Chat/ChatRoom.hs#L210) will drop messages already in queue.

```
------------------------------------------------------------------------------
-- | Write a message to the channel.
writeMessage :: Message -> User -> ChatRoom -> IO ()
writeMessage msg user cr = do
atomically $ writeTChan chan msg
_ <- readAllFromChan 1 chan
TM.tickle timeoutHandle userTimeout

where
chan = _chatChannel cr
timeoutHandle = _timeoutHandle user
userTimeout = _userTimeout cr