io: fixed a bug in net_io_write_async
io: the code in net_io_write_async at line 272
was selectively setting u_conn->coro while calling
flb_coro_yield indiscriminately, this resulted in
coroutines that were not being resumed.
io: moved all the u_conn->coro immediately before / after
the flb_coro_yield calls.
@@ -205,7 +205,6 @@ static FLB_INLINE int net_io_write_async(struct flb_coro *co,
if (bytes == -1) {
if (FLB_WOULDBLOCK()) {
- u_conn->coro = co;
ret = mk_event_add(u_conn->evl,
u_conn->fd,
FLB_ENGINE_EV_THREAD,
@@ -218,6 +217,8 @@ static FLB_INLINE int net_io_write_async(struct flb_coro *co,
return -1;
}
+ u_conn->coro = co;
+
/*
* Return the control to the parent caller, we need to wait for
* the event loop to get back to us.
@@ -269,7 +270,6 @@ static FLB_INLINE int net_io_write_async(struct flb_coro *co,
if (total < len) {
if (u_conn->event.status == MK_EVENT_NONE) {
u_conn->event.mask = MK_EVENT_EMPTY;
- u_conn->coro = co;
ret = mk_event_add(u_conn->evl,
u_conn->fd,
FLB_ENGINE_EV_THREAD,
@@ -283,6 +283,8 @@ static FLB_INLINE int net_io_write_async(struct flb_coro *co,
}
}
+ u_conn->coro = co;
+
flb_coro_yield(co, MK_FALSE);
/* We want this field to hold NULL at all times unless we are explicitly
@@ -326,7 +328,6 @@ static FLB_INLINE ssize_t net_io_read_async(struct flb_coro *co,
ret = recv(u_conn->fd, buf, len, 0);
if (ret == -1) {
if (FLB_WOULDBLOCK()) {
- u_conn->coro = co;
ret = mk_event_add(u_conn->evl,
u_conn->fd,
FLB_ENGINE_EV_THREAD,
@@ -339,6 +340,8 @@ static FLB_INLINE ssize_t net_io_read_async(struct flb_coro *co,
return -1;
}
+ u_conn->coro = co;
+
flb_coro_yield(co, MK_FALSE);
/* We want this field to hold NULL at all times unless we are explicitly
