fix `sync/[timeout/]enable-break' semaphore shortcut
The shortcut could be triggered in a bad case (first argument as `#f' in non-timeout mode) and returned the wrong result (void instead of the semaphore).
This commit is contained in:
parent
b041a151e6
commit
c3266ef685
|
@ -1236,4 +1236,10 @@
|
|||
|
||||
;; ----------------------------------------
|
||||
|
||||
(err/rt-test (sync/enable-break #f (make-semaphore 1)))
|
||||
(test #t semaphore? (sync/enable-break (make-semaphore 1)))
|
||||
(test #t semaphore? (sync/timeout/enable-break #f (make-semaphore 1)))
|
||||
|
||||
;; ----------------------------------------
|
||||
|
||||
(report-errs)
|
||||
|
|
|
@ -6759,9 +6759,18 @@ Scheme_Object *scheme_sync_timeout(int argc, Scheme_Object *argv[])
|
|||
|
||||
static Scheme_Object *do_scheme_sync_enable_break(const char *who, int with_timeout, int tailok, int argc, Scheme_Object *argv[])
|
||||
{
|
||||
if (argc == 2 && SCHEME_FALSEP(argv[0]) && SCHEME_SEMAP(argv[1])) {
|
||||
scheme_wait_sema(argv[1], -1);
|
||||
return scheme_void;
|
||||
Scheme_Object *sema;
|
||||
|
||||
if (with_timeout && (argc == 2) && SCHEME_FALSEP(argv[0]) && SCHEME_SEMAP(argv[1]))
|
||||
sema = argv[1];
|
||||
else if (!with_timeout && (argc == 1) && SCHEME_SEMAP(argv[0]))
|
||||
sema = argv[0];
|
||||
else
|
||||
sema = NULL;
|
||||
|
||||
if (sema) {
|
||||
scheme_wait_sema(sema, -1);
|
||||
return sema;
|
||||
}
|
||||
|
||||
return do_sync(who, argc, argv, 1, with_timeout, tailok);
|
||||
|
|
Loading…
Reference in New Issue
Block a user