Kouhei Sutou
kou****@cozmi*****
2003年 7月 4日 (金) 23:36:24 JST
はじめまして,須藤と申します. 現状のWiLiKiは常にwriteモードでopenしていますが,commit時だ けwriteモードでopenし,それ以外の場合はreadモードでopenする と"gdbm: Resource temporary unavailable"というエラーが出るこ とは減るようです. 場当たり的ですが以下のパッチを当てると上記のように動作するよ うになります. なお,パッチにはdbm-openのキーワード:rwmodeを:rw-modeへ変更 する修正も含まれています. Index: src/wiliki.scm =================================================================== RCS file: /cvsroot/wiliki/WiLiKi/src/wiliki.scm,v retrieving revision 1.79 diff -u -r1.79 wiliki.scm --- src/wiliki.scm 3 May 2003 23:34:05 -0000 1.79 +++ src/wiliki.scm 4 Jul 2003 14:10:17 -0000 @@ -359,22 +359,26 @@ (define (cmd-commit-edit pagename content mtime donttouch) (unless (editable? (wiliki)) (errorf "Can't edit the page ~s: the database is read-only" pagename)) - (let ((p (wdb-get (db) pagename #t)) - (now (sys-time))) - (if (or (not (mtime-of p)) (eqv? (mtime-of p) mtime)) - (if (string-every #[\s] content) - (begin - (set! (content-of p) "") - (wdb-delete! (db) pagename) - (redirect-page (top-page-of (wiliki)))) - (begin - (set! (mtime-of p) now) - (set! (content-of p) (expand-writer-macros content)) - (wdb-put! (db) pagename p :donttouch donttouch) - (redirect-page pagename))) - (conflict-page p pagename content donttouch) - ) - )) + (unless (dbm-closed? (db)) + (dbm-close (db))) + (with-db + (lambda () + (let ((p (wdb-get (db) pagename #t)) + (now (sys-time))) + (if (or (not (mtime-of p)) (eqv? (mtime-of p) mtime)) + (if (string-every #[\s] content) + (begin + (set! (content-of p) "") + (wdb-delete! (db) pagename) + (redirect-page (top-page-of (wiliki)))) + (begin + (set! (mtime-of p) now) + (set! (content-of p) (expand-writer-macros content)) + (wdb-put! (db) pagename p :donttouch donttouch) + (redirect-page pagename))) + (conflict-page p pagename content donttouch) + ))) + :write)) (define (cmd-all) (format-page Index: src/wiliki/db.scm =================================================================== RCS file: /cvsroot/wiliki/WiLiKi/src/wiliki/db.scm,v retrieving revision 1.2 diff -u -r1.2 db.scm --- src/wiliki/db.scm 7 Jun 2003 09:14:34 -0000 1.2 +++ src/wiliki/db.scm 4 Jul 2003 14:10:17 -0000 @@ -43,24 +43,25 @@ (define-constant *retry-limit* 5) (define-constant *EAVAIL-message* "resource temporarily unavailable") -(define (db-try-open retry) +(define (db-try-open retry rwmode) (with-error-handler (lambda (e) (cond ((>= retry *retry-limit*) (raise e)) ((string-contains-ci (ref e 'message) *EAVAIL-message*) - (sys-sleep 1) (db-try-open (+ retry 1))) + (sys-sleep 1) (db-try-open (+ retry 1) rwmode)) (else (raise e)))) (lambda () (dbm-open (db-type-of (wiliki)) - :path (db-path-of (wiliki)) :rwmode :write)))) + :path (db-path-of (wiliki)) :rw-mode rwmode)))) -(define (with-db thunk) +(define (with-db thunk . rwmode) (parameterize - ((db (db-try-open 0))) + ((db (db-try-open 0 (get-optional rwmode :read)))) (dynamic-wind (lambda () #f) thunk - (lambda () (dbm-close (db)))))) + (lambda () (unless (dbm-closed? (db)) + (dbm-close (db))))))) (define-method wdb-exists? ((db <dbm>) key) (dbm-exists? db key)) # 私の通っている大学の先生がWiLiKiを用いて講義をしています.講 # 義中は,一度に80人くらいが一気にアクセスするために"gdbm: # Resource temporary unavailable"というエラーが出てしまうとい # うことですが,パッチを当ててみたところエラーは出なくなった # そうです. ====================== 須藤 功平 kou****@cozmi*****