From e176efd5e04f95b565f8dd51b934924e9bc44896 Mon Sep 17 00:00:00 2001 From: Vitaly Mayatskikh Date: Sun, 13 Jun 2010 12:28:34 +0200 Subject: [PATCH] Fix for 0MQ 2.0.7. --- README | 4 ++++ bye.lisp | 5 ++--- dispatchers.lisp | 1 + julia.lisp | 3 --- run.sh | 1 + test.lisp | 4 ++-- utils.lisp | 12 +++++++++--- 7 files changed, 19 insertions(+), 11 deletions(-) diff --git a/README b/README index dede948..0be92ba 100644 --- a/README +++ b/README @@ -8,6 +8,10 @@ Run node(s): $ sudo sbcl --core CORE- +or simpler: + +$ ./run.sh + Run test: $ sudo sbcl --load test.lisp diff --git a/bye.lisp b/bye.lisp index bad8b6f..34bda3e 100644 --- a/bye.lisp +++ b/bye.lisp @@ -1,12 +1,11 @@ (asdf:oos 'asdf:load-op :julia) -(zmq::with-context (ctx 1 1) +(zmq::with-context (ctx 1) (zmq:with-socket (s ctx zmq:pub) (zmq:connect s julia::*bus*) (zmq:send s (make-instance 'zmq:msg :data (format nil "ALL ~a 0 BYE" julia::*me*))) - (zmq:sleep 1) - (zmq:flush s))) + (sleep 1))) (sb-ext:quit) diff --git a/dispatchers.lisp b/dispatchers.lisp index 23fe0d7..8a2b7d6 100644 --- a/dispatchers.lisp +++ b/dispatchers.lisp @@ -50,6 +50,7 @@ (send-msg from 'sync *gen*))) (defdispatch write +;; FIXME add support for critical sections (when (and *coordinator* (string= to "COORDINATOR")) (send-msg :all 'write args) (send-msg from 'ack (format nil "~a" uid))) diff --git a/julia.lisp b/julia.lisp index 742f44e..44a2563 100644 --- a/julia.lisp +++ b/julia.lisp @@ -10,9 +10,6 @@ (setq *timer* (sb-ext:make-timer 'julia::timer-fn) *cache* (make-hash-table)) (push *me* *ids*) -;; FIXME race condition -;; If there's real coordinator, but we don't know about it yet and -;; receive new COORDINATOR messages. (coordinate) (run-timer) diff --git a/run.sh b/run.sh index 42dd2b9..525c00d 100755 --- a/run.sh +++ b/run.sh @@ -2,4 +2,5 @@ node=$1 sudo NODE=$1 sbcl --eval '(require :julia)' --eval '(julia::julia)' +#sudo NODE=$1 sh ~/src/lisp/sbcl/run-sbcl.sh --eval '(require :julia)' --eval '(julia::julia)' sudo NODE=$1 sbcl --load bye.lisp diff --git a/test.lisp b/test.lisp index 99d155c..17304b1 100644 --- a/test.lisp +++ b/test.lisp @@ -5,7 +5,7 @@ (in-package :julia-test) -(defvar *bus* "pgm://lo;226.0.0.1:5555") +(defvar *bus* "epgm://lo;226.0.0.1:5555") (defvar *ctx*) (defvar *bus-in*) (defvar *bus-out*) @@ -29,7 +29,7 @@ rep))) (defun init () - (setq *ctx* (zmq:init 1 10 zmq:noblock) + (setq *ctx* (zmq:init 1) *bus-in* (zmq:socket *ctx* zmq:sub) *bus-out* (zmq:socket *ctx* zmq:pub) *poll-in* (list (make-instance 'zmq:pollitem diff --git a/utils.lisp b/utils.lisp index 66ea5f7..5f9d72d 100644 --- a/utils.lisp +++ b/utils.lisp @@ -1,6 +1,6 @@ (in-package :julia) -(defvar *bus* "pgm://lo;226.0.0.1:5555") +(defvar *bus* "epgm://lo;226.0.0.1:5555") (defvar *ctx* nil "0MQ context") @@ -39,7 +39,7 @@ (apply #'format t args)) (defun init-messaging () - (setq *ctx* (zmq:init 1 1 zmq:noblock) + (setq *ctx* (zmq:init 1) *bus-in* (zmq:socket *ctx* zmq:sub) *bus-out* (zmq:socket *ctx* zmq:pub) *poll-in* (list (make-instance 'zmq:pollitem @@ -119,13 +119,19 @@ (cond ((and (not *coordinator*) (string= (car *ids*) *me*)) - (zmq:setsockopt *bus-in* zmq:subscribe "COORDINATOR") +;; FIXME race condition +;; If there's real coordinator, but we don't know about it yet and +;; receive new COORDINATOR messages. + (unwind-protect + (zmq:setsockopt *bus-in* zmq:subscribe "COORDINATOR")) (setq *coordinator* t) (logger "I'm the coordinator~%")) ((and *coordinator* (string/= (car *ids*) *me*)) (unwind-protect (zmq:setsockopt *bus-in* zmq:unsubscribe "COORDINATOR")) +;; FIXME race condition +;; Contrary problem (setq *coordinator* nil) (logger "New coordinator is ~a~%" (car *ids*))))) -- 2.11.4.GIT