summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzesimir Nowak <krnowak@openismus.com>2012-03-15 17:56:36 +0100
committerPatrick Ohly <patrick.ohly@intel.com>2012-03-16 10:46:21 +0100
commit64f133ea1e131d9ab30833c5a90c1dfd7cf58228 (patch)
tree88f18b2d5b11c1d457d40e92aab23915984b815b
parentdede8ae9858303a74f3a4e32e8ba3f5071972e6f (diff)
session, connection: Do not use the ready signal.concurrent-sync-pohly-delayed-dbus
We used ready signal to avoid some race conditions when using child's DBus interface right after establishing connection. For now sync-helper creates a delayed DBus connection, which avoid such races and thus we do not need the ready signal anymore.
-rw-r--r--src/dbus/server/connection-resource.cpp12
-rw-r--r--src/dbus/server/connection-resource.h4
-rw-r--r--src/dbus/server/session-resource.cpp12
-rw-r--r--src/dbus/server/session-resource.h5
-rw-r--r--src/dbus/server/sync-helper.cpp5
5 files changed, 8 insertions, 30 deletions
diff --git a/src/dbus/server/connection-resource.cpp b/src/dbus/server/connection-resource.cpp
index b901b3b5..dd8c1135 100644
--- a/src/dbus/server/connection-resource.cpp
+++ b/src/dbus/server/connection-resource.cpp
@@ -172,8 +172,7 @@ void ConnectionResource::init(const Callback_t &callback)
{
SE_LOG_INFO(NULL, NULL, "ConnectionResource (%s) forking...", getPath());
- m_forkExecParent->m_onConnect.connect(boost::bind(&ConnectionResource::onConnect, this, _1));
- m_forkExecParent->m_onReady.connect(boost::bind(&ConnectionResource::onReady, this, callback));
+ m_forkExecParent->m_onConnect.connect(boost::bind(&ConnectionResource::onConnect, this, _1, callback));
m_forkExecParent->m_onQuit.connect(boost::bind(&ConnectionResource::onQuit, this, _1));
m_forkExecParent->m_onFailure.connect(boost::bind(&ConnectionResource::onFailure, this, _2));
m_forkExecParent->addEnvVar("SYNCEVO_START_CONNECTION", "TRUE");
@@ -181,15 +180,10 @@ void ConnectionResource::init(const Callback_t &callback)
m_forkExecParent->start();
}
-void ConnectionResource::onConnect(const GDBusCXX::DBusConnectionPtr &conn)
-{
- m_helper_conn = conn;
-}
-
-void ConnectionResource::onReady(const Callback_t &callback)
+void ConnectionResource::onConnect(const GDBusCXX::DBusConnectionPtr &conn, const Callback_t &callback)
{
SE_LOG_INFO(NULL, NULL, "ConnectionProxy interface ending with: %s", m_sessionID.c_str());
- m_connectionProxy.reset(new ConnectionProxy(m_helper_conn, m_sessionID));
+ m_connectionProxy.reset(new ConnectionProxy(conn, m_sessionID));
/* Enable public dbus interface for Connection. */
activate();
diff --git a/src/dbus/server/connection-resource.h b/src/dbus/server/connection-resource.h
index c57dddc2..770477c7 100644
--- a/src/dbus/server/connection-resource.h
+++ b/src/dbus/server/connection-resource.h
@@ -100,7 +100,6 @@ class ConnectionResource : public GDBusCXX::DBusObjectHelper,
boost::shared_ptr<SyncEvo::ForkExecParent> m_forkExecParent;
boost::scoped_ptr<ConnectionProxy> m_connectionProxy;
- GDBusCXX::DBusConnectionPtr m_helper_conn;
/** Connection.Process */
void process(const GDBusCXX::Caller_t &caller, const GDBusCXX::DBusArray<uint8_t> &msg,
@@ -135,8 +134,7 @@ class ConnectionResource : public GDBusCXX::DBusObjectHelper,
void killSessionsCb(const std::string &peerDeviceId);
// Child process handlers
- void onConnect(const GDBusCXX::DBusConnectionPtr &conn);
- void onReady(const Callback_t &callback);
+ void onConnect(const GDBusCXX::DBusConnectionPtr &conn, const Callback_t &callback);
void onQuit(int status);
void onFailure(const std::string &error);
};
diff --git a/src/dbus/server/session-resource.cpp b/src/dbus/server/session-resource.cpp
index caf4a5b8..1a50df4d 100644
--- a/src/dbus/server/session-resource.cpp
+++ b/src/dbus/server/session-resource.cpp
@@ -159,8 +159,7 @@ void SessionResource::init(const Callback_t &callback)
{
SE_LOG_INFO(NULL, NULL, "SessionResource (%s) forking...", getPath());
- m_forkExecParent->m_onReady.connect(boost::bind(&SessionResource::onSessionReady, this, callback));
- m_forkExecParent->m_onConnect.connect(boost::bind(&SessionResource::onSessionConnect, this, _1));
+ m_forkExecParent->m_onConnect.connect(boost::bind(&SessionResource::onSessionConnect, this, _1, callback));
m_forkExecParent->m_onQuit.connect(boost::bind(&SessionResource::onQuit, this, _1));
m_forkExecParent->m_onFailure.connect(boost::bind(&SessionResource::onFailure, this, _2));
m_forkExecParent->addEnvVar("SYNCEVO_SESSION_ID", m_sessionID);
@@ -371,15 +370,10 @@ void SessionResource::progressChangedCb(int32_t error, const SessionCommon::Sour
emitProgress(error, sources);
}
-void SessionResource::onSessionConnect(const GDBusCXX::DBusConnectionPtr &conn)
-{
- m_helper_conn = conn;
-}
-
-void SessionResource::onSessionReady(const Callback_t &callback)
+void SessionResource::onSessionConnect(const GDBusCXX::DBusConnectionPtr &conn, const Callback_t &callback)
{
SE_LOG_INFO(NULL, NULL, "SessionProxy interface end with: %s", m_sessionID.c_str());
- m_sessionProxy.reset(new SessionProxy(m_helper_conn, m_sessionID));
+ m_sessionProxy.reset(new SessionProxy(conn, m_sessionID));
/* Enable public dbus interface for Session. */
activate();
diff --git a/src/dbus/server/session-resource.h b/src/dbus/server/session-resource.h
index 2a10d97d..9073b6a6 100644
--- a/src/dbus/server/session-resource.h
+++ b/src/dbus/server/session-resource.h
@@ -170,8 +170,6 @@ class SessionResource : public GDBusCXX::DBusObjectHelper,
boost::shared_ptr<SyncEvo::ForkExecParent> m_forkExecParent;
boost::scoped_ptr<SessionProxy> m_sessionProxy;
- GDBusCXX::DBusConnectionPtr m_helper_conn;
-
/**
* True once done() is called.
*/
@@ -196,8 +194,7 @@ class SessionResource : public GDBusCXX::DBusObjectHelper,
GMainLoop *getLoop() { return m_server.getLoop(); }
// Child session handlers
- void onSessionConnect(const GDBusCXX::DBusConnectionPtr &conn);
- void onSessionReady(const Callback_t &callback);
+ void onSessionConnect(const GDBusCXX::DBusConnectionPtr &conn, const Callback_t &callback);
void onQuit(int status);
void onFailure(const std::string &error);
diff --git a/src/dbus/server/sync-helper.cpp b/src/dbus/server/sync-helper.cpp
index 49f005f7..13266831 100644
--- a/src/dbus/server/sync-helper.cpp
+++ b/src/dbus/server/sync-helper.cpp
@@ -132,11 +132,6 @@ int main(int argc, char **argv, char **envp)
SE_LOG_DEBUG(NULL, NULL, "%s: Could not connect to parent. Terminating.", argv[0]);
return 1;
}
- try {
- forkexec->ready();
- } catch (const std::runtime_error &ex) {
- SE_LOG_DEBUG(NULL, NULL, "Failed to send ready message: %s", ex.what());
- }
SE_LOG_DEBUG(NULL, NULL, "%s: Helper (pid %d) finished setup.", argv[0], getpid());