I'm trying to port the zmq egg from using zmq 2.2 to 3.2.2 and I'm not making very good progress. I'm hoping someone can provide some insight. Attached is the modified zmq egg code and a test case that exercises zmq in the way I'm using it in my application.
====the problem====
I get "Resource temporarily unavailable" warnings in code that works fine with the zmq 2.2.0 version:
Warning (#<thread: do access>): in thread: (send-message) Resource temporarily unavailable: 11
Call history:
mockupclientlib.scm:11: print
mockupclientlib.scm:12: zmq#send-message <--
Error: uncaught exception: #<condition: (exn)>
====the diff====
diff -Naur zmq-orig/zmq.scm zmq/zmq.scm
--- zmq-orig/zmq.scm 2013-01-20 06:29:41.387900097 +0000
+++ zmq/zmq.scm 2013-01-20 20:10:42.722357739 +0000
@@ -29,6 +29,8 @@
((sub) ZMQ_SUB)
((req) ZMQ_REQ)
((rep) ZMQ_REP)
+ ((dealer) ZMQ_DEALER)
+ ((router) ZMQ_ROUTER)
((xreq) ZMQ_XREQ)
((xrep) ZMQ_XREP)
((pull) ZMQ_PULL)
@@ -36,23 +38,25 @@
(define-foreign-enum-type (socket-option int)
(socket-option->int int->socket-option)
- ((hwm) ZMQ_HWM)
- ((swap) ZMQ_SWAP)
+ ;; ((hwm) ZMQ_HWM)
+ ((snd-hwm) ZMQ_SNDHWM)
+ ((rcv-hwm) ZMQ_RCVHWM)
+ ;; ((swap) ZMQ_SWAP)
((affinity) ZMQ_AFFINITY)
((identity) ZMQ_IDENTITY)
((subscribe) ZMQ_SUBSCRIBE)
((unsubscribe) ZMQ_UNSUBSCRIBE)
((rate) ZMQ_RATE)
((recovery-ivl) ZMQ_RECOVERY_IVL)
- ((mcast-loop) ZMQ_MCAST_LOOP)
+ ;; ((mcast-loop) ZMQ_MCAST_LOOP)
((sndbuf) ZMQ_SNDBUF)
((rcvbuf) ZMQ_RCVBUF)
((rcvmore) ZMQ_RCVMORE)
((fd) ZMQ_FD))
(define socket-options
- '((integer hwm swap affinity rate recovery-ivl sndbuf rcvbuf)
- (boolean rcvmore mcast-loop)
+ '((integer snd-hwm rcv-hwm affinity rate recovery-ivl sndbuf rcvbuf)
+ (boolean rcvmore) ;; mcast-loop)
(string subscribe unsubscribe identity)))
(define-foreign-enum-type (socket-flag int)
@@ -233,7 +237,7 @@
(define (socket-option-set! socket option value)
(or (zero? (case option
- ((hwm affinity sndbuf rcvbuf swap rate recovery-ivl mcast-loop)
+ ((rcv-hwm snd-hwm affinity sndbuf rcvbuf swap rate recovery-ivl mcast-loop)
(if (integer? value)
((foreign-safe-lambda* int
((scheme-object error)
@@ -311,27 +315,27 @@
(define (send-message socket data #!key non-blocking send-more)
(mutex-lock! (socket-mutex socket))
(let* ((message (initialize-message (socket-message socket) data))
- (result ((foreign-lambda int zmq_send socket message int)
- (socket-pointer socket)
+ (result ((foreign-lambda int zmq_msg_send message socket int)
message
+ (socket-pointer socket)
(bitwise-ior (if non-blocking zmq/noblock 0)
(if send-more zmq/sndmore 0)))))
(close-message message)
(mutex-unlock! (socket-mutex socket))
- (or (zero? result) (zmq-error 'send-message))))
+ (or (> -1 result) (zmq-error 'send-message))))
(define (receive-message socket #!key non-blocking (as 'string))
(mutex-lock! (socket-mutex socket))
(let* ((message (initialize-message (socket-message socket)))
- (result ((foreign-lambda int zmq_recv socket message int)
- (socket-pointer socket)
+ (result ((foreign-lambda int zmq_msg_recv message socket int)
message
+ (socket-pointer socket)
(if non-blocking zmq/noblock 0))))
- (if (zero? result)
+ (if (> -1 result)
(let ((data (message-data message as)))
(mutex-unlock! (socket-mutex socket))
(close-message message)