servant/servant-client
Falco Peijnenburg 798d9e8967 Fixes MVar blocking exception
Uses the fix mentioned by @arianvp in
https://github.com/haskell-servant/servant/pull/425.

See also
https://github.com/haskell-servant/servant/issues/51#issuecomment-250737727

The cause of the issue very is similar to the issue described
in this blog post:
https://www.fpcomplete.com/blog/2016/06/async-exceptions-stm-deadlocks

The main thread creates a waiter, creates an asynchronous callback which is
called when the `readyState` of the request changes. When the readyState
changes to 4, which means 'request finished', the waiter MVar is put.
The main thread takes the MVar and continues to do stuff with the response.

The problem is that the `readyState` can change to 4 more than once,
for some reason. The second time this happens, the waiter MVar can be put
again, since the main thread took it. The main thread, however, won't take
it again. After all, it only needed to take the MVar once to know that the
request was finished. The third time `readyState` is set to 4, the putMVar
would block, causing the following exception to be thrown:

```
thread blocked indefinitely in an MVar operation
```

Since state 4 should really mean that the response is ready, it seems
appropriate to decide that all changes of the state to 4 after the initial one
can be safely ignored.
2016-09-30 18:12:22 +02:00
..
include less OverlappingInstances noise 2016-01-04 13:09:11 -05:00
src/Servant Fixes MVar blocking exception 2016-09-30 18:12:22 +02:00
test Merge branch 'master' of github.com:haskell-servant/servant into client-ghcjs 2016-09-26 15:32:53 +02:00
CHANGELOG.md tweake changelogs for the upcoming release 2016-09-17 11:46:26 -04:00
docs.sh prepare merge 2015-04-20 11:15:58 +02:00
LICENSE Change copyright to servant contributors 2016-01-20 16:58:29 +01:00
README.md Remove host param from servant-client README. 2016-05-25 17:38:25 +02:00
servant-client.cabal Merge branch 'master' of github.com:haskell-servant/servant into client-ghcjs 2016-09-26 15:32:53 +02:00
Setup.hs stylish haskell changes 2015-08-18 00:07:12 +02:00
tinc.yaml Use tinc on travis 2015-11-05 09:32:13 +08:00

servant-client

servant

This library lets you automatically derive Haskell functions that let you query each endpoint of a servant webservice.

Example

type MyApi = "books" :> Get '[JSON] [Book] -- GET /books
        :<|> "books" :> ReqBody Book :> Post '[JSON] Book -- POST /books

myApi :: Proxy MyApi
myApi = Proxy

getAllBooks :: Manager -> BaseUrl -> ExceptT String IO [Book]
postNewBook :: Book -> Manager -> BaseUrl -> ExceptT String IO Book
-- 'client' allows you to produce operations to query an API from a client.
(getAllBooks :<|> postNewBook) = client myApi