|
|
@@ -2,7 +2,6 @@
|
|
|
#include "bus.h"
|
|
|
#include "sockutil.h"
|
|
|
#include "url.h"
|
|
|
-#include "memutil.h"
|
|
|
#include "spinlock.h"
|
|
|
#include "list.h"
|
|
|
#include "bus_internal.h"
|
|
|
@@ -13,6 +12,8 @@
|
|
|
#include <winpr/synch.h>
|
|
|
#include <winpr/string.h>
|
|
|
|
|
|
+#include <sys/eventfd.h>
|
|
|
+
|
|
|
#define TAG TOOLKIT_TAG("bus_unix")
|
|
|
|
|
|
#define BUS_RESULT_DATA 1 // ==BUS_TYPE_PACKET, callback: callback.on_pkt, no use
|
|
|
@@ -26,7 +27,7 @@ typedef struct msg_t {
|
|
|
struct list_head entry;
|
|
|
int type;
|
|
|
int nparam;
|
|
|
- int* params;
|
|
|
+ param_size_t* params;
|
|
|
HANDLE evt;
|
|
|
int evt_result;
|
|
|
}msg_t;
|
|
|
@@ -41,10 +42,12 @@ struct bus_endpt_t {
|
|
|
char* url;
|
|
|
/*define here or iom_t area, this is definitely a problem for now.*/
|
|
|
evtpoll_t* ep;
|
|
|
+ int msg_fd;
|
|
|
+ event_epoll_data_t* msg_sem;
|
|
|
bus_endpt_callback callback;
|
|
|
struct list_head msg_list;
|
|
|
spinlock_t msg_lock;
|
|
|
- HANDLE msg_sem;
|
|
|
+
|
|
|
HANDLE tx_evt; //manually
|
|
|
HANDLE rx_evt; //manually
|
|
|
OVERLAPPED rx_overlapped;
|
|
|
@@ -61,6 +64,15 @@ static void free_msg(msg_t* msg)
|
|
|
free(msg);
|
|
|
}
|
|
|
|
|
|
+static __inline int bus_endpoint__data_is_handle(const bus_endpt_t* endpt, void* data)
|
|
|
+{
|
|
|
+ if ((endpt->type == TYPE_TCP && data == &endpt->sock_handle) ||
|
|
|
+ (endpt->type == TYPE_PIPE && data == &endpt->pipe_handle)) {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
static int to_result(int pkt_type)
|
|
|
{
|
|
|
switch (pkt_type) {
|
|
|
@@ -154,7 +166,7 @@ static int tcp_send_buf(bus_endpt_t* endpt, const char* buf, int n)
|
|
|
{
|
|
|
DWORD left = n;
|
|
|
DWORD offset = 0;
|
|
|
- WLog_DBG(TAG, "fd(%d): tcp send buf len: %d", endpt->sock_handle, n);
|
|
|
+ WLog_DBG(TAG, "==> fd(%d): tcp send buf len: %d", endpt->sock_handle, n);
|
|
|
while (left > 0) {
|
|
|
BOOL ret;
|
|
|
WSABUF wsabuf;
|
|
|
@@ -206,9 +218,11 @@ static int tcp_send_buf(bus_endpt_t* endpt, const char* buf, int n)
|
|
|
left -= dwBytesTransfer;
|
|
|
}
|
|
|
else {
|
|
|
+ WLog_DBG(TAG, "<== error fd(%d): tcp send buf left: %d", endpt->sock_handle, left);
|
|
|
return -1;
|
|
|
}
|
|
|
}
|
|
|
+ WLog_DBG(TAG, "<== fd(%d): tcp send buf len: %d", endpt->sock_handle, n);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
@@ -390,13 +404,8 @@ static int start_read_pkt(bus_endpt_t* endpt, iobuffer_t** p_pkt)
|
|
|
iobuffer_t* pkt = NULL;
|
|
|
|
|
|
*p_pkt = NULL;
|
|
|
- WLog_DBG(TAG, "==> start_read_pkt");
|
|
|
-
|
|
|
+ WLog_DBG(TAG, "==>endpt(%d): start_read_pkt", endpt->epid);
|
|
|
ResetEvent(endpt->rx_evt);
|
|
|
- /*we control it.*/
|
|
|
- //memset(&endpt->rx_overlapped, 0, sizeof(OVERLAPPED));
|
|
|
- //ioqueue_overlapped_set_mask(&endpt->rx_overlapped, sizeof(OVERLAPPED));
|
|
|
- endpt->rx_overlapped.hEvent = endpt->rx_evt;
|
|
|
endpt->rx_pending_pkt_uc_len = 0;
|
|
|
|
|
|
if (endpt->type == TYPE_PIPE) {
|
|
|
@@ -437,7 +446,7 @@ static int start_read_pkt(bus_endpt_t* endpt, iobuffer_t** p_pkt)
|
|
|
return 0;
|
|
|
}
|
|
|
else if(errno == EAGAIN || errno == EWOULDBLOCK) {
|
|
|
- WLog_DBG(TAG, "set rx pending flag.");
|
|
|
+ WLog_DBG(TAG, "endpt(%d): set rx pending flag.", endpt->epid);
|
|
|
endpt->rx_pending = 1;
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -486,6 +495,7 @@ static int read_left_pkt(bus_endpt_t* endpt, iobuffer_t** p_pkt)
|
|
|
|
|
|
iobuffer_push_count(pkt, endpt->rx_pending_pkt_len);
|
|
|
*p_pkt = pkt;
|
|
|
+ WLog_DBG(TAG, "endpt(%d): reset rx_pending", endpt->epid);
|
|
|
endpt->rx_pending = 0;
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -529,6 +539,8 @@ TOOLKIT_API int bus_endpt_create(const char* url, int epid, const bus_endpt_call
|
|
|
|
|
|
endpt = ZALLOC_T(bus_endpt_t);
|
|
|
endpt->sock_handle = -1;
|
|
|
+ endpt->msg_fd = -1;
|
|
|
+ endpt->ep = NULL;
|
|
|
endpt->url = tmp_url;
|
|
|
|
|
|
if (_stricmp(uf.scheme, "tcp") == 0) {
|
|
|
@@ -559,7 +571,12 @@ TOOLKIT_API int bus_endpt_create(const char* url, int epid, const bus_endpt_call
|
|
|
endpt->tx_evt = CreateEventA(NULL, TRUE, FALSE, NULL);
|
|
|
endpt->rx_evt = CreateEventA(NULL, TRUE, FALSE, NULL);
|
|
|
endpt->rx_buf_queue = iobuffer_queue_create();
|
|
|
- endpt->msg_sem = CreateSemaphoreA(NULL, 0, 0x7fffffff, NULL);
|
|
|
+ endpt->msg_fd = eventfd(0, EFD_CLOEXEC | EFD_SEMAPHORE);
|
|
|
+ if (endpt->msg_fd == -1) {
|
|
|
+ WLog_ERR(TAG, "create event fd failed: %s(%d)", strerror(errno), errno);
|
|
|
+ goto on_error;
|
|
|
+ }
|
|
|
+
|
|
|
INIT_LIST_HEAD(&endpt->msg_list);
|
|
|
spinlock_init(&endpt->msg_lock);
|
|
|
memcpy(&endpt->callback, callback, sizeof(bus_endpt_callback));
|
|
|
@@ -590,19 +607,30 @@ TOOLKIT_API int bus_endpt_create(const char* url, int epid, const bus_endpt_call
|
|
|
if (ans_buf)
|
|
|
iobuffer_destroy(ans_buf);
|
|
|
|
|
|
+ if (-1 == evtpoll_attach(endpt->ep, endpt->msg_fd)) {
|
|
|
+ goto on_error;
|
|
|
+ }
|
|
|
+ if (evtpoll_subscribe(endpt->ep, EV_READ, endpt->msg_fd, &endpt->msg_fd, NULL)) {
|
|
|
+ WLog_ERR(TAG, "epoll subscribe bus endpt eventfd failed.");
|
|
|
+ goto on_error_msg;
|
|
|
+ }
|
|
|
+
|
|
|
/* subscribe read event [3/27/2020 Gifur] */
|
|
|
- ioqueue_overlapped_set_mask(&endpt->rx_overlapped, sizeof(OVERLAPPED));
|
|
|
if (evtpoll_attach(endpt->ep, endpt->sock_handle)) {
|
|
|
WLog_ERR(TAG, "epoll attch bus endpt failed.");
|
|
|
- goto on_error;
|
|
|
+ goto on_error_msg;
|
|
|
}
|
|
|
- if (evtpoll_subscribe(endpt->ep, EV_READ, endpt->sock_handle, &endpt->rx_overlapped, NULL)) {
|
|
|
+ if (evtpoll_subscribe(endpt->ep, EV_READ, endpt->sock_handle, &endpt->sock_handle, NULL)) {
|
|
|
WLog_ERR(TAG, "epoll subscribe bus endpt failed.");
|
|
|
- goto on_error;
|
|
|
+ goto on_error_handle;
|
|
|
}
|
|
|
*p_endpt = endpt;
|
|
|
return 0;
|
|
|
|
|
|
+on_error_handle:
|
|
|
+ evtpoll_detach(endpt->ep, endpt->sock_handle);
|
|
|
+on_error_msg:
|
|
|
+ evtpoll_detach(endpt->ep, endpt->msg_fd);
|
|
|
on_error:
|
|
|
if (endpt->type == TYPE_TCP) {
|
|
|
closesocket(endpt->sock_handle);
|
|
|
@@ -610,8 +638,8 @@ on_error:
|
|
|
else if (endpt->type == TYPE_PIPE) {
|
|
|
CloseHandle(endpt->pipe_handle);
|
|
|
}
|
|
|
- if (endpt->msg_sem)
|
|
|
- CloseHandle(endpt->msg_sem);
|
|
|
+ if (endpt->msg_fd > 0)
|
|
|
+ close(endpt->msg_fd);
|
|
|
if (endpt->tx_evt)
|
|
|
CloseHandle(endpt->tx_evt);
|
|
|
if (endpt->rx_evt)
|
|
|
@@ -626,6 +654,9 @@ on_error:
|
|
|
iobuffer_destroy(buf);
|
|
|
if (ans_buf)
|
|
|
iobuffer_destroy(ans_buf);
|
|
|
+ if (endpt->ep != NULL) {
|
|
|
+ evtpoll_destroy(endpt->ep);
|
|
|
+ }
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
@@ -673,8 +704,8 @@ on_error:
|
|
|
else if (endpt->type == TYPE_PIPE) {
|
|
|
CloseHandle(endpt->pipe_handle);
|
|
|
}
|
|
|
- if (endpt->msg_sem)
|
|
|
- CloseHandle(endpt->msg_sem);
|
|
|
+ if (endpt->msg_fd)
|
|
|
+ close(endpt->msg_fd);
|
|
|
if (endpt->tx_evt)
|
|
|
CloseHandle(endpt->tx_evt);
|
|
|
if (endpt->rx_evt)
|
|
|
@@ -734,30 +765,25 @@ static int bus_endpt_poll_internal(bus_endpt_t* endpt, int* result, int timeout)
|
|
|
int i;
|
|
|
struct epoll_event events[MAX_EPOLL_EVENT];
|
|
|
struct epoll_event* pe;
|
|
|
- nfds = epoll_wait(evtpoll_get_epoll_fd(endpt->ep) , events, MAX_EPOLL_EVENT, timeout);
|
|
|
+ nfds = evtpoll_wait(endpt->ep, events, MAX_EPOLL_EVENT, timeout);
|
|
|
if (nfds == 0) {
|
|
|
- assert(timeout != -1);
|
|
|
WLog_DBG(TAG, "epoll wait timeout.");
|
|
|
return 0; //timeout
|
|
|
}
|
|
|
- if (nfds == -1 && errno != EINTR) {
|
|
|
- WLog_ERR(TAG, "epoll wait error: %s(%d)", strerror(errno), errno);
|
|
|
+ if (nfds == -1) {
|
|
|
return -1;
|
|
|
}
|
|
|
WLog_DBG(TAG, "epoll wait return nfd: %d", nfds);
|
|
|
for (i = 0; i < nfds; ++i) {
|
|
|
- void* io_ctx = NULL;
|
|
|
+ void* pdata = NULL;
|
|
|
pe = events + i;
|
|
|
WLog_INFO(TAG, "loop events[%d]::fd(0x%08X) OUT:%d, IN:%d", i, pe->data.fd,
|
|
|
pe->events & EPOLLOUT ? 1 : 0, pe->events & EPOLLIN ? 1 : 0);
|
|
|
assert(pe->events & EPOLLIN);
|
|
|
- ret = evtpoll_deal(endpt->ep, pe, &io_ctx);
|
|
|
- if (ret > 0) {
|
|
|
- assert(io_ctx);
|
|
|
-#if 1 //DEBUG
|
|
|
- uint32_t io_type = ioqueue_overlapped_get_type(io_ctx);
|
|
|
- assert(io_type == EV_BUS_ENDPOINT);
|
|
|
-#endif
|
|
|
+ ret = evtpoll_deal(endpt->ep, pe, &pdata, 0);
|
|
|
+ if (!ret) {
|
|
|
+ assert(pdata);
|
|
|
+ if(bus_endpoint__data_is_handle(endpt, pdata))
|
|
|
{
|
|
|
rc = read_left_pkt(endpt, &pkt);
|
|
|
if (rc < 0)
|
|
|
@@ -770,6 +796,21 @@ static int bus_endpt_poll_internal(bus_endpt_t* endpt, int* result, int timeout)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ else if (pdata == &endpt->msg_fd) {
|
|
|
+ uint64_t rdata;
|
|
|
+ WLog_DBG(TAG, "message arrive.");
|
|
|
+ do
|
|
|
+ {
|
|
|
+ ret = read(endpt->msg_fd, &rdata, sizeof rdata);
|
|
|
+ } while (ret < 0 && errno == EINTR);
|
|
|
+
|
|
|
+ if (ret < 0) {
|
|
|
+ WLog_ERR(TAG, "read msg fd failed: %s", strerror(errno));
|
|
|
+ abort();
|
|
|
+ }
|
|
|
+ *result = BUS_RESULT_MSG;
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -799,22 +840,45 @@ static int recv_until(bus_endpt_t* endpt, int type, iobuffer_t** p_ansbuf)
|
|
|
int rc;
|
|
|
iobuffer_t* ans_pkt = NULL;
|
|
|
int ans_type;
|
|
|
-
|
|
|
+ WLog_DBG(TAG, "==>endpt(%d): recv until type: 0x%08X", endpt->epid, type);
|
|
|
for (;;) {
|
|
|
if (!endpt->rx_pending) {
|
|
|
rc = start_read_pkt(endpt, &ans_pkt);
|
|
|
if (rc < 0) {
|
|
|
- DWORD dwError = WSAGetLastError();
|
|
|
break;
|
|
|
}
|
|
|
+ } else {
|
|
|
+ WLog_DBG(TAG, "endpt(%d) is pending", endpt->epid);
|
|
|
}
|
|
|
if (!ans_pkt) {
|
|
|
- DWORD ret = WaitForSingleObject(endpt->rx_evt, INFINITE);
|
|
|
- if (ret != WAIT_OBJECT_0)
|
|
|
+ int nfds;
|
|
|
+ int ret;
|
|
|
+ int i, flag = 0;
|
|
|
+ struct epoll_event events[MAX_EPOLL_EVENT];
|
|
|
+ struct epoll_event* pe;
|
|
|
+ nfds = evtpoll_wait(endpt->ep, events, MAX_EPOLL_EVENT, -1);
|
|
|
+ if (nfds == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (nfds == -1) {
|
|
|
return -1;
|
|
|
- rc = read_left_pkt(endpt, &ans_pkt);
|
|
|
- if (rc < 0)
|
|
|
- break;
|
|
|
+ }
|
|
|
+ WLog_DBG(TAG, "epoll wait return nfd: %d", nfds);
|
|
|
+ for (i = 0; i < nfds; ++i) {
|
|
|
+ void* pdata = NULL;
|
|
|
+ pe = events + i;
|
|
|
+ ret = evtpoll_deal(endpt->ep, pe, &pdata, 0);
|
|
|
+ if (!ret && bus_endpoint__data_is_handle(endpt, pdata)) {
|
|
|
+ flag = 1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (flag) {
|
|
|
+ rc = read_left_pkt(endpt, &ans_pkt);
|
|
|
+ if (rc < 0) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
if (ans_pkt) {
|
|
|
int read_state = iobuffer_get_read_state(ans_pkt);
|
|
|
@@ -836,7 +900,6 @@ static int recv_until(bus_endpt_t* endpt, int type, iobuffer_t** p_ansbuf)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
return rc;
|
|
|
}
|
|
|
|
|
|
@@ -868,14 +931,12 @@ static int recv_until_state(bus_endpt_t* endpt, int* p_state)
|
|
|
rc = recv_until(endpt, BUS_TYPE_ENDPT_GET_STATE, &ans_pkt);
|
|
|
if (rc < 0)
|
|
|
return rc;
|
|
|
-
|
|
|
iobuffer_read(ans_pkt, IOBUF_T_I4, &type, 0);
|
|
|
iobuffer_read(ans_pkt, IOBUF_T_I4, &epid, 0);
|
|
|
iobuffer_read(ans_pkt, IOBUF_T_I4, &state, 0);
|
|
|
iobuffer_destroy(ans_pkt);
|
|
|
-
|
|
|
+ WLog_DBG(TAG, "state address: 0x%08X", p_state);
|
|
|
*p_state = state;
|
|
|
-
|
|
|
return rc;
|
|
|
}
|
|
|
|
|
|
@@ -925,7 +986,7 @@ TOOLKIT_API int bus_endpt_send_info(bus_endpt_t* endpt, int epid, int type, iobu
|
|
|
int write_state;
|
|
|
|
|
|
assert(endpt);
|
|
|
-
|
|
|
+ WLog_DBG(TAG, "endpt(%d) send info: %d, %d.", endpt->epid, epid, type);
|
|
|
read_state = iobuffer_get_read_state(pkt);
|
|
|
write_state = iobuffer_get_write_state(pkt);
|
|
|
|
|
|
@@ -1093,9 +1154,10 @@ TOOLKIT_API int bus_endpt_get_state(bus_endpt_t* endpt, int epid, int* p_state)
|
|
|
iobuffer_write(buf, IOBUF_T_I4, &v, 0);
|
|
|
|
|
|
rc = send_pkt_raw(endpt, buf);
|
|
|
- if (rc < 0)
|
|
|
+ if (rc < 0) {
|
|
|
+ WLog_ERR(TAG, "send pkt raw failed.");
|
|
|
goto on_error;
|
|
|
-
|
|
|
+ }
|
|
|
rc = recv_until_state(endpt, p_state);
|
|
|
|
|
|
on_error:
|
|
|
@@ -1106,18 +1168,19 @@ on_error:
|
|
|
return rc;
|
|
|
}
|
|
|
|
|
|
-TOOLKIT_API int bus_endpt_post_msg(bus_endpt_t* endpt, int msg, int nparam, int params[])
|
|
|
+TOOLKIT_API int bus_endpt_post_msg(bus_endpt_t* endpt, int msg, int nparam, param_size_t params[])
|
|
|
{
|
|
|
msg_t* e;
|
|
|
-
|
|
|
+ int rc;
|
|
|
+ uint64_t wdata = 0;
|
|
|
assert(endpt);
|
|
|
-
|
|
|
+ WLog_DBG(TAG, "==> endpt(%d) post msg: %d", endpt->epid, msg);
|
|
|
e = MALLOC_T(msg_t);
|
|
|
e->type = msg;
|
|
|
e->nparam = nparam;
|
|
|
if (nparam) {
|
|
|
- e->params = (int*)malloc(sizeof(int) * nparam);
|
|
|
- memcpy(e->params, params, sizeof(int) * nparam);
|
|
|
+ e->params = (param_size_t*)malloc(sizeof(param_size_t) * nparam);
|
|
|
+ memcpy(e->params, params, sizeof(param_size_t) * nparam);
|
|
|
}
|
|
|
else {
|
|
|
e->params = NULL;
|
|
|
@@ -1126,40 +1189,55 @@ TOOLKIT_API int bus_endpt_post_msg(bus_endpt_t* endpt, int msg, int nparam, int
|
|
|
spinlock_enter(&endpt->msg_lock, -1);
|
|
|
list_add_tail(&e->entry, &endpt->msg_list);
|
|
|
spinlock_leave(&endpt->msg_lock);
|
|
|
- ReleaseSemaphore(endpt->msg_sem, 1, NULL);
|
|
|
-
|
|
|
+ wdata = 1;
|
|
|
+ rc = write(endpt->msg_fd, &wdata, sizeof wdata);
|
|
|
+ if (rc == -1) {
|
|
|
+ WLog_ERR(TAG, "write to eventfd failed: %s(%d)", strerror(errno), errno);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-TOOLKIT_API int bus_endpt_send_msg(bus_endpt_t* endpt, int msg, int nparam, int params[])
|
|
|
+TOOLKIT_API int bus_endpt_send_msg(bus_endpt_t* endpt, int msg, int nparam, param_size_t params[])
|
|
|
{
|
|
|
msg_t e;
|
|
|
-
|
|
|
+ int rc;
|
|
|
+ uint64_t wdata = 0;
|
|
|
assert(endpt);
|
|
|
-
|
|
|
+ WLog_DBG(TAG, "==> endpt(%d) send msg: %d, %d", endpt->epid, msg, nparam);
|
|
|
e.type = msg;
|
|
|
e.nparam = nparam;
|
|
|
if (nparam) {
|
|
|
- e.params = (int*)malloc(sizeof(int) * nparam);
|
|
|
- memcpy(e.params, params, sizeof(int) * nparam);
|
|
|
+ e.params = (param_size_t*)malloc(sizeof(param_size_t) * nparam);
|
|
|
+ memcpy(e.params, params, sizeof(param_size_t) * nparam);
|
|
|
}
|
|
|
else {
|
|
|
e.params = NULL;
|
|
|
}
|
|
|
e.evt_result = 0;
|
|
|
e.evt = CreateEventA(NULL, TRUE, FALSE, NULL);
|
|
|
+ assert(e.evt != NULL);
|
|
|
spinlock_enter(&endpt->msg_lock, -1);
|
|
|
list_add_tail(&e.entry, &endpt->msg_list);
|
|
|
spinlock_leave(&endpt->msg_lock);
|
|
|
- ReleaseSemaphore(endpt->msg_sem, 1, NULL);
|
|
|
-
|
|
|
+ wdata = 1;
|
|
|
+ rc = write(endpt->msg_fd, &wdata, sizeof wdata);
|
|
|
+ if (rc == -1) {
|
|
|
+ WLog_ERR(TAG, "write to eventfd failed: %s(%d)", strerror(errno), errno);
|
|
|
+ CloseHandle(e.evt);
|
|
|
+ if (nparam) {
|
|
|
+ free(e.params);
|
|
|
+ }
|
|
|
+ WLog_DBG(TAG, "<== error endpt(%d) send msg: %d", endpt->epid, msg);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
WaitForSingleObject(e.evt, INFINITE);
|
|
|
CloseHandle(e.evt);
|
|
|
|
|
|
if (nparam) {
|
|
|
free(e.params);
|
|
|
}
|
|
|
-
|
|
|
+ WLog_DBG(TAG, "<== endpt(%d) send msg: %d, res: %d", endpt->epid, msg, e.evt_result);
|
|
|
return e.evt_result;
|
|
|
}
|
|
|
|
|
|
@@ -1219,17 +1297,23 @@ TOOLKIT_API int bus_endpt_poll(bus_endpt_t* endpt, int timeout)
|
|
|
msg->params,
|
|
|
msg->evt ? &msg->evt_result : NULL,
|
|
|
endpt->callback.user_data);
|
|
|
- if (msg->evt)
|
|
|
+ if (msg->evt) {
|
|
|
+ WLog_DBG(TAG, "after recv msg, send finished evt.");
|
|
|
SetEvent(msg->evt);
|
|
|
- else
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ WLog_DBG(TAG, "free msg");
|
|
|
free_msg(msg);
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
if (msg->evt) {
|
|
|
msg->evt_result = -1;
|
|
|
+ WLog_DBG(TAG, "after on msg failed, send finished evt.");
|
|
|
SetEvent(msg->evt);
|
|
|
}
|
|
|
else {
|
|
|
+ WLog_DBG(TAG, "free msg");
|
|
|
free_msg(msg);
|
|
|
}
|
|
|
}
|