mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-26 20:38:25 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b30acaaabb | ||
|
|
dc91248aca |
No files matched your search
+5
-3
@@ -12008,7 +12008,7 @@ static void mg_tcpip_poll(struct mg_tcpip_if *ifp, uint64_t now) {
|
||||
if (expired_1000ms) { // ifp->state rules over state6
|
||||
mg_ip_link(ifp, drv_up, l2_up); // Handle IPv4
|
||||
mg_ip6_link(ifp, drv_up, l2_up); // Handle IPv6
|
||||
if (ifp->state < MG_TCPIP_STATE_UP) MG_ERROR(("Network is down"));
|
||||
if (ifp->state < MG_TCPIP_STATE_UP) MG_ERROR(("Network is down, state %hhu", ifp->state));
|
||||
mg_tcpip_call(ifp, MG_TCPIP_EV_TIMER_1S, NULL);
|
||||
}
|
||||
}
|
||||
@@ -12254,8 +12254,10 @@ static void write_conn(struct mg_connection *c) {
|
||||
}
|
||||
|
||||
static bool can_write(struct mg_connection *c) {
|
||||
return c->is_connecting == 0 && c->is_resolving == 0 && c->send.len > 0 &&
|
||||
c->is_tls_hs == 0 && c->is_arplooking == 0;
|
||||
struct mg_tcpip_if *ifp = c->mgr->ifp;
|
||||
bool ready = (ifp->ip != 0 && ifp->state == MG_TCPIP_STATE_READY);
|
||||
return ready && c->is_connecting == 0 && c->is_resolving == 0 &&
|
||||
c->send.len > 0 && c->is_tls_hs == 0 && c->is_arplooking == 0;
|
||||
}
|
||||
|
||||
void mg_mgr_poll(struct mg_mgr *mgr, int ms) {
|
||||
|
||||
+5
-3
@@ -2200,7 +2200,7 @@ static void mg_tcpip_poll(struct mg_tcpip_if *ifp, uint64_t now) {
|
||||
if (expired_1000ms) { // ifp->state rules over state6
|
||||
mg_ip_link(ifp, drv_up, l2_up); // Handle IPv4
|
||||
mg_ip6_link(ifp, drv_up, l2_up); // Handle IPv6
|
||||
if (ifp->state < MG_TCPIP_STATE_UP) MG_ERROR(("Network is down"));
|
||||
if (ifp->state < MG_TCPIP_STATE_UP) MG_ERROR(("Network is down, state %hhu", ifp->state));
|
||||
mg_tcpip_call(ifp, MG_TCPIP_EV_TIMER_1S, NULL);
|
||||
}
|
||||
}
|
||||
@@ -2446,8 +2446,10 @@ static void write_conn(struct mg_connection *c) {
|
||||
}
|
||||
|
||||
static bool can_write(struct mg_connection *c) {
|
||||
return c->is_connecting == 0 && c->is_resolving == 0 && c->send.len > 0 &&
|
||||
c->is_tls_hs == 0 && c->is_arplooking == 0;
|
||||
struct mg_tcpip_if *ifp = c->mgr->ifp;
|
||||
bool ready = (ifp->ip != 0 && ifp->state == MG_TCPIP_STATE_READY);
|
||||
return ready && c->is_connecting == 0 && c->is_resolving == 0 &&
|
||||
c->send.len > 0 && c->is_tls_hs == 0 && c->is_arplooking == 0;
|
||||
}
|
||||
|
||||
void mg_mgr_poll(struct mg_mgr *mgr, int ms) {
|
||||
|
||||
@@ -1280,6 +1280,8 @@ static void test_frag_send_path(void) {
|
||||
mif.driver = &driver;
|
||||
mif.driver_data = &s_driver_data;
|
||||
mg_tcpip_init(&mgr, &mif);
|
||||
mif.ip = mg_htonl(0xa00001);
|
||||
mif.state = MG_TCPIP_STATE_READY; // so can_write() lets the data out
|
||||
mif.mtu = 500; // force ad hoc small MTU to fragment IP
|
||||
mg_http_listen(&mgr, "http://0.0.0.0:80", frag_send_fn, NULL);
|
||||
mgr.conns->pfn = NULL;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include "mongoose.h"
|
||||
#include <malloc.h>
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
@@ -85,7 +86,6 @@ static void MX_USART3_UART_Init(void);
|
||||
/* Private user code ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN 0 */
|
||||
size_t mg_usage(int task, int metric) {
|
||||
extern void *_sbrk(ptrdiff_t incr);
|
||||
extern unsigned char _end, _sstack, _estack;
|
||||
extern uint32_t _Min_Stack_Size;
|
||||
switch (metric) {
|
||||
@@ -101,10 +101,9 @@ size_t mg_usage(int task, int metric) {
|
||||
}
|
||||
case MG_USAGE_HEAP_TOTAL:
|
||||
return (size_t) &_sstack - (size_t) &_end;
|
||||
case MG_USAGE_HEAP_USED: {
|
||||
size_t heap = (size_t) _sbrk(0), start = (size_t) &_end;
|
||||
return heap >= start && heap <= (size_t) &_sstack ? heap - start : 0;
|
||||
}
|
||||
case MG_USAGE_HEAP_USED:
|
||||
// The program break includes freed blocks retained for reuse by malloc
|
||||
return (size_t) mallinfo().uordblks;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,16 +3,16 @@
|
||||
|
||||
#include "hal.h"
|
||||
#include "mongoose.h"
|
||||
#include <malloc.h>
|
||||
|
||||
size_t mg_usage(int task, int metric) {
|
||||
extern void *_sbrk(int incr);
|
||||
extern unsigned char _end[], _estack[];
|
||||
extern unsigned char _estack[];
|
||||
if (metric == MG_USAGE_NUM_TASKS) return 1;
|
||||
if (metric == MG_USAGE_TASK_NAME) return task == 0 ? (size_t) "main" : 0;
|
||||
// Heap and stack share RAM, so neither has a fixed total.
|
||||
if (metric == MG_USAGE_HEAP_USED) {
|
||||
size_t heap = (size_t) _sbrk(0), start = (size_t) _end;
|
||||
return heap >= start && heap <= (size_t) _estack ? heap - start : 0;
|
||||
// The program break includes freed blocks retained for reuse by malloc
|
||||
return (size_t) mallinfo().uordblks;
|
||||
}
|
||||
if (metric == MG_USAGE_STACK_USED && task == 0) {
|
||||
size_t sp = (size_t) __get_MSP(), top = (size_t) _estack;
|
||||
|
||||
Reference in new issue
Block a user