[pg-cvs] CVS update: pg/sysdep.lisp

Eric Marsden emarsden at common-lisp.net
Mon Dec 19 22:21:51 UTC 2005


Update of /project/pg/cvsroot/pg
In directory common-lisp.net:/tmp/cvs-serv4507

Modified Files:
	sysdep.lisp 
Log Message:
Fix the SB-ROTATE-BYTE dependency for SBCL (was loaded twice, with
unfortunate consequences).

Add support for unix-socket connections to the backend for SBCL.

(Thanks to Andreas Fuchs)

Date: Mon Dec 19 23:21:50 2005
Author: emarsden

Index: pg/sysdep.lisp
diff -u pg/sysdep.lisp:1.11 pg/sysdep.lisp:1.12
--- pg/sysdep.lisp:1.11	Mon Dec 19 23:18:32 2005
+++ pg/sysdep.lisp	Mon Dec 19 23:21:50 2005
@@ -146,27 +146,30 @@
              :transport-error e))))
 
 #+sbcl
-(defun socket-connect (port host)
+(defun socket-connect (port host-name)
   (declare (type integer port))
-  (handler-case
-      (sb-bsd-sockets:socket-make-stream
-       (if host
-	   (let ((s (make-instance 'sb-bsd-sockets:inet-socket
-                                   :type :stream :protocol :tcp))
-		 (num (car (sb-bsd-sockets:host-ent-addresses
-			    (sb-bsd-sockets:get-host-by-name host)))))
-	     (sb-bsd-sockets:socket-connect s num port)
-             s)
-	   (let ((s (make-instance 'sb-bsd-sockets:local-socket :type :stream)))
-	     (sb-bsd-sockets:socket-connect
-	      s (format nil "/var/run/postgresql/.s.PGSQL.~D" port))
-	     s))
-       :element-type '(unsigned-byte 8)
-       :input t
-       :output t
-       :buffering :none)
-    (error (e)
-      (error 'connection-failure :host host :port port :transport-error e))))
+  (let ((host (if (typep host-name 'pathname)
+                  (namestring host-name)
+                  host-name)))
+    (handler-case
+        (sb-bsd-sockets:socket-make-stream
+         (if (eql #\/ (char host 0))
+             (let ((s (make-instance 'sb-bsd-sockets:local-socket :type :stream)))
+               (sb-bsd-sockets:socket-connect
+                s (format nil  "~A.s.PGSQL.~D" (string host) port))
+               s)
+             (let ((s (make-instance 'sb-bsd-sockets:inet-socket
+                         :type :stream :protocol :tcp))
+                   (num (car (sb-bsd-sockets:host-ent-addresses
+                              (sb-bsd-sockets:get-host-by-name host)))))
+               (sb-bsd-sockets:socket-connect s num port)
+               s))
+         :element-type '(unsigned-byte 8)
+         :input t
+         :output t
+         :buffering :none)
+      (error (e)
+        (error 'connection-failure :host host :port port :transport-error e)))))
 
 #+allegro
 (defun socket-connect (port host)




More information about the Pg-cvs mailing list