Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
46c1e49f
Commit
46c1e49f
authored
Feb 25, 2011
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(optimization): Исправления по результатам тестирования valgrind
parent
785b6ca9
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
98 additions
and
41 deletions
+98
-41
SharedMemory.cc
extensions/SharedMemory/SharedMemory.cc
+19
-6
SharedMemory.h
extensions/SharedMemory/SharedMemory.h
+3
-0
PassiveTimer.h
include/PassiveTimer.h
+6
-4
UniSetObject.h
include/UniSetObject.h
+3
-0
ORepHelpers.cc
src/ObjectRepository/ORepHelpers.cc
+3
-2
ObjectIndex_XML.cc
src/ObjectRepository/ObjectIndex_XML.cc
+16
-9
ObjectsActivator.cc
src/ObjectRepository/ObjectsActivator.cc
+4
-1
UniSetObject.cc
src/ObjectRepository/UniSetObject.cc
+16
-5
IOController.cc
src/Processes/IOController.cc
+5
-2
ThrPassiveTimer.cc
src/Timers/ThrPassiveTimer.cc
+21
-11
UniXML.cc
src/Various/UniXML.cc
+2
-1
No files found.
extensions/SharedMemory/SharedMemory.cc
View file @
46c1e49f
...
...
@@ -229,15 +229,13 @@ void SharedMemory::sysCommand( SystemMessage *sm )
case
SystemMessage
:
:
StartUp
:
{
PassiveTimer
ptAct
(
activateTimeout
);
while
(
!
activated
&&
!
ptAct
.
checkTime
()
)
while
(
!
isActivated
()
&&
!
ptAct
.
checkTime
()
)
{
cout
<<
myname
<<
"(sysCommand): wait activate..."
<<
endl
;
msleep
(
100
);
if
(
activated
)
break
;
}
if
(
!
activated
)
if
(
!
isActivated
()
)
dlog
[
Debug
::
CRIT
]
<<
myname
<<
"(sysCommand): ************* don`t activate?! ************"
<<
endl
;
// подождать пока пройдёт инициализация
...
...
@@ -300,7 +298,11 @@ bool SharedMemory::activateObject()
// пока не пройдёт инициализация датчиков
// см. sysCommand()
{
activated
=
false
;
{
uniset_mutex_lock
l
(
act_mutex
,
100
);
activated
=
false
;
}
UniSetTypes
::
uniset_mutex_lock
l
(
mutex_start
,
5000
);
res
=
IONotifyController_LT
::
activateObject
();
...
...
@@ -324,7 +326,10 @@ bool SharedMemory::activateObject()
}
}
activated
=
true
;
{
uniset_mutex_lock
l
(
act_mutex
,
100
);
activated
=
true
;
}
}
cerr
<<
"************************** activate: "
<<
pt
.
getCurrent
()
<<
" msec "
<<
endl
;
...
...
@@ -883,3 +888,10 @@ std::ostream& operator<<( std::ostream& os, const SharedMemory::HistoryInfo& h )
return
os
;
}
// ------------------------------------------------------------------------------------------
bool
SharedMemory
::
isActivated
()
{
uniset_mutex_lock
l
(
act_mutex
,
300
);
return
activated
;
}
// ------------------------------------------------------------------------------------------
\ No newline at end of file
extensions/SharedMemory/SharedMemory.h
View file @
46c1e49f
...
...
@@ -391,12 +391,15 @@ class SharedMemory:
void
buildHistoryList
(
xmlNode
*
cnode
);
void
checkHistoryFilter
(
UniXML_iterator
&
it
);
bool
isActivated
();
DIOStateList
::
iterator
ditPulsar
;
IOController_i
::
SensorInfo
siPulsar
;
UniversalIO
::
IOTypes
iotypePulsar
;
int
msecPulsar
;
UniSetTypes
::
uniset_mutex
act_mutex
;
private
:
HistorySlot
m_historySignal
;
...
...
include/PassiveTimer.h
View file @
46c1e49f
...
...
@@ -27,9 +27,7 @@
#include <signal.h>
#include <sys/time.h>
#include <cc++/socket.h>
//#include "Exceptions.h"
#include "Mutex.h"
//----------------------------------------------------------------------------------------
/*! \class UniSetTimer
* \brief Базовый интерфейс пасивных таймеров
...
...
@@ -136,10 +134,14 @@ class ThrPassiveTimer:
virtual
bool
wait
(
timeout_t
timeMS
);
/*!< блокировать вызывающий поток на заданное время */
virtual
void
terminate
();
/*!< прервать работу таймера */
protected
:
bool
isTerminated
();
void
setTerminated
(
bool
set
);
private
:
volatile
sig_atomic_t
terminated
;
bool
terminated
;
omni_mutex
*
tmutex
;
omni_condition
*
tcondx
;
UniSetTypes
::
uniset_mutex
term_mutex
;
};
//----------------------------------------------------------------------------------------
...
...
include/UniSetObject.h
View file @
46c1e49f
...
...
@@ -186,6 +186,8 @@ class UniSetObject:
void
setPushMutexTimeout
(
unsigned
long
msec
);
unsigned
long
getPushMutexTimeout
(){
return
pushMutexTimeout
;
}
bool
isActive
();
void
setActive
(
bool
set
);
UniSetTypes
::
VoidMessage
msg
;
ObjectsManager
*
mymngr
;
...
...
@@ -216,6 +218,7 @@ class UniSetObject:
pid_t
msgpid
;
// pid потока обработки сообщений
bool
reg
;
bool
active
;
UniSetTypes
::
uniset_mutex
act_mutex
;
bool
threadcreate
;
UniSetTimer
*
tmr
;
UniSetTypes
::
ObjectId
myid
;
...
...
src/ObjectRepository/ORepHelpers.cc
View file @
46c1e49f
...
...
@@ -72,7 +72,8 @@ namespace ORepHelpers
CosNaming
::
NamingContext_var
ctx
;
try
{
ctx
=
CosNaming
::
NamingContext
::
_narrow
(
rootC
->
resolve
(
ctxName
)
);
CORBA
::
Object_var
o
=
rootC
->
resolve
(
ctxName
);
ctx
=
CosNaming
::
NamingContext
::
_narrow
(
o
);
if
(
CORBA
::
is_nil
(
ctx
)
)
{
const
string
err
(
"OREPHELPER(getContext): не смог получить ссылку на контекст(is_nil) "
+
cname
);
...
...
@@ -142,7 +143,7 @@ namespace ORepHelpers
try
{
// cout << "ORepHelpers(getRootNamingContext): nsName->" << nsName << endl;
CORBA
::
Object_var
initServ
(
orb
->
resolve_initial_references
(
nsName
.
c_str
()
));
CORBA
::
Object_var
initServ
=
orb
->
resolve_initial_references
(
nsName
.
c_str
(
));
unideb
[
Debug
::
REPOSITORY
]
<<
"OREPHELP: get rootcontext...(nsName = "
<<
nsName
<<
")"
<<
endl
;
rootContext
=
CosNaming
::
NamingContext
::
_narrow
(
initServ
);
if
(
CORBA
::
is_nil
(
rootContext
))
...
...
src/ObjectRepository/ObjectIndex_XML.cc
View file @
46c1e49f
...
...
@@ -119,10 +119,14 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string sec,
{
if
(
(
unsigned
)
ind
>=
omap
.
size
()
)
{
ostringstream
msg
;
msg
<<
"(ObjectIndex_XML::build): не хватило размера массива maxSize="
<<
omap
.
size
();
// throw OutOfRange(msg.str());
unideb
[
Debug
::
WARN
]
<<
msg
.
str
()
<<
"... Делаем resize + 100
\n
"
;
if
(
unideb
.
debugging
(
Debug
::
INFO
)
)
{
ostringstream
msg
;
msg
<<
"(ObjectIndex_XML::build): не хватило размера массива maxSize="
<<
omap
.
size
();
// throw OutOfRange(msg.str());
unideb
[
Debug
::
WARN
]
<<
msg
.
str
()
<<
"... Делаем resize + 100
\n
"
;
}
omap
.
resize
(
omap
.
size
()
+
100
);
}
...
...
@@ -171,7 +175,7 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string sec,
omap
[
ind
].
id
=
ind
;
// name
string
name
(
secname
+
xml
.
getProp
(
it
,
"name"
));
const
string
name
(
secname
+
xml
.
getProp
(
it
,
"name"
));
delete
[]
omap
[
ind
].
repName
;
omap
[
ind
].
repName
=
new
char
[
name
.
size
()
+
1
];
strcpy
(
omap
[
ind
].
repName
,
name
.
c_str
()
);
...
...
@@ -195,10 +199,13 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string sec,
if
(
(
unsigned
)
ind
>=
omap
.
size
()
)
{
ostringstream
msg
;
msg
<<
"(ObjectIndex_XML::build): не хватило размера массива maxSize="
<<
omap
.
size
();
// throw OutOfRange(msg.str());
unideb
[
Debug
::
WARN
]
<<
msg
.
str
()
<<
"... Делаем resize + 100
\n
"
;
if
(
unideb
.
debugging
(
Debug
::
INFO
)
)
{
ostringstream
msg
;
msg
<<
"(ObjectIndex_XML::build): не хватило размера массива maxSize="
<<
omap
.
size
();
// throw OutOfRange(msg.str());
unideb
[
Debug
::
INFO
]
<<
msg
.
str
()
<<
"... Делаем resize + 100
\n
"
;
}
omap
.
resize
(
omap
.
size
()
+
100
);
}
}
...
...
src/ObjectRepository/ObjectsActivator.cc
View file @
46c1e49f
...
...
@@ -380,6 +380,7 @@ void ObjectsActivator::set_signals(bool ask)
struct
sigaction
act
,
oact
;
sigemptyset
(
&
act
.
sa_mask
);
sigemptyset
(
&
oact
.
sa_mask
);
// добавляем сигналы, которые будут игнорироваться
// при обработке сигнала
...
...
@@ -416,7 +417,9 @@ void ObjectsActivator::finishterm( int signo )
unideb
[
Debug
::
SYSTEM
]
<<
gActivator
->
getName
()
<<
"(finishterm): прерываем процесс завершения...!"
<<
endl
<<
flush
;
ObjectsActivator
::
set_signals
(
false
);
if
(
gActivator
)
gActivator
->
set_signals
(
false
);
sigset
(
SIGALRM
,
SIG_DFL
);
doneterm
=
1
;
raise
(
SIGKILL
);
...
...
src/ObjectRepository/UniSetObject.cc
View file @
46c1e49f
...
...
@@ -675,7 +675,7 @@ unsigned int UniSetObject::countMessages()
// ------------------------------------------------------------------------------------------
bool
UniSetObject
::
disactivate
()
{
if
(
!
active
)
if
(
!
isActive
()
)
{
try
{
...
...
@@ -685,7 +685,7 @@ bool UniSetObject::disactivate()
return
true
;
}
active
=
false
;
// завершаем поток обработки сообщений
setActive
(
false
)
;
// завершаем поток обработки сообщений
tmr
->
stop
();
// Очищаем очередь
...
...
@@ -795,7 +795,7 @@ bool UniSetObject::activate()
registered
();
// Запускаем поток обработки сообщений
active
=
true
;
setActive
(
true
)
;
if
(
myid
!=
UniSetTypes
::
DefaultObjectId
&&
threadcreate
)
{
...
...
@@ -825,7 +825,7 @@ void UniSetObject::work()
unideb
[
Debug
::
INFO
]
<<
myname
<<
": thread processing messages run..."
<<
endl
;
if
(
thr
)
msgpid
=
thr
->
getTID
();
while
(
active
)
while
(
isActive
()
)
{
callback
();
}
...
...
@@ -899,5 +899,16 @@ bool UniSetObject::PriorVMsgCompare::operator()(const UniSetTypes::VoidMessage&
return
lhs
.
priority
<
rhs
.
priority
;
}
// ------------------------------------------------------------------------------------------
void
UniSetObject
::
setActive
(
bool
set
)
{
uniset_mutex_lock
l
(
act_mutex
,
300
);
active
=
set
;
}
// ------------------------------------------------------------------------------------------
bool
UniSetObject
::
isActive
()
{
uniset_mutex_lock
l
(
act_mutex
,
200
);
return
active
;
}
// ------------------------------------------------------------------------------------------
#undef CREATE_TIMER
src/Processes/IOController.cc
View file @
46c1e49f
...
...
@@ -151,7 +151,9 @@ bool IOController::localGetState( IOController::DIOStateList::iterator& li,
ostringstream
err
;
err
<<
myname
<<
"(localGetState): дискретный вход(выход) с именем "
<<
conf
->
oind
->
getNameById
(
si
.
id
)
<<
" не найден"
;
unideb
[
Debug
::
INFO
]
<<
err
.
str
()
<<
endl
;
if
(
unideb
.
debugging
(
Debug
::
INFO
)
)
unideb
[
Debug
::
INFO
]
<<
err
.
str
()
<<
endl
;
throw
IOController_i
::
NameNotFound
(
err
.
str
().
c_str
());
}
// ---------------------------------------------------------------------------
...
...
@@ -174,7 +176,8 @@ long IOController::localGetValue( IOController::AIOStateList::iterator& li,
ostringstream
err
;
err
<<
myname
<<
"(localGetValue): аналоговый вход(выход) с именем "
<<
conf
->
oind
->
getNameById
(
si
.
id
)
<<
" не найден"
;
unideb
[
Debug
::
INFO
]
<<
err
.
str
()
<<
endl
;
if
(
unideb
.
debugging
(
Debug
::
INFO
)
)
unideb
[
Debug
::
INFO
]
<<
err
.
str
()
<<
endl
;
throw
IOController_i
::
NameNotFound
(
err
.
str
().
c_str
());
}
// ------------------------------------------------------------------------------------------
...
...
src/Timers/ThrPassiveTimer.cc
View file @
46c1e49f
...
...
@@ -50,32 +50,42 @@ ThrPassiveTimer::~ThrPassiveTimer()
delete
tmutex
;
}
// ------------------------------------------------------------------------------------------
bool
ThrPassiveTimer
::
isTerminated
()
{
UniSetTypes
::
uniset_mutex_lock
l
(
term_mutex
,
100
);
return
terminated
;
}
// ------------------------------------------------------------------------------------------
void
ThrPassiveTimer
::
setTerminated
(
bool
set
)
{
UniSetTypes
::
uniset_mutex_lock
l
(
term_mutex
,
200
);
terminated
=
set
;
}
// ------------------------------------------------------------------------------------------
void
ThrPassiveTimer
::
terminate
()
{
if
(
!
terminated
)
if
(
!
isTerminated
()
)
{
// tmutex->lock();
terminated
=
1
;
setTerminated
(
true
);
tcondx
->
signal
();
// tmutex->unlock();
}
}
// ------------------------------------------------------------------------------------------
bool
ThrPassiveTimer
::
wait
(
timeout_t
timeMS
)
bool
ThrPassiveTimer
::
wait
(
timeout_t
time_msec
)
{
terminated
=
0
;
setTerminated
(
false
)
;
{
tmutex
->
lock
();
timeout_t
t
mMS
=
PassiveTimer
::
setTiming
(
timeMS
);
// вызываем для совместимости с обычным PassiveTimer-ом
if
(
time
MS
==
WaitUpTime
)
timeout_t
t
_msec
=
PassiveTimer
::
setTiming
(
time_msec
);
// вызываем для совместимости с обычным PassiveTimer-ом
if
(
time
_msec
==
WaitUpTime
)
{
while
(
!
terminated
)
// на всякий, вдруг проснется по ошибке...
while
(
!
isTerminated
()
)
// на всякий, вдруг проснется по ошибке...
tcondx
->
wait
();
}
else
{
unsigned
long
sec
,
msec
;
omni_thread
::
get_time
(
&
sec
,
&
msec
,
t
mMS
/
1000
,
(
tmMS
%
1000
)
*
1000000
);
omni_thread
::
get_time
(
&
sec
,
&
msec
,
t
_msec
/
1000
,
(
t_msec
%
1000
)
*
1000000
);
// cout <<"timer: спим "<< timeMS/1000 << "[сек] и " << (timeMS%1000)*1000000 <<"[мсек]" << endl;
tcondx
->
timedwait
(
sec
,
msec
);
}
...
...
@@ -83,7 +93,7 @@ bool ThrPassiveTimer::wait(timeout_t timeMS)
tmutex
->
unlock
();
}
terminated
=
1
;
setTerminated
(
true
)
;
return
true
;
}
// ------------------------------------------------------------------------------------------
...
...
src/Various/UniXML.cc
View file @
46c1e49f
...
...
@@ -122,7 +122,8 @@ string UniXML::getProp(const xmlNode* node, const string name)
const
char
*
text
=
(
const
char
*
)
::
xmlGetProp
((
xmlNode
*
)
node
,
(
const
xmlChar
*
)
name
.
c_str
());
if
(
text
==
NULL
)
return
""
;
return
text
;
return
string
(
text
);
}
int
UniXML
::
getIntProp
(
const
xmlNode
*
node
,
const
string
name
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment