1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

esp32: reapply pending count just for esp32

This commit is contained in:
Andy Green 2017-05-07 08:19:55 +08:00
parent 57e020a826
commit 5468812946
6 changed files with 29 additions and 6 deletions

View file

@ -10,11 +10,13 @@ CROSS_PATH:= $(shell dirname $(CROSS_PATH1) )/..
# -DOPENSSL_LIBRARIES="${PWD}/../../boringssl/build/ssl/libssl.a;${PWD}/../../boringssl/build/crypto/libcrypto.a" \
# -DOPENSSL_INCLUDE_DIRS="${PWD}/../../boringssl/include" \
# -DNDEBUG=1 after cflags
.PHONY: build
build:
cd $(COMPONENT_BUILD_DIR) ; \
echo "doing lws cmake" ; \
cmake $(COMPONENT_PATH) -DLWS_C_FLAGS="$(CFLAGS) -DNDEBUG=1 " \
cmake $(COMPONENT_PATH) -DLWS_C_FLAGS="$(CFLAGS) -DNDEBUG=1" \
-DIDF_PATH=$(IDF_PATH) \
-DCROSS_PATH=$(CROSS_PATH) \
-DCOMPONENT_PATH=$(COMPONENT_PATH) \

View file

@ -159,6 +159,8 @@ int lws_issue_raw(struct lws *wsi, unsigned char *buf, size_t len)
n = lws_ssl_capable_write(wsi, buf, n);
lws_latency(context, wsi, "send lws_issue_raw", n, n == len);
//lwsl_notice("lws_ssl_capable_write: %d\n", n);
switch (n) {
case LWS_SSL_CAPABLE_ERROR:
/* we're going to close, let close know sends aren't possible */
@ -202,7 +204,7 @@ handle_truncated_send:
* Newly truncated send. Buffer the remainder (it will get
* first priority next time the socket is writable)
*/
lwsl_info("%p new partial sent %d from %lu total\n", wsi, n,
lwsl_debug("%p new partial sent %d from %lu total\n", wsi, n,
(unsigned long)real_len);
/*
@ -813,5 +815,9 @@ LWS_VISIBLE int
lws_ssl_pending_no_ssl(struct lws *wsi)
{
(void)wsi;
#if defined(LWS_WITH_ESP32)
return 100;
#else
return 0;
#endif
}

View file

@ -90,8 +90,10 @@ lws_handle_POLLOUT_event(struct lws *wsi, struct lws_pollfd *pollfd)
/* leave POLLOUT active either way */
goto bail_ok;
} else
if (wsi->state == LWSS_FLUSHING_STORED_SEND_BEFORE_CLOSE)
if (wsi->state == LWSS_FLUSHING_STORED_SEND_BEFORE_CLOSE) {
wsi->socket_is_permanently_unusable = 1;
goto bail_die; /* retry closing now */
}
if (wsi->mode == LWSCM_WSCL_ISSUE_HTTP_BODY)
goto user_service;
@ -906,8 +908,11 @@ lws_service_fd_tsi(struct lws_context *context, struct lws_pollfd *pollfd, int t
#endif
// lwsl_debug("fd=%d, revents=%d, mode=%d, state=%d\n", pollfd->fd, pollfd->revents, (int)wsi->mode, (int)wsi->state);
if (pollfd->revents & LWS_POLLHUP)
if (pollfd->revents & LWS_POLLHUP) {
lwsl_debug("pollhup\n");
wsi->socket_is_permanently_unusable = 1;
goto close_and_handled;
}
#ifdef LWS_OPENSSL_SUPPORT
@ -1318,7 +1323,7 @@ drain:
goto handled;
close_and_handled:
lwsl_debug("Close and handled\n");
lwsl_debug("%p: Close and handled\n", wsi);
lws_close_free_wsi(wsi, LWS_CLOSE_STATUS_NOSTATUS);
/*
* pollfd may point to something else after the close

View file

@ -334,6 +334,7 @@ lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, int len)
if (n < 0) {
n = lws_ssl_get_error(wsi, n);
lwsl_notice("get_ssl_err result %d\n", n);
if (n == SSL_ERROR_WANT_READ || SSL_want_read(wsi->ssl)) {
lwsl_debug("%s: WANT_READ\n", __func__);
lwsl_debug("%p: LWS_SSL_CAPABLE_MORE_SERVICE\n", wsi);

View file

@ -59,7 +59,7 @@ static void ota_reboot_timer_cb(TimerHandle_t t)
const esp_partition_t *
ota_choose_part(void)
{
const esp_partition_t *bootpart, *part;
const esp_partition_t *bootpart, *part = NULL;
esp_partition_iterator_t i;
bootpart = lws_esp_ota_get_boot_partition();

View file

@ -39,6 +39,7 @@ struct store_json {
struct per_session_data__esplws_scan {
struct per_session_data__esplws_scan *next;
scan_state scan_state;
struct timeval last_send;
struct lws_spa *spa;
char filename[32];
@ -361,6 +362,7 @@ callback_esplws_scan(struct lws *wsi, enum lws_callback_reasons reason,
}
switch (pss->scan_state) {
struct timeval t;
char ssid[32];
uint8_t mac[6];
struct lws_esp32_image i;
@ -369,6 +371,12 @@ callback_esplws_scan(struct lws *wsi, enum lws_callback_reasons reason,
case SCAN_STATE_INITIAL:
gettimeofday(&t, NULL);
if (t.tv_sec - pss->last_send.tv_sec < 10)
return 0;
pss->last_send = t;
ESP_ERROR_CHECK(nvs_open("lws-station", NVS_READWRITE, &nvh));
n = 0;
if (nvs_get_blob(nvh, "ssl-pub.der", NULL, &s) == ESP_OK)
@ -495,6 +503,7 @@ scan_state_final:
return 0;
}
issue:
// lwsl_notice("issue: %d (%d)\n", p - start, n);
m = lws_write(wsi, (unsigned char *)start, p - start, n);
if (m < 0) {
lwsl_err("ERROR %d writing to di socket\n", m);