Permalink
Browse files

add graceful socket_shutdown for PocoStomp

  • Loading branch information...
1 parent aac9ddf commit 5fbb4526620ce1a6e4a2b311de1bf3be728ef422 Elias Karakoulakis committed Jan 9, 2012
Showing with 14 additions and 6 deletions.
  1. +12 −6 PocoStomp.cpp
  2. +2 −0 PocoStomp.h
View
@@ -101,12 +101,6 @@ bool PocoStomp::socket_connect()
{
while (m_fsm.getState().getId() != StompFSM_map::SocketConnected.getId()) {
try {
- if (m_connection->addr != NULL) {
- delete m_connection->addr;
- }
- if (m_connection->socket != NULL) {
- delete m_connection->socket;
- }
m_connection->addr = new Poco::Net::SocketAddress(m_hostname, m_port);
m_connection->socket = new Poco::Net::StompSocket(*(m_connection->addr));
m_fsm.socket_connected();
@@ -124,6 +118,18 @@ bool PocoStomp::socket_connect()
}
// ####################################################
+void PocoStomp::socket_shutdown()
+// ####################################################
+{
+ if (m_connection->addr != NULL) {
+ delete m_connection->addr;
+ if (m_connection->socket != NULL) {
+ delete m_connection->socket;
+ }
+ }
+}
+
+// ####################################################
bool PocoStomp::connect()
// ####################################################
{
View
@@ -57,6 +57,7 @@ namespace STOMP {
typedef struct {
Poco::Net::SocketAddress* addr;
Poco::Net::StompSocket* socket;
+ bool alive;
} Connection;
typedef std::map<std::string, std::string> hdrmap;
@@ -191,6 +192,7 @@ namespace STOMP {
// more methods called from the thread loop
bool socket_connect();
+ void socket_shutdown();
bool incoming_data_waiting();
private:
void run(); // Runnable::run(): Stomp worker thread implementation

0 comments on commit 5fbb452

Please sign in to comment.