Commit ab2f9a78 authored by csr21's avatar csr21
Browse files

resource-id management

Based on a patch from Andy Hefner: pathological programs can cause the
resource ID counter to wrap, so we need to keep track of all resource
IDs in use, not just those which have cache entries.

darcs-hash:20080824173713-df18d-904596f2ca742c831f28597e05d6ae52a9ee4443.gz
parent d30326a9
......@@ -164,12 +164,23 @@
(type mask32 mask))))))
(defun resourcealloc (display)
;; Allocate a resource-id for in DISPLAY
;; Allocate a resource-id for use in DISPLAY
(declare (type display display))
(declare (clx-values resource-id))
(dpb (incf (display-resource-id-count display))
(display-resource-id-byte display)
(display-resource-id-base display)))
(loop for next-count upfrom (1+ (display-resource-id-count display))
repeat (1+ (display-resource-id-mask display))
as id = (dpb next-count
(display-resource-id-byte display)
(display-resource-id-base display))
unless (nth-value 1 (gethash id (display-resource-id-map display)))
do (setf (display-resource-id-count display) next-count)
(setf (gethash id (display-resource-id-map display)) t)
(return-from resourcealloc id))
;; internal consistency check
(assert (= (hash-table-count (display-resource-id-map display))
(1+ (display-resource-id-mask display))))
;; tell the user what's gone wrong
(error 'resource-ids-exhausted))
(defmacro allocate-resource-id (display object type)
;; Allocate a resource-id for OBJECT in DISPLAY
......
......@@ -1777,6 +1777,13 @@
(format stream "inconsistent-parameters:~{ ~s~}"
(inconsistent-parameters-parameters condition)))))
(define-condition resource-ids-exhausted (x-error)
()
(:report
(lambda (condition stream)
(declare (ignore condition))
(format stream "All X resource IDs are in use."))))
(defun get-error-key (display error-code)
(declare (type display display)
(type array-index error-code))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment