mirror of
https://github.com/janet-lang/janet
synced 2025-06-10 10:34:13 +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: {
|
||||||
janet_mark(state->is_buffer
|
if (state->mode != JANET_ASYNC_WRITEMODE_CONNECT) {
|
||||||
? janet_wrap_buffer(state->src.buf)
|
janet_mark(state->is_buffer
|
||||||
: janet_wrap_string(state->src.str));
|
? janet_wrap_buffer(state->src.buf)
|
||||||
|
: 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;
|
||||||
|
@ -43,10 +43,10 @@ int (janet_truthy)(Janet x) {
|
|||||||
return janet_truthy(x);
|
return janet_truthy(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
JanetStruct (janet_unwrap_struct)(Janet x) {
|
JanetStruct(janet_unwrap_struct)(Janet x) {
|
||||||
return janet_unwrap_struct(x);
|
return janet_unwrap_struct(x);
|
||||||
}
|
}
|
||||||
JanetTuple (janet_unwrap_tuple)(Janet x) {
|
JanetTuple(janet_unwrap_tuple)(Janet x) {
|
||||||
return janet_unwrap_tuple(x);
|
return janet_unwrap_tuple(x);
|
||||||
}
|
}
|
||||||
JanetFiber *(janet_unwrap_fiber)(Janet x) {
|
JanetFiber *(janet_unwrap_fiber)(Janet x) {
|
||||||
@ -61,16 +61,16 @@ JanetTable *(janet_unwrap_table)(Janet x) {
|
|||||||
JanetBuffer *(janet_unwrap_buffer)(Janet x) {
|
JanetBuffer *(janet_unwrap_buffer)(Janet x) {
|
||||||
return janet_unwrap_buffer(x);
|
return janet_unwrap_buffer(x);
|
||||||
}
|
}
|
||||||
JanetString (janet_unwrap_string)(Janet x) {
|
JanetString(janet_unwrap_string)(Janet x) {
|
||||||
return janet_unwrap_string(x);
|
return janet_unwrap_string(x);
|
||||||
}
|
}
|
||||||
JanetSymbol (janet_unwrap_symbol)(Janet x) {
|
JanetSymbol(janet_unwrap_symbol)(Janet x) {
|
||||||
return janet_unwrap_symbol(x);
|
return janet_unwrap_symbol(x);
|
||||||
}
|
}
|
||||||
JanetKeyword (janet_unwrap_keyword)(Janet x) {
|
JanetKeyword(janet_unwrap_keyword)(Janet x) {
|
||||||
return janet_unwrap_keyword(x);
|
return janet_unwrap_keyword(x);
|
||||||
}
|
}
|
||||||
JanetAbstract (janet_unwrap_abstract)(Janet x) {
|
JanetAbstract(janet_unwrap_abstract)(Janet x) {
|
||||||
return janet_unwrap_abstract(x);
|
return janet_unwrap_abstract(x);
|
||||||
}
|
}
|
||||||
void *(janet_unwrap_pointer)(Janet x) {
|
void *(janet_unwrap_pointer)(Janet x) {
|
||||||
@ -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