zaphoyd/websocketpp — Issue #50: A few issues in the policy-refactor
Author: megabyte1024
Created: 2012-01-17 14:37:40+00:00
State: open

All issues bellow are in the endpoint.hpp file.

1. The endpoint::close_all method iterates the m_connections set and calls the close method of every element. the result is a crash, because the close method calls the endpoint::remove_connection method which removes the connection from the m_connections member. Quick but not "nice" fix is

- for (it = m_connections.begin(); it != m_connections.end(); it++) {
- (*it)->close(code,reason);
- }
+ while(!m_connections.empty()) { // using for is not correct because the close method calls the remove_connection, which removes connection from m_connections
+ (*m_connections.begin())->close(code,reason);
+ }

2. Ambiguous access of 'm_io_service'. Can be either the endpoint_base or the role or the socket classes. Fix is

explicit endpoint(handler_ptr handler)
- : role_type(m_io_service),
- socket_type(m_io_service),
+ : role_type(endpoint_base::m_io_service),
+ socket_type(endpoint_base::m_io_service),
m_state(IDLE),

3. The same as previous issue but in different place

<< "Endpoint is stopping immediately" << log::endl;

- m_io_service.stop();
+ endpoint_base::m_io_service.stop();
m_state = STOPPED;

4. Under Windows the following lines either can't be compiled or do not define correct friend class declarations and as result the "can't access to protected method" error

friend class role< endpoint >;
friend class socket< endpoint >;
friend class connection::template connection,socket< type >::template connection>;

Quick but not 100% correct fix is to use #if defined(WIN32) ... #else ... #endif with the following lines which are commented in the header file

friend role_type;
friend socket_type;
friend connection_type;

5. Simple mistyping.

- << "Endpoint recieved signal to close all connections cleanly with code "
+ << "Endpoint received signal to close all connections cleanly with code "