Make test NOT fail

This commit is contained in:
Sergio R. Caprile 2022-11-30 17:37:32 -03:00
parent 59b69a3b3b
commit 474a07564c
4 changed files with 16 additions and 3 deletions

View File

@ -925,6 +925,10 @@ void mg_mgr_poll(struct mg_mgr *mgr, int ms) {
mg_timer_poll(&mgr->timers, now);
for (c = mgr->conns; c != NULL; c = tmp) {
tmp = c->next;
mg_call(c, MG_EV_POLL, &now);
MG_VERBOSE(("%lu .. %c%c%c%c%c", c->id, c->is_tls ? 'T' : 't',
c->is_connecting ? 'C' : 'c', c->is_tls_hs ? 'H' : 'h',
c->is_resolving ? 'R' : 'r', c->is_closing ? 'C' : 'c'));
if (c->is_tls_hs) mg_tls_handshake(c);
if (can_write(c)) write_conn(c);
if (c->is_draining && c->send.len == 0) c->is_closing = 1;

View File

@ -7451,6 +7451,10 @@ void mg_mgr_poll(struct mg_mgr *mgr, int ms) {
mg_timer_poll(&mgr->timers, now);
for (c = mgr->conns; c != NULL; c = tmp) {
tmp = c->next;
mg_call(c, MG_EV_POLL, &now);
MG_VERBOSE(("%lu .. %c%c%c%c%c", c->id, c->is_tls ? 'T' : 't',
c->is_connecting ? 'C' : 'c', c->is_tls_hs ? 'H' : 'h',
c->is_resolving ? 'R' : 'r', c->is_closing ? 'C' : 'c'));
if (c->is_tls_hs) mg_tls_handshake(c);
if (can_write(c)) write_conn(c);
if (c->is_draining && c->send.len == 0) c->is_closing = 1;

View File

@ -10,7 +10,7 @@ static size_t mock_tx(const void *buf, size_t len, void *data) {
static size_t mock_rx(void *buf, size_t len, void *data) {
(void) buf, (void) len, (void) data;
return len;
return 0;
}
static bool mock_up(void *data) {

View File

@ -266,12 +266,17 @@ static void ph(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
}
static void test_poll(void) {
int count = 0;
int count = 0, i;
struct mg_mgr mgr;
mg_mgr_init(&mgr);
struct mip_if mif;
memset(&mif, 0, sizeof(mif));
mif.driver = &mip_driver_mock;
mip_init(&mgr, &mif);
mg_http_listen(&mgr, "http://127.0.0.1:12346", ph, &count);
for (int i = 0; i < 10; i++) mg_mgr_poll(&mgr, 0);
for (i = 0; i < 10; i++) mg_mgr_poll(&mgr, 0);
ASSERT(count == 10);
mip_free(&mif);
mg_mgr_free(&mgr);
}