-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure sockets are closed when sessions are closed #1910
Comments
Oops, formatting makes this patch a bit messy. I have added it as an attachment. Original comment by: mtomlinson |
Hi, I appiled the attached patch but I am getting below errors while compilation. Do we have any updated patch. System Details:LSB Version: :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch Erros while compilation:session.cpp: In member function ‘SaErrorT cSession::DoRpc(uint32_t, ClientRpcParams&, ClientRpcParams&)’: Thanks! Original comment by: erpraveenk |
I just downloaded the latest trunk and applied the patch as-is, and it @@ -20,6 +20,7 @@ #include <glib.h> #include <oh_error.h> This compiles fine for me, but then again, it did without this change. On 07/04/16 03:14, Praveen wrote:
Original comment by: mtomlinson |
Mark, Thanks for the patch. I applied it with addional printf/CRIT statements and ran the tests using hpitop and hpi_shell. By and large it works well. The hpitop closed the sock properly. The hpi_shell has two threads and somehow the socks are not closed on that. Still looking into it. The modified patch is attached. Mohan Original comment by: mohandev2 |
Mark, The only client library that uses multiple threads wich sock connections is hpi_shell. Other single threaded applications are closing the sockets properly. At present hpi_shell does not. Even with your patch it is not closing the sockets at the end of the session. Could you please take a look at hpi_shell with your patch? Thanks Original comment by: mohandev2 |
Original comment by: mohandev2 |
Original comment by: mohandev2 |
From cf9cc9b59586bcdb410d03c6b26408eb4eb75414 Mon Sep 17 00:00:00 2001
From: Mark Tomlinson mark.tomlinson@alliedtelesis.co.nz
Date: Mon, 29 Feb 2016 13:21:57 +1300
Subject: [PATCH] Ensure sockets are closed when sessions are closed
The cSession class had a per-thread variable m_sockets. This allowed
different threads to share the same session, but each would have a
different socket to communicate with the client. This was implemented
using GStaticPrivate, but as this had been deprecated, changed to
GPrivate. The documentation for GPrivate states: "It is not possible to
destroy a GPrivate after it has been used. As such, it is only ever
acceptable to use GPrivate in static scope, and even then sparingly so."
This is not true for the m_sockets variable.
To achieve the same thing, a hash table is used to allow a different
socket per thread. When the cSession class is deleted, all sockets are
closed as the hash table is freed up.
Signed-off-by: Mark Tomlinson mark.tomlinson@alliedtelesis.co.nz
baselib/session.cpp | 34 ++++++++++++----------------------
1 file changed, 12 insertions(+), 22 deletions(-)
diff --git a/baselib/session.cpp b/baselib/session.cpp
index c5edfc8..ca9c2d7 100644
--- a/baselib/session.cpp
+++ b/baselib/session.cpp
@@ -103,11 +103,7 @@ private:
SaHpiDomainIdT m_did;
SaHpiSessionIdT m_sid;
SaHpiSessionIdT m_remote_sid;
-#if GLIB_CHECK_VERSION (2, 32, 0)
-#else
-#endif
};
@@ -117,16 +113,12 @@ cSession::cSession()
m_sid( 0 ),
m_remote_sid( 0 )
{
}
cSession::~cSession()
{
}
SaErrorT cSession::GetEntityRoot( SaHpiEntityPathT& entity_root ) const
@@ -213,11 +205,9 @@ SaErrorT cSession::DoRpc( uint32_t id,
}
}
if ( !rc ) {
@@ -240,7 +230,9 @@ SaErrorT cSession::DoRpc( uint32_t id,
SaErrorT cSession::GetSock( cClientStreamSock * & sock )
{
if ( ptr ) {
sock = reinterpret_cast<cClientStreamSock >(ptr);
} else {
@@ -266,11 +258,9 @@ SaErrorT cSession::GetSock( cClientStreamSock * & sock )
/ keepalive_intvl / 1,
/ keepalive_probes */ 3 );
}
return SA_OK;
--
2.7.2
Reported by: mtomlinson
Original Ticket: openhpi/bugs/1910
The text was updated successfully, but these errors were encountered: