fix sync and custom-input-port bugs

svn: r1452
This commit is contained in:
Matthew Flatt 2005-12-01 02:51:28 +00:00
parent fcb91fb16b
commit 7124e7f063
3 changed files with 24 additions and 12 deletions

View File

@ -1042,7 +1042,7 @@ static long user_read_result(const char *who, Scheme_Input_Port *port,
} else if (evt_ok && scheme_is_evt(val)) {
/* A peek/read failed, and we were given a evt that unblocks
when the read/peek (at some offset) succeeds. */
if (nonblock) {
if (nonblock > 0) {
if (sinfo) {
scheme_set_sync_target(sinfo, val, (Scheme_Object *)port, NULL, 0, 1);
return 0;
@ -1155,6 +1155,7 @@ user_get_or_peek_bytes(Scheme_Input_Port *port,
fun = uip->read_proc;
while (1) {
int nb;
if (uip->reuse_str && (size == SCHEME_BYTE_STRLEN_VAL(uip->reuse_str))) {
bstr = uip->reuse_str;
@ -1168,6 +1169,13 @@ user_get_or_peek_bytes(Scheme_Input_Port *port,
a[1] = peek_skip;
a[2] = unless ? unless : scheme_false;
nb = nonblock;
if (!nb) {
if (scheme_can_break(scheme_current_thread)) {
nb = -1;
}
}
/* Disable breaks while calling the port's function: */
scheme_push_break_enable(&cframe, 0, 0);
@ -1180,7 +1188,7 @@ user_get_or_peek_bytes(Scheme_Input_Port *port,
}
r = user_read_result(peek ? "user port peek" : "user port read",
port, val, bstr, peek, nonblock,
port, val, bstr, peek, nb,
1, !!uip->peek_proc, unless && SCHEME_CDR(unless), sinfo);
scheme_pop_break_enable(&cframe, 1);

View File

@ -749,6 +749,8 @@ int scheme_wait_semas_chs(int n, Scheme_Object **o, int just_try, Syncing *synci
--semas[i]->value;
break;
}
} else if (semas[i]->so.type == scheme_never_evt_type) {
/* Never ready. */
} else if (try_channel(semas[i], syncing, i, NULL))
break;
}

View File

@ -5247,21 +5247,23 @@ static Scheme_Object *do_sync(const char *name, int argc, Scheme_Object *argv[],
if (l) {
for (; SCHEME_PAIRP(l); l = SCHEME_CDR(l)) {
a = SCHEME_CAR(l);
if (to_call) {
args[0] = o;
/* Call wrap proc with breaks disabled */
scheme_push_break_enable(&cframe, 0, 0);
o = scheme_apply(to_call, 1, args);
scheme_pop_break_enable(&cframe, 0);
to_call = NULL;
}
if (SCHEME_BOXP(a) || SCHEME_PROCP(a)) {
if (SCHEME_BOXP(a)) {
a = SCHEME_BOX_VAL(a);
to_call_is_cont = 1;
}
if (to_call) {
args[0] = o;
/* Call wrap proc with breaks disabled */
scheme_push_break_enable(&cframe, 0, 0);
o = scheme_apply(to_call, 1, args);
scheme_pop_break_enable(&cframe, 0);
}
to_call = a;
} else if (SAME_TYPE(scheme_thread_suspend_type, SCHEME_TYPE(a))
|| SAME_TYPE(scheme_thread_resume_type, SCHEME_TYPE(a)))