X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=lsp-dbus%2Flsp-dbus-connection.lsp;h=73e96728f3581f577c23953f368ec82219f9ea74;hb=75e62613b1db312d16206acccfcfd6d03020f010;hp=3ac9b068a6db20a04775725d54ec9d0b835be6d0;hpb=b803427b65b26ec297322de115e8dcbae55b033e;p=rrq%2Flsp-utils.git diff --git a/lsp-dbus/lsp-dbus-connection.lsp b/lsp-dbus/lsp-dbus-connection.lsp index 3ac9b06..73e9672 100644 --- a/lsp-dbus/lsp-dbus-connection.lsp +++ b/lsp-dbus/lsp-dbus-connection.lsp @@ -40,9 +40,13 @@ (define (read-message) (let ((BUFFER "") (RESULT "")) - (while (net-select (%socket) "r" 1000) - (net-receive (%socket) BUFFER 8192) - (extend RESULT BUFFER)) + (while (and RESULT (net-select (%socket) "r" 1000)) + (if (net-receive (%socket) BUFFER 8192) + (extend RESULT BUFFER) + (begin + (setf RESULT nil) + (die 1 "dbus socket closed")) + )) RESULT)) ;; (handshake MSG PAT) @@ -54,9 +58,6 @@ (setf RESULT (read-message)) (if PAT (regex PAT RESULT 0) RESULT))) -(define (char2hex STR) - (join (map (curry format "%2x") (map char (explode STR))))) - (constant 'AUTHFMT "AUTH EXTERNAL %s\r\n" 'AUTHACK "OK (\\S+)\r\n" @@ -78,5 +79,4 @@ (define (cancel) (handshake "CANCEL\r\n" "(.*)")) -"DbusConnection" - +"lsp-dbus-connection.lsp"