Commit e2b740aa authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 8a571de2
...@@ -523,6 +523,8 @@ func handshake(ctx context.Context, conn net.Conn) (_ *zLink, err error) { ...@@ -523,6 +523,8 @@ func handshake(ctx context.Context, conn net.Conn) (_ *zLink, err error) {
wg.Go(func(ctx context.Context) error { wg.Go(func(ctx context.Context) error {
// server first announces its preferred protocol // server first announces its preferred protocol
// it is e.g. "M5", "Z5", "Z4", "Z3101", ... // it is e.g. "M5", "Z5", "Z4", "Z3101", ...
//
// first letter is preferred encoding: 'M' (msgpack), or 'Z' (pickles).
pkb, err := zl.recvPkt() pkb, err := zl.recvPkt()
if err != nil { if err != nil {
return fmt.Errorf("rx: %s", err) return fmt.Errorf("rx: %s", err)
...@@ -534,9 +536,9 @@ func handshake(ctx context.Context, conn net.Conn) (_ *zLink, err error) { ...@@ -534,9 +536,9 @@ func handshake(ctx context.Context, conn net.Conn) (_ *zLink, err error) {
return fmt.Errorf("rx: invalid peer handshake: %q", proto) return fmt.Errorf("rx: invalid peer handshake: %q", proto)
} }
// even if server announced it prefers 'M' (msgpack) it will // use wire encoding preferred by server
// accept 'Z' (pickles) as encoding. We always use 'Z'. encoding := proto[0]
//
// extract peer version from protocol string and choose actual // extract peer version from protocol string and choose actual
// version to use as min(peer, mybest) // version to use as min(peer, mybest)
ver := proto[1:] ver := proto[1:]
...@@ -560,14 +562,14 @@ func handshake(ctx context.Context, conn net.Conn) (_ *zLink, err error) { ...@@ -560,14 +562,14 @@ func handshake(ctx context.Context, conn net.Conn) (_ *zLink, err error) {
// version selected - now send it back to server as // version selected - now send it back to server as
// corresponding handshake reply. // corresponding handshake reply.
pkb = allocPkb() pkb = allocPkb()
pkb.WriteString("Z" + ver) pkb.WriteString(fmt.Sprintf("%c%s", encoding, ver))
err = zl.sendPkt(pkb) err = zl.sendPkt(pkb)
if err != nil { if err != nil {
return fmt.Errorf("tx: %s", err) return fmt.Errorf("tx: %s", err)
} }
zl.ver = ver zl.ver = ver
zl.encoding = 'Z' // XXX hardcoded zl.encoding = encoding
close(hok) close(hok)
return nil return nil
}) })
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment