Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Protocol version should be passed in to the encoding functions, not s…

…pecified by a global constant.

The protocol version is still specified with a constant, but higher level function now pass it in when encoding terms.
  • Loading branch information...
commit e405e22d3f51078af305b21ab3697c2f024654e8 1 parent d6f2e27
@flambard authored
View
7 src/bert.lisp
@@ -44,6 +44,7 @@
(in-package :bert)
+(defconstant +protocol-version+ 131)
(defgeneric translate-complex-type (object)
(:documentation "Translates tuples with the 'bert' tag to corresponding Lisp objects."))
@@ -113,7 +114,8 @@
(defmethod encode (object &key berp-header)
- (let ((bytes (cleric:encode (translate-complex-type object) :version-tag t)))
+ (let ((bytes (cleric:encode (translate-complex-type object)
+ :version-tag +protocol-version+)))
(if berp-header
(concatenate '(vector (unsigned-byte 8))
(uint32-to-bytes (length bytes))
@@ -206,6 +208,7 @@
(defun decode (bytes)
- (multiple-value-bind (term pos) (cleric:decode bytes :version-tag t)
+ (multiple-value-bind (term pos)
+ (cleric:decode bytes :version-tag +protocol-version+)
(values (translate-complex-terms term) pos)))
View
1  src/constants.lisp
@@ -4,7 +4,6 @@
;;; Node protocol type tags
(defconstant +pass-through+ 112)
-(defconstant +protocol-version+ 131)
;;; Erlang data tags
View
6 src/decode.lisp
@@ -6,12 +6,12 @@
(defun decode (bytes &key (start 0) (version-tag nil))
"Decode a sequence of bytes to an Erlang object."
- (when version-tag
+ (when (integerp version-tag)
(let ((version (aref bytes start)))
- (unless (= version +protocol-version+)
+ (unless (= version version-tag)
(error 'unexpected-message-tag-error
:received-tag version
- :expected-tags (list +protocol-version+))))
+ :expected-tags (list version-tag))))
(incf start))
(let ((tag (aref bytes start)))
(case tag
View
1  src/distribution-header.lisp
@@ -48,6 +48,7 @@
;; +----------------------+
;;
+(defconstant +protocol-version+ 131)
(defconstant +distribution-header-tag+ 68)
(defun decode-distribution-header (bytes &optional (pos 0))
View
6 src/erlang-tuple.lisp
@@ -51,12 +51,12 @@
(encode-external-large-tuple x atom-cache-entries)))
(defun decode-erlang-tuple (bytes &key (start 0) (version-tag nil))
- (when version-tag
+ (when (integerp version-tag)
(let ((version (aref bytes start)))
- (unless (= version +protocol-version+)
+ (unless (= version version-tag)
(error 'unexpected-message-tag-error
:received-tag version
- :expected-tags (list +protocol-version+))))
+ :expected-tags (list version-tag))))
(incf start))
(let ((tag (aref bytes start)))
(case tag
View
4 src/generic-functions.lisp
@@ -8,9 +8,9 @@
(:documentation "Encodes the Erlang translatable object to a vector of bytes."))
(defmethod encode :around (x &key version-tag atom-cache-entries)
- (if version-tag
+ (if (integerp version-tag)
(concatenate '(vector octet)
- (vector +protocol-version+)
+ (vector version-tag)
(call-next-method x :atom-cache-entries atom-cache-entries))
(call-next-method x :atom-cache-entries atom-cache-entries)))
View
7 src/node-protocol.lisp
@@ -101,7 +101,8 @@
(write-uint32 (+ (length dh) (length cm)) stream)
(write-sequence dh stream)
(write-sequence cm stream)))
- (let ((cm (encode-control-message control-message :version-tag t)))
+ (let ((cm (encode-control-message control-message
+ :version-tag +protocol-version+)))
(write-uint32 (1+ (length cm)) stream)
(write-byte +pass-through+ stream)
(write-sequence cm stream)))
@@ -123,7 +124,9 @@
(error 'connection-closed-error)))))
(case (aref bytes 0)
(#.+pass-through+
- (decode-control-message bytes :start 1 :version-tag t))
+ (decode-control-message bytes
+ :start 1
+ :version-tag +protocol-version+))
(#.+protocol-version+
(multiple-value-bind (cache pos) (decode-distribution-header bytes 1)
(let ((*cached-atoms* cache))
Please sign in to comment.
Something went wrong with that request. Please try again.