Skip to content
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

Fix broken addListener() & delListener() handling. #1415

Merged
merged 1 commit into from
Sep 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion remote/rtRemoteFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ rtRemoteFunction::rtRemoteFunction(std::string const& id, std::string const& nam
, m_name(name)
, m_client(client)
, m_timeout(client->getEnvironment()->Config->environment_request_timeout())
, m_Hash(0)
{
std::hash<std::string> hashFn;
m_Hash = hashFn(name);

if (!strcmp(id.c_str(), "global"))
{
m_client->registerKeepAliveForObject(m_name);
Expand Down
25 changes: 19 additions & 6 deletions remote/rtRemoteValueWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.

#include "rtRemoteValueWriter.h"
#include "rtRemoteObject.h"
#include "rtRemoteFunction.h"
#include "rtRemoteObjectCache.h"
#include "rtRemoteConfig.h"
#include "rtRemoteMessage.h"
Expand All @@ -32,14 +33,26 @@ namespace
{
// static std::atomic<int> sNextFunctionId;

std::string getId(rtFunctionRef const& /*ref*/)
std::string getId(rtFunctionRef const& ref)
{
rtGuid id = rtGuid::newRandom();
rtFunctionCallback * obj = dynamic_cast<rtFunctionCallback *>(ref.ptr());
if(obj && !obj->getId().empty())
{
return obj->getId();
}
else
{
rtGuid id = rtGuid::newRandom();

std::stringstream ss;
ss << "func://";
ss << id.toString();
return ss.str();
std::stringstream ss;
ss << "func://";
ss << id.toString();

if(obj)
obj->setId(ss.str());

return ss.str();
}
}

std::string getId(rtObjectRef const& ref)
Expand Down
11 changes: 11 additions & 0 deletions src/rtObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include <string.h>
#include <vector>
#include <string>

// rtIObject and rtIFunction are designed to be an
// Abstract Binary Interface(ABI)
Expand Down Expand Up @@ -632,11 +633,21 @@ class rtFunctionCallback: public rtIFunction
mContext = NULL;
}

void setId(std::string id)
{
mId = id;
}

std::string getId()
{
return mId;
}

private:
rtFunctionCB mCB;
void* mContext;
rtAtomic mRefCount;
std::string mId;
};


Expand Down