[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] Freeing memory after http transfer
From: |
Bernhard 'Gustl' Bauer |
Subject: |
Re: [lwip-users] Freeing memory after http transfer |
Date: |
Fri, 13 Nov 2009 11:01:56 +0100 |
User-agent: |
Thunderbird 2.0.0.23 (Windows/20090812) |
Kieran Mansley schrieb:
Each time tcp_sent is called it tells you how much data has been
released. Keep a count of this. When your count equals the size of
data you sent, you know it's all done.
This is the original http_sent:
static err_t http_sent(void *arg, struct tcp_pcb *pcb, u16_t len) {
struct http_state *hs;
LWIP_UNUSED_ARG(len);
hs = arg;
hs->retries = 0;
if (hs->left > 0) {
send_data(pcb, hs);
} else {
close_conn(pcb, hs);
}
return ERR_OK;
}
If hs->left == 0 this does not mean that all data has already been sent
out. The last packet is just somewere in the pipeline. So the connection
cannot be closed yet.
I can remember something puzzled my when doing the first steps: Used
buffers where freed by a function called from the timers. Probably this
was the cause.
I would suggest to add bytes_to_send and bytes_acked to struct
http_state and to change the function like this:
static err_t http_sent(void *arg, struct tcp_pcb *pcb, u16_t len) {
struct http_state *hs;
LWIP_UNUSED_ARG(len);
hs = arg;
hs->retries = 0;
hs->bytes_acked+=len;
if (hs->left > 0) {
send_data(pcb, hs);
}
if (hs->bytes_acked==hs->bytes_to_send) {
close_conn(pcb, hs);
}
return ERR_OK;
}
- [lwip-users] Freeing memory after http transfer, Bernhard 'Gustl' Bauer, 2009/11/12
- Re: [lwip-users] Freeing memory after http transfer, Simon Goldschmidt, 2009/11/12
- RE: [lwip-users] Freeing memory after http transfer, Bill Auerbach, 2009/11/12
- Re: [lwip-users] Freeing memory after http transfer, Bernhard 'Gustl' Bauer, 2009/11/12
- Re: [lwip-users] Freeing memory after http transfer, Kieran Mansley, 2009/11/12
- Re: [lwip-users] Freeing memory after http transfer,
Bernhard 'Gustl' Bauer <=
- Re: [lwip-users] Freeing memory after http transfer, address@hidden, 2009/11/13
- Re: [lwip-users] Freeing memory after http transfer, Bernhard 'Gustl' Bauer, 2009/11/13
- Re: [lwip-users] Freeing memory after http transfer, address@hidden, 2009/11/13
- Re: [lwip-users] Freeing memory after http transfer, Bernhard 'Gustl' Bauer, 2009/11/16
- Re: [lwip-users] Freeing memory after http transfer, Simon Goldschmidt, 2009/11/16
Re: [lwip-users] Freeing memory after http transfer, Bernhard 'Gustl' Bauer, 2009/11/12