<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -4,6 +4,15 @@
 ** Please leave this at the top of the file.  Thanks.
 *******************************************************************************
 
+2009-06-18  Robert Rorschach  &lt;rfr@franz.com&gt;
+
+	* client.cl: compile in 8.1, 8.1+smp-macros, 8.2, 9.0
+	* examples/chat.cl: compile in 8.1, 8.1+smp-macros, 8.2, 9.0
+	* macs.cl: compile in 8.1, 8.1+smp-macros, 8.2, 9.0
+	* main.cl: compile in 8.1, 8.1+smp-macros, 8.2, 9.0; bump version
+	* parse.cl: compile in 8.1, 8.1+smp-macros, 8.2, 9.0
+	* proxy.cl: compile in 8.1, 8.1+smp-macros, 8.2, 9.0
+
 2009-05-11  Kevin Layer  &lt;layer@gemini.franz.com&gt;
 1.2.59
 	* main.cl (request-query): rfe8332: make request-query-value</diff>
      <filename>ChangeLog</filename>
    </modified>
    <modified>
      <diff>@@ -46,8 +46,7 @@
 
 (in-package :net.aserve.client)
 
-
-
+(net.aserve::check-smp-consistency)
 
 (defclass client-request ()
   ((uri   	;; uri we're accessing
@@ -1115,34 +1114,35 @@ or \&quot;foo.com:8000\&quot;, not ~s&quot; proxy))
 ;; line
 ;; this is a global variable; it is never bound.
 
-(defvar *response-header-buffers* nil)
+(net.aserve::defvar-mp *response-header-buffers* nil)
 
 (defun get-header-line-buffer ()
   ;; return the next header line buffer
   (let (buff)
-    #-smp
-    (excl::atomically ;; in a #-smp form
-     (excl::fast (setq buff (pop *response-header-buffers*))))
-    #+smp
-    (setq buff
-      (pop-atomic (si:global-symbol-value '*response-header-buffers*)))
+    (net.aserve::smp-case
+     ((t :macros)
+      (setq buff
+	(pop-atomic *response-header-buffers*)))
+     (nil
+      (excl::atomically ;; in a #-smp form
+       (excl::fast (setq buff (pop *response-header-buffers*))))))
     (if* buff
        thenret
        else (make-array 400 :element-type 'character))))
 
 (defun put-header-line-buffer (buff &amp;optional buff2)
   ;; put back up to two buffers
-  #-smp
-  (mp:without-scheduling ;; in a #-smp form
-    (push buff *response-header-buffers*)
-    (if* buff2 then (push buff2 *response-header-buffers*)))
-  #+smp
-  (progn
-    (push-atomic buff (si:global-symbol-value '*response-header-buffers*))
-    (if* buff2
-       then (push-atomic buff2
-			 (si:global-symbol-value '*response-header-buffers*))))
-  )
+  (net.aserve::smp-case
+   (nil
+    (mp:without-scheduling ;; in a #-smp form
+      (push buff *response-header-buffers*)
+      (if* buff2 then (push buff2 *response-header-buffers*))))
+   ((t :macros)
+    (progn
+      (push-atomic buff *response-header-buffers*)
+      (if* buff2
+	 then (push-atomic buff2 *response-header-buffers*))))
+   ))
 
 
 </diff>
      <filename>client.cl</filename>
    </modified>
    <modified>
      <diff>@@ -39,6 +39,14 @@
 			:net.html.generator))
 (in-package :user)
 
+(net.aserve::check-smp-consistency)
+
+(defmacro with-mp-locked-controller ((c) &amp;body body)
+  (net.aserve::smp-case
+   ((t :macros) `(with-locked-object (,c :-smp :without-scheduling)
+		   ,@body))
+   (nil `(si::without-scheduling ,c ,@body))))
+
 (defvar *chat-home-package* :user) ; :user for now while debugging
 (defvar *chat-home*)     ; home dir for chat info
 (defvar *chat-home-pics*)     ; home dir for chat pics
@@ -174,7 +182,7 @@
 ;  b = upgrade user
 
 
-(defclass master-chat-controller (mp:lockable-object)
+(defclass master-chat-controller (#+smp mp:lockable-object)
   ((controllers :initform nil
 		; list of chat-controller instances
 		:initarg :controllers
@@ -200,7 +208,7 @@
 
 
 
-(defclass chat-controller (lockable-object)
+(defclass chat-controller (#+smp mp:lockable-object)
   ;; describes a whole set of chats
   
   ((chats :initform nil
@@ -968,7 +976,7 @@
     ; create a unique string to indentify this controller
     (loop
       (setq ustring (make-unique-string))
-      (with-locked-object (*master-controller* :-smp :without-scheduling)
+      (with-mp-locked-controller (*master-controller*)
 	(if* (not (member ustring 
 			  (ustrings *master-controller*)
 			  :test #'equal))
@@ -1023,7 +1031,7 @@
        else (let (ustring)
 	      (loop
 		(setq ustring (make-unique-string))
-		(with-locked-object (controller :-smp :without-scheduling)
+		(with-mp-locked-controller (controller)
 		  (if* (not (member ustring (ustrings controller) 
 				    :test #'equal))
 		     then (push ustring (ustrings controller))
@@ -1034,7 +1042,7 @@
 					 :filename 
 					 (request-query-value &quot;filename&quot; req)
 					 :ustring ustring)))
-		(with-locked-object (controller :-smp :without-scheduling)
+		(with-mp-locked-controller (controller)
 		  (push chat (chats controller)))
 		(dump-existing-chat *chat-home*)
 		(with-http-response (req ent)</diff>
      <filename>examples/chat.cl</filename>
    </modified>
    <modified>
      <diff>@@ -218,6 +218,90 @@
 				   (return-from ,g-blocktag
 				     (progn ,@actions))))))
 	 ,@body))))
+
+;;;;;;;;;;;;;; SMP-aware macros
+;;
+;; We cater to three slightly different states:
+;;
+;;  #+smp
+;;     (smp-case (t form) ...)
+;;     The compile and execute environments support SMP;
+;;     9.0 with smp.
+;;
+;;  #+(and smp-macros (not smp))
+;;     (smp-case (:macros form) ...)
+;;     Compile environment recognizes the SMP macros, but compiles
+;;     for non-SMP lisp;
+;;     &gt;=8.2 but not smp
+;;     8.1 with smp patches.
+;;
+;;  #-smp-macros
+;;     (smp-case (nil form) ...)
+;;     Compile environment does not recognize SMP macros;
+;;     8.1 without smp patches.
+;;
+
+(defmacro smp-case (&amp;rest clauses)
+  (let* ((key
+	  #+smp t
+	  #+(and smp-macros (not smp)) :macros
+	  #-smp-macros nil
+	  )
+	 (clause (dolist (c clauses)
+		   (unless (and (consp c)
+				(consp (cdr c))
+				(null (cddr c)))
+		     (error &quot;smp-case clause ~s is badly formed&quot; c))
+		   (let ((c-key (car c)))
+		     (if* (or (eq c-key key)
+			      (and (consp c-key)
+				   (member key c-key)))
+			then (return c))))))
+    (unless clause
+      (error &quot;smp-case is missing clause for ~s&quot; key))
+    (second clause)))
+
+(defmacro check-smp-consistency ()
+  (smp-case
+   (nil (when (featurep :smp)
+	  (error &quot;This file was compiled to run in a non-smp acl&quot;)))
+   (:macros (if* (featurep :smp)
+	       then (error &quot;This file was compiled to run in a non-smp acl&quot;)
+	     elseif (not (featurep :smp-macros))
+	       then (error &quot;This file requires the smp-macros patch&quot;)))
+   (t (unless (featurep :smp)
+	(error &quot;This file was compiled to run in an smp acl&quot;)))))
+   
+
+(defmacro atomic-incf (var)
+  (smp-case
+   (t `(incf-atomic ,var))
+   (:macros `(with-delayed-scheduling (incf ,var)))
+   (nil `(si:without-scheduling (incf ,var))))
+  )
+
+(defmacro atomic-decf (var)
+  (smp-case
+   (t `(decf-atomic ,var))
+   (:macros `(with-delayed-scheduling (decf ,var)))
+   (nil `(si:without-scheduling (decf ,var)))))
+
+(defmacro with-locked-server ((s) &amp;body body)
+  (smp-case
+   ((t :macros) `(with-locked-object (,s :-smp :without-scheduling) ,@body))
+   (nil `(si:without-scheduling ,s ,@body))))
+
+(defmacro defvar-mp (v &amp;rest rest)
+  (smp-case
+   ((t :macros) `(defvar-nobind ,v ,@rest))
+   (nil `(defvar ,v ,@rest))))
+
+(defmacro atomically-fast (&amp;body body)
+  (smp-case
+   ((t :macros) `(excl::.atomically (excl::fast ,@body)))
+   (nil `(excl::atomically (excl::fast ,@body)))))
+
+;;;;;; end of smp-aware macro definitions
 			 
 
 </diff>
      <filename>macs.cl</filename>
    </modified>
    <modified>
      <diff>@@ -38,7 +38,9 @@
 
 (in-package :net.aserve)
 
-(defparameter *aserve-version* '(1 2 59))
+(check-smp-consistency)
+
+(defparameter *aserve-version* '(1 2 60))
 
 (eval-when (eval load)
     (require :sock)
@@ -526,22 +528,7 @@ Problems with protocol may occur.&quot; (ef-name ef)))))
 
 ; safe versions during multiprocessing
 
-#-smp
-(defmacro atomic-incf (var)
-  `(mp:without-scheduling (incf ,var)))	;; in a #-smp form
-
-#+smp
-(defmacro atomic-incf (var)
-  `(incf-atomic ,var))
-
-#-smp
-(defmacro atomic-decf (var)
-  `(mp:without-scheduling (decf ,var))) ;; in a #-smp form
-
-#+smp
-(defmacro atomic-decf (var)
-  `(decf-atomic ,var))
-
+;; atomic-incf and atomic-decf macro definitions moved to aserve/macs.cl
 
 ;;;;;;;;; end macros
 
@@ -1185,7 +1172,8 @@ by keyword symbols and not by strings&quot;
      #'http-accept-thread)))
 
 ;; make-worker-thread wasn't thread-safe before smp. I'm assuming that's
-;; ok, and leaving it non-thread-safe in the smp version.
+;; ok, which it will be if only one thread ever calls it, and leaving it
+;; non-thread-safe in the smp version. 
 (defun make-worker-thread ()
   (let* ((name (format nil &quot;~d-aserve-worker&quot; (incf *thread-index*)))
 	 (proc (mp:make-process :name name
@@ -1394,12 +1382,7 @@ by keyword symbols and not by strings&quot;
 		 then (logmess &quot;accept: too many errors, bailing&quot;)
 		      (return-from http-accept-thread nil)))))
       (ignore-errors (progn
-		       #-smp
-		       (mp:without-scheduling ;; in a #-smp form
-			 (if* (eql (wserver-socket server) main-socket)
-			    then (setf (wserver-socket server) nil)))
-		       #+smp
-		       (with-locked-object (server)
+		       (with-locked-server (server)
 			 (if* (eql (wserver-socket server) main-socket)
 			    then (setf (wserver-socket server) nil)))
 		       (close main-socket))))))</diff>
      <filename>main.cl</filename>
    </modified>
    <modified>
      <diff>@@ -38,6 +38,7 @@
 
 (in-package :net.aserve)
 
+(check-smp-consistency)
 
 ;; parseobj -- used for cons-free parsing of strings
 (defconstant parseobj-size 20)
@@ -49,34 +50,31 @@
   (max  parseobj-size)
   )
 
-(defvar *parseobjs* nil)  ;; never bound; this is a global variable
+(defvar-mp *parseobjs* nil)  ;; never bound; this is a global variable
 
-#-smp
 (defun allocate-parseobj ()
-  (let (res)
-    (mp::without-scheduling  ;; in a #-smp form
-      (if* (setq res (pop *parseobjs*))
-	 then (setf (parseobj-next res) 0)
-	      res
-	 else (make-parseobj)))))
-
-#+smp
-(defun allocate-parseobj ()
-  (let ((res (pop-atomic (si:global-symbol-value '*parseobjs*))))
-    (if* res
-       then (setf (parseobj-next res) 0)
-	    res
-       else (make-parseobj)))
-)
-
-#-smp
-(defun free-parseobj (po)
-  (mp::without-scheduling ;; in a #-smp form
-    (push po *parseobjs*)))
+  (smp-case
+   ((t :macros)
+    (let ((res (pop-atomic *parseobjs*)))
+	(if* res
+	   then (setf (parseobj-next res) 0)
+		res
+	   else (make-parseobj))))
+   (nil
+    (let (res)
+      (mp::without-scheduling  ;; in a #-smp form
+	(if* (setq res (pop *parseobjs*))
+	   then (setf (parseobj-next res) 0)
+		res
+	   else (make-parseobj)))))))
 
-#+smp
 (defun free-parseobj (po)
-  (push-atomic po (si:global-symbol-value '*parseobjs*)))
+  (smp-case
+   ((t :macros)
+    (push-atomic po (si:global-symbol-value '*parseobjs*)))
+   (nil
+    (mp::without-scheduling ;; in a #-smp form
+      (push po *parseobjs*)))))
 
 (defun add-to-parseobj (po start end)
   ;; add the given start,end pair to the parseobj
@@ -809,22 +807,3 @@
 	      (values root tail
 		      (subseq tail 0 pos)
 		      (subseq tail (1+ pos)))))))
-
-			      
-		
-
-    
-
-
-
-
-
-	
-
-      
-	      
-	      
-  
-  
-       
-</diff>
      <filename>parse.cl</filename>
    </modified>
    <modified>
      <diff>@@ -33,11 +33,40 @@
 ;;- http://www.franz.com/~jkf/coding_standards.html
 ;;-
 
-(eval-when (compile)
-  (require :smpdefs))
-
 (in-package :net.aserve)
 
+(check-smp-consistency)
+
+(defmacro with-mp-locked-connection-cache ((s) &amp;rest body)
+  (smp-case
+   ((t :macros) `(with-locked-structure (,s :-smp :without-scheduling)
+		   ,@body))
+   (nil `(si::without-scheduling ,s ,@body)))) ;; in a #-smp block
+
+(defmacro with-mp-locked-pcache-ent ((s) &amp;rest body)
+  (smp-case
+   ((t :macros) `(with-locked-structure (,s :-smp :without-scheduling)
+		   ,@body))
+   (nil `(si::without-scheduling ,s ,@body)))) ;; in a #-smp block
+
+(defmacro with-fast-mp-locked-pcache-ent ((s) &amp;rest body)
+  (smp-case
+   ((t :macros) `(with-locked-structure (,s :-smp :atomically)
+		   ,@body))
+   (nil `(excl::atomically ,s ,@body)))) ;; in a #-smp block
+
+(defmacro with-mp-locked-pcache ((s) &amp;rest body)
+  (smp-case
+   ((t :macros) `(with-locked-structure (,s :-smp :without-scheduling)
+		   ,@body))
+   (nil `(si::without-scheduling ,s ,@body)))) ;; in a #-smp block
+
+(defmacro with-mp-locked-pcache-queue ((s) &amp;rest body)
+  (smp-case
+   ((t :macros) `(with-locked-structure (,s :-smp :without-scheduling)
+		   ,@body))
+   (nil `(si::without-scheduling ,s ,@body)))) ;; in a #-smp block
+
 ; denotes a request from the browser
 (defconstant *browser-level* 100) ;
 
@@ -61,10 +90,11 @@
 ; the cache
 (defparameter *connection-cache-queue* (cons nil nil)) ; (first . last) queue of conn-cache objects
 (defparameter *connection-cache-expire* 10) ; number of seconds to live
-#+smp
-(defparameter *connection-cache-lock*
-    (make-basic-lock :name &quot;connection-cache&quot;))
 
+(defparameter *connection-cache-lock*
+    (smp-case
+     ((t :macros) (excl::make-basic-lock :name &quot;connection-cache&quot;))
+     (nil nil)))
 
 ; number of seconds we wait for a connect before we consider it timed
 ; out.  Given the chance Linux seems to wait forever for a connection
@@ -73,7 +103,7 @@
 
 
 (defstruct (pcache 
-	    #+smp (:include synchronizing-structure)
+	    #+smp-macros (:include synchronizing-structure)
 	    )
   ;; proxy cache
   table		; hash table mapping to pcache-ent objects
@@ -173,7 +203,7 @@
 
 
 (defstruct (pcache-ent
-	    #+smp (:include synchronizing-structure)
+	    #+smp-macros (:include synchronizing-structure)
 	    )
   key		; the string form of the uri 
   uri		; the actual uri
@@ -985,8 +1015,7 @@ cached connection = ~s~%&quot; cond cached-connection))
     
 
     
-    (with-locked-structure
-	(*connection-cache-lock* :-smp :without-scheduling)
+    (with-mp-locked-connection-cache (*connection-cache-lock*)
       (incf *connections-cached*)
       (let ((start (first-valid-entry now queue)))
 		
@@ -1026,7 +1055,7 @@ cached connection = ~s~%&quot; cond cached-connection))
   ;; build a new one if there isn't  one cached
   (let ((now (get-universal-time))
 	(queue *connection-cache-queue*))
-    (with-locked-structure (*connection-cache-lock* :-smp :without-scheduling)
+    (with-mp-locked-connection-cache (*connection-cache-lock*)
       (let ((start (first-valid-entry now queue))
 	    (prev nil))
 	(loop
@@ -1858,7 +1887,7 @@ cached connection = ~s~%&quot; cond cached-connection))
   ;; attempt to increase the use count of this entry by one.
   ;; If successful return true.
   ;; If the entry is dead return nil
-  (with-locked-structure (pcache-ent :-smp :atomically)
+  (with-fast-mp-locked-pcache-ent (pcache-ent)
     (excl::fast
      (let ((val (pcache-ent-use pcache-ent)))
        (if* val
@@ -1867,7 +1896,7 @@ cached connection = ~s~%&quot; cond cached-connection))
 
 (defun unlock-pcache-ent (pcache-ent)
   ;; reduce the use count of this entry
-  (with-locked-structure (pcache-ent :-smp :without-scheduling)
+  (with-mp-locked-pcache-ent (pcache-ent)
     (let ((val (pcache-ent-use pcache-ent)))
       (if* val
 	 then (if* (and (zerop (excl::fast
@@ -1940,7 +1969,7 @@ cached connection = ~s~%&quot; cond cached-connection))
 	    then (setq error-flag :noqueue)
 	   elseif (eq (pcache-ent-state pcache-ent) :dead) ; debugging 
 	     then (setq error-flag :dead)
-	     else (with-locked-structure (fromq :-smp :without-scheduling)
+	     else (with-mp-locked-pcache-queue (fromq)
 		    (let* ((prev (pcache-ent-prev pcache-ent))
 			   (next (pcache-ent-next pcache-ent))
 			   (mru-head (queueobj-mru toq))
@@ -1957,7 +1986,7 @@ cached connection = ~s~%&quot; cond cached-connection))
        else ;; toq != fromq; we're changing one or more queue counts
 	    (when fromq
 	      ;; it's leaving the queue fromq
-	      (with-locked-structure (fromq :-smp :without-scheduling)
+	      (with-mp-locked-pcache-queue (fromq)
 		(let ((prev (pcache-ent-prev pcache-ent))
 		      (next (pcache-ent-next pcache-ent)))
 		  ;; unlink
@@ -1974,7 +2003,7 @@ cached connection = ~s~%&quot; cond cached-connection))
 	      ;; link into the toq, at the mru position
 	      (if* (eq (pcache-ent-state pcache-ent) :dead)
 		 then (setq error-flag :dead)
-		 else (with-locked-structure (toq :-smp :without-scheduling)
+		 else (with-mp-locked-pcache-queue (toq)
 			(let* ((mru-head (queueobj-mru toq))
 			       (mru (pcache-ent-next mru-head)))
 			  (setf (pcache-ent-next mru-head) pcache-ent
@@ -2004,7 +2033,7 @@ cached connection = ~s~%&quot; cond cached-connection))
 (defun kill-pcache-ent (pcache-ent &amp;optional (pcache (wserver-pcache
 						      *wserver*)))
   ; make this entry dead
-  (with-locked-structure (pcache :-smp :without-scheduling)
+  (with-mp-locked-pcache (pcache)
     
     ; stop any scanning of this uri
     (setf (pcache-ent-level pcache-ent) -1) 
@@ -2265,7 +2294,7 @@ cached connection = ~s~%&quot; cond cached-connection))
 		      (return-from main))))))
       
       ;; this is the new version
-      (with-locked-structure (pcache :-smp :without-scheduling)
+      (with-mp-locked-pcache (pcache)
 	(setq ent-todo nil)
 	(do ((lru (pcache-ent-prev lru-head) (pcache-ent-prev lru)))
 	    ((eq lru mru-head)
@@ -2293,17 +2322,17 @@ cached connection = ~s~%&quot; cond cached-connection))
   ;; flush all the deal items from the cache, returning
   ;; their resource
   (let (ent)
-    #-smp
-    (excl::atomically ;; in a #-smp block
-     (excl::fast
-      (setf ent (pcache-dead-ent pcache)
-	    (pcache-dead-ent pcache) nil)))
-    #+smp
-    (loop
-      (setq ent (pcache-dead-ent pcache))
-      (excl::fast
-       (when (atomic-conditional-setf (pcache-dead-ent pcache) nil ent)
-	 (return))))
+    (smp-case
+     (nil
+      (atomically-fast
+	(setf ent (pcache-dead-ent pcache)
+	      (pcache-dead-ent pcache) nil)))
+     ((t :macros)
+      (loop
+	(setq ent (pcache-dead-ent pcache))
+	(excl::fast
+	 (when (atomic-conditional-setf (pcache-dead-ent pcache) nil ent)
+	   (return))))))
     
     ; now we have an exclusive link to the dead entries
     ; which we can free at our leisure
@@ -2318,15 +2347,15 @@ cached connection = ~s~%&quot; cond cached-connection))
 	     then (return-free-blocks (pcache-ent-pcache-disk ent)
 				      diskloc)))
 	(setq ent (pcache-ent-next ent)))
-      #-smp
-      (excl::atomically ;; in a #-smp block
-       (excl::fast 
-	(decf (the fixnum (pcache-dead-items pcache)) 
-	      (the fixnum count))))
-      #+smp
-      (excl::fast
-       (decf-atomic (the fixnum (pcache-dead-items pcache)) 
-		    (the fixnum count)))
+      (smp-case
+       (nil
+	(atomically-fast
+	  (decf (the fixnum (pcache-dead-items pcache)) 
+		(the fixnum count))))
+       ((t :macros)
+	(excl::fast
+	 (decf-atomic (the fixnum (pcache-dead-items pcache)) 
+		      (the fixnum count)))))
       )))
      
      
@@ -2381,7 +2410,7 @@ cached connection = ~s~%&quot; cond cached-connection))
 	    (store-data-on-disk pcache-ent pcache-disk to-store-list)
 	    (log-proxy (pcache-ent-key pcache-ent) 0 :wd nil)
 	    (let ((ans
-		   (with-locked-structure (pcache-ent :-smp :without-scheduling)
+		   (with-mp-locked-pcache-ent (pcache-ent)
 		     (if* (and (null (pcache-ent-state pcache-ent))
 			       (eql 1 (pcache-ent-use pcache-ent)))
 			then ; we are tre sole user of this entry so we cna
@@ -2422,81 +2451,77 @@ cached connection = ~s~%&quot; cond cached-connection))
 	      ans))))
 
 (defun ensure-pcache-in-memory (pcache-ent)
-  #+smp
-  (with-locked-structure (pcache-ent)
+  (smp-case
+   (t
+    (with-locked-structure (pcache-ent)
+      (if* (pcache-ent-disk-location pcache-ent)
+	 then (retrieve-pcache-from-disk pcache-ent))))
+   ((nil :macros)
     (if* (pcache-ent-disk-location pcache-ent)
-       then (retrieve-pcache-from-disk pcache-ent)))
-  #-smp
-  (if* (pcache-ent-disk-location pcache-ent)
-     then (retrieve-pcache-from-disk pcache-ent)))
+       then (retrieve-pcache-from-disk pcache-ent)))))
 
 
 (defun retrieve-pcache-from-disk (pcache-ent)
   ;; read the cache entry back in from the disk
   
   ;; This is now called with the pcache-ent locked in smp lisps,
-  ;; so the flagval isn't needed in smp at all
+  ;; so the flagval test isn't needed in smp at all
   
   ; ensure the loading flag to true and set flagval
   ; to the value before we set the flag.
   ; If the value was nil and thus we set it to true, then
   ; we are the process responsible for loading in the data
-  ;
-  (let (#-smp
-	(flagval (excl::atomically ;; in a #-smp block
-		  (excl::fast 
-		   (let ((val (pcache-ent-loading-flag pcache-ent)))
-		     (if* (null val) 
-			then (setf (pcache-ent-loading-flag pcache-ent) t))
-		     val)))))
-    #-smp
+					;
+  #-smp
+  (let ((flagval (atomically-fast
+		  (let ((val (pcache-ent-loading-flag pcache-ent)))
+		    (if* (null val) 
+		       then (setf (pcache-ent-loading-flag pcache-ent) t))
+		    val))))
     (if* flagval
-       then #-smp
-	    (mp:process-wait &quot;cache entry to be loaded&quot;
+       then (mp:process-wait &quot;cache entry to be loaded&quot;
 			     #'(lambda (pcache-ent) 
 				 (null (pcache-ent-loading-flag pcache-ent)))
 			     pcache-ent)
 	    (return-from retrieve-pcache-from-disk))
-    
-    ; it's our job to load in the entry
-    (let* ((block-list (pcache-ent-disk-location pcache-ent))
-	   (pcache-disk (pcache-ent-pcache-disk pcache-ent))
-	   (stream (pcache-disk-stream pcache-disk))
-	   (bytes (+ (pcache-ent-data-length pcache-ent)
-		     *header-block-size*))
-	   (res))
-      (dlogmess (format nil &quot;retrieve ~s in blocks ~s~%&quot;
-		       (pcache-ent-key pcache-ent)
-		       block-list))
-      (log-proxy (pcache-ent-key pcache-ent) 0 :rd nil)
-      
-      (mp:with-process-lock ((pcache-disk-lock pcache-disk))
-	; get a lock so we're the only thread doing operations
-	; on the stream to the cache
-	(dolist (ent block-list)
-	  (file-position stream (* (car ent) *header-block-size*))
-	  (dotimes (i (1+ (- (cdr ent) (car ent))))
-	    (let ((buff (get-header-block)))
-	      (read-sequence buff stream :end (min *header-block-size*
-						   bytes))
-	      (decf bytes *header-block-size*)
-	      (push buff res))))
-	(setf (pcache-ent-data pcache-ent) (nreverse res))
+    )
+  ;; it's our job to load in the entry
+  (let* ((block-list (pcache-ent-disk-location pcache-ent))
+	 (pcache-disk (pcache-ent-pcache-disk pcache-ent))
+	 (stream (pcache-disk-stream pcache-disk))
+	 (bytes (+ (pcache-ent-data-length pcache-ent)
+		   *header-block-size*))
+	 (res))
+    (dlogmess (format nil &quot;retrieve ~s in blocks ~s~%&quot;
+		      (pcache-ent-key pcache-ent)
+		      block-list))
+    (log-proxy (pcache-ent-key pcache-ent) 0 :rd nil)
+    
+    (mp:with-process-lock ((pcache-disk-lock pcache-disk))
+      ;; get a lock so we're the only thread doing operations
+      ;; on the stream to the cache
+      (dolist (ent block-list)
+	(file-position stream (* (car ent) *header-block-size*))
+	(dotimes (i (1+ (- (cdr ent) (car ent))))
+	  (let ((buff (get-header-block)))
+	    (read-sequence buff stream :end (min *header-block-size*
+						 bytes))
+	    (decf bytes *header-block-size*)
+	    (push buff res))))
+      (setf (pcache-ent-data pcache-ent) (nreverse res))
       
 
-	(return-free-blocks pcache-disk block-list)
+      (return-free-blocks pcache-disk block-list)
 	
-	; insert in the memory ru list
-	(most-recently-used-ent pcache-ent)
+      ;; insert in the memory ru list
+      (most-recently-used-ent pcache-ent)
     
-	; insert in memory 
+      ;; insert in memory 
 	
-	(#+smp progn
-	 #-smp excl::atomically
-	 (excl::fast
-	  (setf (pcache-ent-disk-location pcache-ent) nil
-		(pcache-ent-pcache-disk pcache-ent) nil
-		(pcache-ent-loading-flag pcache-ent) nil)))))))
+      (atomically-fast
+       (setf (pcache-ent-disk-location pcache-ent) nil
+	     (pcache-ent-pcache-disk pcache-ent) nil
+	     (pcache-ent-loading-flag pcache-ent) nil)))))
 
 	
 	</diff>
      <filename>proxy.cl</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>49ae4525f9e3118bff0c48d4f44d8f58dc63d735</id>
    </parent>
  </parents>
  <author>
    <name>Robert Rorschach</name>
    <email>rfr@franz.com</email>
  </author>
  <url>http://github.com/franzinc/aserve/commit/e3b5904a37f52d85d77765bd678ec63f210ac503</url>
  <id>e3b5904a37f52d85d77765bd678ec63f210ac503</id>
  <committed-date>2009-06-18T11:34:20-07:00</committed-date>
  <authored-date>2009-06-18T11:34:20-07:00</authored-date>
  <message>fix aserve smp code to compile on 8.1

2009-06-18  Robert Rorschach  &lt;rfr@franz.com&gt;

	* client.cl: compile in 8.1, 8.1+smp-macros, 8.2, 9.0
	* examples/chat.cl: compile in 8.1, 8.1+smp-macros, 8.2, 9.0
	* macs.cl: compile in 8.1, 8.1+smp-macros, 8.2, 9.0
	* main.cl: compile in 8.1, 8.1+smp-macros, 8.2, 9.0; bump version
	* parse.cl: compile in 8.1, 8.1+smp-macros, 8.2, 9.0
	* proxy.cl: compile in 8.1, 8.1+smp-macros, 8.2, 9.0</message>
  <tree>d5f0a7414fe4fbcbab1acc116681aa17dc32bccd</tree>
  <committer>
    <name>Robert Rorschach</name>
    <email>rfr@franz.com</email>
  </committer>
</commit>
