Add method for reset crossEventCallHandler
authorTaejeong Lee <taejeong.lee@samsung.com>
Tue, 15 Jan 2013 15:40:36 +0000 (00:40 +0900)
committerJihoon Chung <jihoon.chung@samsung.com>
Wed, 16 Jan 2013 01:45:50 +0000 (10:45 +0900)
[Issue#] JIRA(#N_SE-20674)
[Problem] Event handler isn't called
[Cause] After add commit for enhancement launching time,
event handler doesn't work.
Root cause is that pipe in the event handler is copyed during forking.
This cause occurred that event sends to parent process(UI)
even event is created by child process.
[Solution] Add reset method for event handler.
This method will be used in the webkit bundle.
[SCMRequest] N/A

Change-Id: I3875ab86a841ea7b8074b8936845cbdf45b7adc1

modules/event/include/dpl/event/main_event_dispatcher.h
modules/event/src/main_event_dispatcher.cpp

index 97145f6..7bfabad 100644 (file)
@@ -71,7 +71,7 @@ protected:
     // Cross thread send support
     WrappedEventCallList m_wrappedCrossEventCallList;
     Mutex m_crossEventCallMutex;
-    WaitableEvent m_crossEventCallInvoker;
+    WaitableEvent* m_crossEventCallInvoker;
 
     Ecore_Event_Handler *m_eventCallHandler;
     Ecore_Fd_Handler *m_crossEventCallHandler;
@@ -110,6 +110,7 @@ public:
 
     virtual void AddEventCall(AbstractEventCall *abstractEventCall);
     virtual void AddTimedEventCall(AbstractEventCall *abstractEventCall, double dueTime);
+    virtual void ResetCrossEventCallHandler();
 };
 
 MainEventDispatcher& GetMainEventDispatcherInstance();
index 6faf090..ae1107d 100644 (file)
@@ -64,8 +64,11 @@ MainEventDispatcher::MainEventDispatcher()
     if ((m_eventCallHandler = ecore_event_handler_add(m_eventId, &StaticDispatchEvent, this)) == NULL)
         ThrowMsg(Exception::CreateFailed, "Failed to register event handler!");
 
+    // Allocate WaitableEvent
+    m_crossEventCallInvoker = new WaitableEvent();
+
     // Register cross event handler
-    m_crossEventCallHandler = ecore_main_fd_handler_add(m_crossEventCallInvoker.GetHandle(), ECORE_FD_READ, &StaticDispatchCrossInvoker, this, NULL, NULL);
+    m_crossEventCallHandler = ecore_main_fd_handler_add(m_crossEventCallInvoker->GetHandle(), ECORE_FD_READ, &StaticDispatchCrossInvoker, this, NULL, NULL);
 
     if (m_crossEventCallHandler == NULL)
         ThrowMsg(Exception::CreateFailed, "Failed to register cross event handler!");
@@ -75,16 +78,19 @@ MainEventDispatcher::MainEventDispatcher()
 
 MainEventDispatcher::~MainEventDispatcher()
 {
-    // Remove event class handler
-    ecore_event_handler_del(m_eventCallHandler);
-    m_eventCallHandler = NULL;
-
     // Remove cross event handler
     ecore_main_fd_handler_del(m_crossEventCallHandler);
     m_crossEventCallHandler = NULL;
-
     LogPedantic("ECORE cross-event handler unregistered");
 
+    // Remove m_crossEventCallInvoker
+    delete m_crossEventCallInvoker;
+    m_crossEventCallInvoker = NULL;
+
+    // Remove event class handler
+    ecore_event_handler_del(m_eventCallHandler);
+    m_eventCallHandler = NULL;
+
     // Decrement ECORE init count
     // We do not need ecore routines any more
     ecore_shutdown();
@@ -94,6 +100,33 @@ MainEventDispatcher::~MainEventDispatcher()
     g_lateMainEventDispatcher = NULL;
 }
 
+void MainEventDispatcher::ResetCrossEventCallHandler()
+{
+    // Remove cross event handler
+    ecore_main_fd_handler_del(m_crossEventCallHandler);
+    m_crossEventCallHandler = NULL;
+    LogPedantic("ECORE cross-event handler unregistered");
+
+    // Re-allocate WaitableEvent
+    delete m_crossEventCallInvoker;
+    m_crossEventCallInvoker = new WaitableEvent();
+
+    // Register cross event handler
+    m_crossEventCallHandler =
+        ecore_main_fd_handler_add(m_crossEventCallInvoker->GetHandle(),
+                                  ECORE_FD_READ,
+                                  &StaticDispatchCrossInvoker,
+                                  this,
+                                  NULL,
+                                  NULL);
+
+    if (m_crossEventCallHandler == NULL) {
+        ThrowMsg(Exception::CreateFailed, "Failed to register cross event handler!");
+    }
+
+    LogPedantic("ECORE cross-event handler re-registered");
+}
+
 void MainEventDispatcher::StaticDeleteEvent(void *data, void *event)
 {
     LogPedantic("Static ECORE delete event handler");
@@ -226,7 +259,7 @@ void MainEventDispatcher::DispatchCrossInvoker()
 
     // Critical section
     {
-        m_crossEventCallInvoker.Reset();
+        m_crossEventCallInvoker->Reset();
         Mutex::ScopedLock lock(&m_crossEventCallMutex);
         m_wrappedCrossEventCallList.swap(stolenCrossEvents);
     }
@@ -261,7 +294,7 @@ void MainEventDispatcher::AddEventCall(AbstractEventCall *abstractEventCall)
         {
             Mutex::ScopedLock lock(&m_crossEventCallMutex);
             m_wrappedCrossEventCallList.push_back(WrappedEventCall(abstractEventCall, false, 0.0));
-            m_crossEventCallInvoker.Signal();
+            m_crossEventCallInvoker->Signal();
         }
 
         LogPedantic("Event pushed to cross-thread event list");
@@ -283,7 +316,7 @@ void MainEventDispatcher::AddTimedEventCall(AbstractEventCall *abstractEventCall
         {
             Mutex::ScopedLock lock(&m_crossEventCallMutex);
             m_wrappedCrossEventCallList.push_back(WrappedEventCall(abstractEventCall, true, dueTime));
-            m_crossEventCallInvoker.Signal();
+            m_crossEventCallInvoker->Signal();
         }
 
         LogPedantic("Event pushed to cross-thread event list");