mirror of
https://github.com/janet-lang/janet
synced 2025-08-04 21:13:51 +00:00
Quick fix for discussion #1253
Protect against garbage collection during connect.
This commit is contained in:
parent
63023722d1
commit
8df7364319
@ -2525,14 +2525,17 @@ JanetAsyncStatus ev_machine_write(JanetListenerState *s, JanetAsyncEvent event)
|
|||||||
switch (event) {
|
switch (event) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
case JANET_ASYNC_EVENT_MARK:
|
case JANET_ASYNC_EVENT_MARK: {
|
||||||
|
if (state->mode != JANET_ASYNC_WRITEMODE_CONNECT) {
|
||||||
janet_mark(state->is_buffer
|
janet_mark(state->is_buffer
|
||||||
? janet_wrap_buffer(state->src.buf)
|
? janet_wrap_buffer(state->src.buf)
|
||||||
: janet_wrap_string(state->src.str));
|
: janet_wrap_string(state->src.str));
|
||||||
|
}
|
||||||
if (state->mode == JANET_ASYNC_WRITEMODE_SENDTO) {
|
if (state->mode == JANET_ASYNC_WRITEMODE_SENDTO) {
|
||||||
janet_mark(janet_wrap_abstract(state->dest_abst));
|
janet_mark(janet_wrap_abstract(state->dest_abst));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case JANET_ASYNC_EVENT_CLOSE:
|
case JANET_ASYNC_EVENT_CLOSE:
|
||||||
janet_cancel(s->fiber, janet_cstringv("stream closed"));
|
janet_cancel(s->fiber, janet_cstringv("stream closed"));
|
||||||
return JANET_ASYNC_STATUS_DONE;
|
return JANET_ASYNC_STATUS_DONE;
|
||||||
|
@ -317,4 +317,3 @@ JANET_WRAP_DEFINE(pointer, void *, JANET_POINTER, pointer)
|
|||||||
#undef JANET_WRAP_DEFINE
|
#undef JANET_WRAP_DEFINE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user