edicl / drakma

HTTP client written in Common Lisp

Home Page:http://edicl.github.io/drakma/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

drakma:http-request does not terminate

simkoc opened this issue · comments

I am using sbcl 1.1.14
drakma: 2.0.1
linux ubuntu 14.04 3.13.0-59-generic

(drakma:http-request "http://support.wnet.ua/lg.php"
:parameters (list (cons "query" "4")
(cons "arg" "8.8.8.8")
(cons "action" "Execute")
(cons "router" "hostkhar"))
:method :post)

will not terminate and a ctr-c + backtrace reveals:

0: ("bogus stack frame")
1: (SB-SYS:WAIT-UNTIL-FD-USABLE 7 :INPUT NIL NIL)
2: (SB-IMPL::REFILL-INPUT-BUFFER #<SB-SYS:FD-STREAM for "socket 192.168.0.13:39020, peer: 217.20.163.184:80" {1002C56803}>)
3: (SB-IMPL::INPUT-UNSIGNED-8BIT-BYTE #<SB-SYS:FD-STREAM for "socket 192.168.0.13:39020, peer: 217.20.163.184:80" {1002C56803}> T NIL)
4: (READ-BYTE #<SB-SYS:FD-STREAM for "socket 192.168.0.13:39020, peer: 217.20.163.184:80" {1002C56803}> T NIL)
5: (CHUNGA:READ-CHAR* #<SB-SYS:FD-STREAM for "socket 192.168.0.13:39020, peer: 217.20.163.184:80" {1002C56803}> T NIL)
6: ((:METHOD CHUNGA::FILL-BUFFER (CHUNGA:CHUNKED-INPUT-STREAM)) #<CHUNGA:CHUNKED-IO-STREAM {1002D826D3}>) [fast-method]
7: ((:METHOD TRIVIAL-GRAY-STREAMS:STREAM-READ-SEQUENCE (CHUNGA:CHUNKED-INPUT-STREAM T T T)) #<CHUNGA:CHUNKED-IO-STREAM {1002D826D3}> #(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
AT SOME POINT DOWN HERE IS THE DRAKMA CALL

To all fairness, doing the same request via chromium does not terminate either. But still, I think it is a bit weird if I can effectively freeze the program permanently with an http-request as I'd expect it to either finish or time-out.

DRAKMA does not currently implement timeouts on SBCL. On Clozure CL, you can use the :DEADLINE argument, on LispWorks, the timeouts in the HTTP-REQUEST API work as advertised.

I am not familiar with the drakma callstack, but doesn't imply the read-sequence part that drakma already got a response but fails to deal with the returned values?

No, it is waiting for data to arrive on the socket. That is what (SB-SYS:WAIT-UNTIL-FD-USABLE 7 :INPUT NIL NIL) does.