diff options
| author | Tyge Løvset <[email protected]> | 2023-02-28 19:28:55 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-02-28 19:28:55 +0100 |
| commit | 27e419388b4cee6ea972344ff24cc7ad76d3e8b0 (patch) | |
| tree | 6af085e6a3bc9fcaf23f6005319f692764630177 /include/stc | |
| parent | 158fbcd56a9684423f70e9579bdf2271f8c90b9f (diff) | |
| download | STC-modified-27e419388b4cee6ea972344ff24cc7ad76d3e8b0.tar.gz STC-modified-27e419388b4cee6ea972344ff24cc7ad76d3e8b0.zip | |
Fixed a state issue in coroutine.
Diffstat (limited to 'include/stc')
| -rw-r--r-- | include/stc/algo/coroutine.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/include/stc/algo/coroutine.h b/include/stc/algo/coroutine.h index bf000779..40a98836 100644 --- a/include/stc/algo/coroutine.h +++ b/include/stc/algo/coroutine.h @@ -70,7 +70,7 @@ enum { int *_state = &(ctx)->cco_state; \ switch (*_state) { \ case cco_state_expired: \ - case 0:; \ + case 0: #define cco_end(retval) \ *_state = cco_state_expired; break; \ @@ -90,7 +90,7 @@ enum { do { \ *_state = __LINE__; \ c_PASTE(cco, __LINE__): corocall; if (cco_alive(ctx)) return retval; \ - case __LINE__: if (cco_alive(ctx)) goto c_PASTE(cco, __LINE__); \ + case __LINE__: if ((ctx)->cco_state >= cco_state_final) goto c_PASTE(cco, __LINE__); \ } while (0) #define cco_final \ @@ -102,6 +102,6 @@ enum { #define cco_stop(ctx) \ (((ctx)->cco_state = cco_alive(ctx) ? \ - cco_state_final : cco_state_illegal), ctx) + cco_state_final : cco_state_expired), ctx) #endif |
