From 3985aba03f404dbcf2d9623e7d52353992ace262 Mon Sep 17 00:00:00 2001 From: eta Date: Sun, 5 Apr 2020 19:11:02 +0100 Subject: [PATCH] I swear, this stream is gonna cause anger management issues --- stuff.lisp | 31 ++++++++++++++++++++----------- whatsxmpp.asd | 2 +- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/stuff.lisp b/stuff.lisp index 2605174..8979e82 100644 --- a/stuff.lisp +++ b/stuff.lisp @@ -173,16 +173,22 @@ ;; and specify the speed manually, and then it works. ;; ;; Wouldn't it be nice if people documented this sort of thing? + ;; + ;; ### Part II: The Fucking Stream Strikes Back ### + ;; ...and, after another hour of debugging, I found out you have to specify the `name' + ;; arg, otherwise it breaks -- but ONLY randomly and once you decide to deploy it + ;; in production, of course. (let ((source (make-xmpp-source comp)) (fucking-stream (cxml:make-xstream (component-socket comp) :speed 1 ; FFFFFFFFUUUUUUUU + :name (cxml::make-stream-name ; AAAARGH + :entity-name "main document" + :entity-kind :main + :uri nil) + :name "XMPP server stream" :initial-speed 1))) - (handler-case - (cxml:parse fucking-stream source - :recode t) - (error (e) - (format *debug-io* "~&Component listen thread failed: ~A~%" e) - (emit :error comp e))))) + (cxml:parse fucking-stream source + :recode t))) (defmacro with-component-xml-output ((comp) &body body) (let ((ret-sym (gensym))) @@ -1478,6 +1484,12 @@ WhatsXMPP represents users as u440123456789 and groups as g1234-5678." (on :connected ret (lambda () (wa-resetup-users ret))) ret)))) +#+sbcl +(defun report-error-and-die (err) + (format t "ERROR: ~A~%Backtrace: ~A~%" err + (trivial-backtrace:print-backtrace err)) + (sb-ext:exit :code 1 :abort t)) + #+sbcl (defun main () "Hacky main() function for running this in 'the real world' (outside emacs)" @@ -1486,14 +1498,11 @@ WhatsXMPP represents users as u440123456789 and groups as g1234-5678." (setf swank:*configure-emacs-indentation* nil) (swank:create-server :dont-close t) (setf *debugger-hook* (lambda (condition hook) - (declare (ignore hook)) - (format t "ERROR: ~A~%" condition) - (sb-ext:exit :code 1 :abort t))) + (report-error-and-die condition))) (format t "*mario voice* Here we go!~%") (defparameter *comp* (whatsxmpp-init)) (on :error *comp* (lambda (e) - (format t "ERROR: ~A~%" e) - (sb-ext:exit :code 1 :abort t))) + (report-error-and-die e))) ;; don't pretty-print stuff with newlines (setf *print-right-margin* most-positive-fixnum) ;; We don't have anything better to do, so let's wait on a condition diff --git a/whatsxmpp.asd b/whatsxmpp.asd index ea0cd37..2327188 100644 --- a/whatsxmpp.asd +++ b/whatsxmpp.asd @@ -1,5 +1,5 @@ (defsystem "whatsxmpp" - :depends-on ("usocket" "bordeaux-threads" "event-emitter" "blackbird" "cxml" "ironclad" "uuid" "sqlite" "whatscl" "drakma" "local-time" "trivial-timers" "swank") + :depends-on ("usocket" "bordeaux-threads" "event-emitter" "blackbird" "cxml" "ironclad" "uuid" "sqlite" "whatscl" "drakma" "local-time" "trivial-timers" "swank" "trivial-backtrace") :serial t :build-operation "program-op" :build-pathname "whatsxmpp"