Revision c9224fa4
ID | c9224fa4cab174e66b3e7167da79ad62399e2866 |
Parent | 4d8e5008 |
Child | 2ca68e2b |
Rapi: fully evaluate the body in getUrl
Currently, the Rapi.getUrl function returns the body without
evaluating it, and the other functions (loadData, parseData) do the
same. In effect, the top-level structure returned from loadData can be
a thunk which depends on the curl operation, thus keeping the curl
resources alive even after return from the Rapi module.
While this is not a problem in single-threaded programs, it can become
an issue with the threaded runtime. So it's better to fully evaluate
the HTTP body before returning from the getUrl function, so that at
least the curl resources are released.
Either "return $! body" or "(code, !body) <- …" works (i.e. avoids the
segfaults in my tests), but I think it's cleaner to force full
evaluation of the body when returning from the curlGetString
function. For this, we also enable the BangPatterns language
extension.
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Balazs Lecz <leczb@google.com>
Files
- added
- modified
- copied
- renamed
- deleted