From 614b6ea634a8a765020ee905100d62d811399af5 Mon Sep 17 00:00:00 2001 From: Dong Heng Date: Tue, 21 Aug 2018 21:15:47 +0800 Subject: [PATCH] feat(esp8266): Perfect AIO function and logic --- components/esp8266/include/esp_socket.h | 30 +++++++++++++++++++++++++ components/esp8266/source/esp_socket.c | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/components/esp8266/include/esp_socket.h b/components/esp8266/include/esp_socket.h index 4ebc6971..5b5ee1f4 100644 --- a/components/esp8266/include/esp_socket.h +++ b/components/esp8266/include/esp_socket.h @@ -137,6 +137,36 @@ typedef struct esp_socket_method { int (*close)(void *index); } esp_socket_method_t; +/* + * @brief free an aio control block by calling the callback function + * + * @param aio asynchronous I/O controlling block + * @param aio data handling result + * + * @return none + */ +static inline void esp_aio_free(esp_aio_t *aio, int status) +{ + if (aio->cb) { + aio->ret = status; + aio->cb(aio); + } +} + +/* + * @brief drop an aio control block by disable "pbuf" and "cb" + * and then the aio control block has no meaning + * + * @param aio asynchronous I/O controlling block + * + * @return none + */ +static inline void esp_aio_drop(esp_aio_t *aio) +{ + aio->pbuf = NULL; + aio->cb = NULL; +} + /* * @brief create a socket file description * diff --git a/components/esp8266/source/esp_socket.c b/components/esp8266/source/esp_socket.c index 6c025be0..74d2def5 100644 --- a/components/esp8266/source/esp_socket.c +++ b/components/esp8266/source/esp_socket.c @@ -25,7 +25,7 @@ #define CRITICAL_EXIT(t) #ifndef ESP_SOCKET_MAX -#define ESP_SOCKET_MAX 3 +#define ESP_SOCKET_MAX 2 #endif #define SET_ERR(err) errno = err