From 518b939f316510998cb62271ffe3df219d23725f Mon Sep 17 00:00:00 2001
From: KIU Shueng Chuan <nixchuan@gmail.com>
Date: Fri, 24 Jul 2015 05:12:11 +0800
Subject: [PATCH] make ZMQ_STREAM_NOTIFY also control disconnect notificatons

---
 doc/zmq_setsockopt.txt | 10 +++++-----
 src/stream_engine.cpp  |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/doc/zmq_setsockopt.txt b/doc/zmq_setsockopt.txt
index 61392959..4ace7910 100644
--- a/doc/zmq_setsockopt.txt
+++ b/doc/zmq_setsockopt.txt
@@ -716,11 +716,11 @@ Default value:: -1 (infinite)
 Applicable socket types:: all
 
 
-ZMQ_STREAM_NOTIFY: send connect notifications
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Enables connect notifications on a STREAM socket, when set to 1. By default a
-STREAM socket does not notify new connections. When notifications are enabled,
-it delivers a zero-length message to signal new client connections.
+ZMQ_STREAM_NOTIFY: send connect and disconnect notifications
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Enables connect and disconnect notifications on a STREAM socket, when set
+to 1. When notifications are enabled, the socket delivers a zero-length
+message when a peer connects or disconnects.
 
 [horizontal]
 Option value type:: int
diff --git a/src/stream_engine.cpp b/src/stream_engine.cpp
index 96b6bde6..17c3d52c 100644
--- a/src/stream_engine.cpp
+++ b/src/stream_engine.cpp
@@ -965,7 +965,7 @@ int zmq::stream_engine_t::write_subscription_msg (msg_t *msg_)
 
 void zmq::stream_engine_t::error (error_reason_t reason)
 {
-    if (options.raw_socket) {
+    if (options.raw_socket && options.raw_notify) {
         //  For raw sockets, send a final 0-length message to the application
         //  so that it knows the peer has been disconnected.
         msg_t terminator;
-- 
2.18.0