Imported Upstream version 1.72.0
[platform/upstream/boost.git] / boost / beast / websocket / impl / stream_impl.hpp
index 5bcd9c7..0513dfe 100644 (file)
@@ -210,6 +210,14 @@ struct stream<NextLayer, deflateSupported>::impl_type
         timer.cancel();
     }
 
+    void
+    time_out()
+    {
+        timed_out = true;
+        change_status(status::closed);
+        close_socket(get_lowest_layer(stream()));
+    }
+
     // Called just before sending
     // the first frame of each message
     void
@@ -451,7 +459,11 @@ struct stream<NextLayer, deflateSupported>::impl_type
             }
             else
             {
-                BOOST_ASSERT(! is_timer_set());
+                // VFALCO This assert goes off when there's also
+                // a pending read with the timer set. The bigger
+                // fix is to give close its own timeout, instead
+                // of using the handshake timeout.
+                // BOOST_ASSERT(! is_timer_set());
             }
             break;
 
@@ -512,8 +524,7 @@ private:
             switch(impl.status_)
             {
             case status::handshake:
-                impl.timed_out = true;
-                close_socket(get_lowest_layer(impl.stream()));
+                impl.time_out();
                 return;
 
             case status::open:
@@ -533,14 +544,11 @@ private:
                     return;
                 }
 
-                // timeout
-                impl.timed_out = true;
-                close_socket(get_lowest_layer(impl.stream()));
+                impl.time_out();
                 return;
 
             case status::closing:
-                impl.timed_out = true;
-                close_socket(get_lowest_layer(impl.stream()));
+                impl.time_out();
                 return;
 
             case status::closed: