http_request return in a wrong errno
lxlenovostar opened this issue · comments
lxlenovostar commented
bt is:
#1 0xb6e065c0 in req_close (req=0x42b00, err=0, msg=0x0) at src/http/client.c:174
No locals.
#2 0xb6e06650 in try_next (conn=0x43008, err=110) at src/http/client.c:204
req = 0x42b00
retry = false
#3 0xb6e06810 in timeout_handler (arg=0x43008) at src/http/client.c:286
conn = 0x43008
#4 0xb6e29a20 in call_handler (th=0xb6e067fd <timeout_handler>, arg=0x43008) at src/tmr/tmr.c:68
tick = 1559648010604
diff = 274440
#5 0xb6e29ab6 in tmr_poll (tmrl=0xb6f64668 <global_re+24>) at src/tmr/tmr.c:111
tmr = 0x43008
th = 0xb6e067fd <timeout_handler>
th_arg = 0x43008
jfs = 1559648010604
#6 0xb6e2adec in re_main (signalh=0xd365 <handle_signal_handler>) at src/main/main.c:995
re = 0xb6f64650 <global_re>
err = 0
(gdb) print *((struct http_req *)0x42b00)
$1 = {chunk = {size = 0, lf = 0, trailer = false, digit = false, param = false}, srvv = {{u = {sa = {sa_family = 2, sa_data = "\000Px\335B-\000\000\000\000\000\000\000"}, in = {
sin_family = 2, sin_port = 20480, sin_addr = {s_addr = 759356792}, sin_zero = "\000\000\000\000\000\000\000"}, in6 = {sin6_family = 2, sin6_port = 20480,
sin6_flowinfo = 759356792, sin6_addr = {__in6_u = {__u6_addr8 = '\000' <repeats 15 times>}}, sin6_scope_id = 0}, padding = "\002\000\000Px\335B-", '\000' <repeats 19 times>},
len = 16}, {u = {sa = {sa_family = 0, sa_data = '\000' <repeats 13 times>}, in = {sin_family = 0, sin_port = 0, sin_addr = {s_addr = 0}, sin_zero = "\000\000\000\000\000\000\000"},
in6 = {sin6_family = 0, sin6_port = 0, sin6_flowinfo = 0, sin6_addr = {__in6_u = {__u6_addr8 = '\000' <repeats 15 times>}}, sin6_scope_id = 0},
padding = '\000' <repeats 27 times>}, len = 0} <repeats 15 times>}, le = {prev = 0x0, next = 0x0, list = 0x0, data = 0x42b00}, reqp = 0x0, cli = 0x40fc8, msg = 0x0, dq = 0x0,
conn = 0x0, mbreq = 0x45cc8, mb = 0x0, host = 0x422c8 "3gr3dymt1gea1hp111111tsfa4dk.com", resph = 0xdf9d <download_block_file+352>, datah = 0x0, connh = 0x0, arg = 0x0, rx_len = 0,
srvc = 0, port = 80, chunked = false, secure = false, close = false}
static void try_next(struct conn *conn, int err)
{
struct http_req *req = conn->req;
bool retry = conn->usec > 1;
mem_deref(conn);
if (!req)
return;
req->conn = NULL;
if (retry)
++req->srvc;
if (req->srvc > 0 && !req->msg) {
err = req_connect(req);
if (!err)
return;
}
req_close(req, err, NULL);
}
We don't call req_connect
, why err become 0 from 110?
lxlenovostar commented
In the case of some push/pop function stack operation , I use http_request in a wrong way.
int http_request(struct http_req **reqp, struct http_cli *cli, const char *met,
const char *uri, http_resp_h *resph, http_data_h *datah,
void *arg, const char *fmt, ...);
I use a reqp
in stack space, req_close
will set *reqp
to NULL.
static void req_close(struct http_req *req, int err,
const struct http_msg *msg)
{
list_unlink(&req->le);
req->dq = mem_deref(req->dq);
req->datah = NULL;
if (req->conn) {
if (req->connh)
req->connh(req->conn->tc, req->conn->sc, req->arg);
if (err || req->close || req->connh)
mem_deref(req->conn);
else
conn_idle(req->conn);
req->conn = NULL;
}
req->connh = NULL;
if (req->reqp) {
*req->reqp = NULL;
req->reqp = NULL;
}
if (req->resph) {
if (msg)
msg->mb->pos = 0;
req->resph(err, msg, req->arg);
req->resph = NULL;
}
mem_deref(req);
}