| 1 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 2 |
;;; Test that serve-event doesn't leak its handlers to other threads |
| 3 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 4 |
|
| 5 |
(require 'serve-event) |
| 6 |
|
| 7 |
(defun test-leak (&aux exit) |
| 8 |
(let ((out *standard-output*)) |
| 9 |
(print "Press enter." out) |
| 10 |
(let* ((p1 (mp:process-run-function |
| 11 |
'stdin-2 |
| 12 |
(lambda () |
| 13 |
(serve-event:with-fd-handler |
| 14 |
(0 :input #'(lambda (fd) |
| 15 |
(declare (ignore fd)) |
| 16 |
(format out "WRONG!~%"))) |
| 17 |
(sleep most-positive-fixnum))))) |
| 18 |
(p2 (mp:process-run-function |
| 19 |
'stdin-1 |
| 20 |
(lambda () |
| 21 |
(serve-event:with-fd-handler |
| 22 |
(0 :input #'(lambda (fd) |
| 23 |
(declare (ignore fd)) |
| 24 |
(format out"GOOD!~%"))) |
| 25 |
(unwind-protect (serve-event:serve-event) |
| 26 |
(mp:interrupt-process p1 (lambda () |
| 27 |
(mp:exit-process))))))))) |
| 28 |
(mp:process-join p1) |
| 29 |
(mp:process-join p2)))) |
| 30 |
|
| 31 |
(test-leak) |