[openrtm-commit:00405] r562 - trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext
openrtm @ openrtm.org
openrtm @ openrtm.org
2011年 9月 12日 (月) 16:05:48 JST
Author: fsi-katami
Date: 2011-09-12 16:05:47 +0900 (Mon, 12 Sep 2011)
New Revision: 562
Modified:
trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/PeriodicExecutionContext.java
Log:
When component was added to a EC, RTC's reference was stored but reference count was decremented. This causes a segmentation fault when remove_component is called. This reference count related bugs have been fixed. refs #2234
Modified: trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/PeriodicExecutionContext.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/PeriodicExecutionContext.java 2011-09-12 03:14:09 UTC (rev 561)
+++ trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/executionContext/PeriodicExecutionContext.java 2011-09-12 07:05:47 UTC (rev 562)
@@ -342,7 +342,9 @@
rtcout.println(Logbuf.TRACE, "PeriodicExecutionContext.get_rate()");
- return m_profile.rate;
+ synchronized (m_profile) {
+ return m_profile.rate;
+ }
}
/**
@@ -356,7 +358,9 @@
if( rate<=0.0 ) return ReturnCode_t.BAD_PARAMETER;
- m_profile.rate = rate;
+ synchronized (m_profile) {
+ m_profile.rate = rate;
+ }
this.m_usec = (long)(1000000/rate);
if( m_usec == 0 ) m_nowait = true;
for(int intIdx=0;intIdx<m_comps.size();intIdx++ ) {
@@ -610,27 +614,30 @@
m_comps.elementAt(intIdx)._sm.ec_id);
m_comps.elementAt(intIdx)._ref = null;
m_comps.remove(m_comps.elementAt(intIdx));
+ rtcout.println(Logbuf.TRACE, "remove_component(): an RTC removed from this context.");
RTC.RTObject rtcomp = RTC.RTObjectHelper.narrow(comp);
if(rtcomp == null){
rtcout.println(Logbuf.ERROR,"Invalid object reference.");
return ReturnCode_t.RTC_ERROR;
}
- long index;
- RTC.RTCListHolder holder
+ synchronized (m_profile) {
+ long index;
+ RTC.RTCListHolder holder
= new RTC.RTCListHolder(m_profile.participants);
- index = CORBA_SeqUtil.find(holder, new is_equiv(rtcomp));
+ index = CORBA_SeqUtil.find(holder, new is_equiv(rtcomp));
- if (index < 0) { // not found in my list
- rtcout.println(Logbuf.ERROR, "Not found.");
- return ReturnCode_t.BAD_PARAMETER;
+ if (index < 0) { // not found in my list
+ rtcout.println(Logbuf.ERROR, "Not found.");
+ return ReturnCode_t.BAD_PARAMETER;
+ }
+
+ CORBA_SeqUtil.erase(holder, (int)index);
+ m_profile.participants = holder.value;
}
-
- CORBA_SeqUtil.erase(holder, (int)index);
- m_profile.participants = holder.value;
-
return ReturnCode_t.RTC_OK;
}
}
+ rtcout.println(Logbuf.TRACE, "remove_component(): no RTC found in this context.");
return ReturnCode_t.BAD_PARAMETER;
}
@@ -646,7 +653,10 @@
rtcout.println(Logbuf.TRACE, "PeriodicExecutionContext.get_profile()");
- ExecutionContextProfileHolder p = new ExecutionContextProfileHolder(m_profile);
+ ExecutionContextProfileHolder p;
+ synchronized (m_profile) {
+ p = new ExecutionContextProfileHolder(m_profile);
+ }
return p.value;
}
openrtm-commit メーリングリストの案内