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
9e8d9030
Commit
9e8d9030
authored
Jan 06, 2015
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(9) Попытка решить проблеммы с утчечками памяти.
parent
71691352
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
83 additions
and
74 deletions
+83
-74
SharedMemory.cc
extensions/SharedMemory/SharedMemory.cc
+6
-9
SharedMemory.h
extensions/SharedMemory/SharedMemory.h
+2
-1
Configuration.h
include/Configuration.h
+2
-2
IONotifyController.h
include/IONotifyController.h
+3
-0
UniXML.h
include/UniXML.h
+3
-1
ObjectIndex_XML.cc
src/ObjectRepository/ObjectIndex_XML.cc
+5
-10
ObjectIndex_idXML.cc
src/ObjectRepository/ObjectIndex_idXML.cc
+6
-15
UniSetActivator.cc
src/ObjectRepository/UniSetActivator.cc
+6
-2
IONotifyController.cc
src/Processes/IONotifyController.cc
+4
-2
NCRestorer.cc
src/Processes/NCRestorer.cc
+1
-2
NCRestorer_XML.cc
src/Processes/NCRestorer_XML.cc
+18
-10
Configuration.cc
src/Various/Configuration.cc
+20
-16
UniXML.cc
src/Various/UniXML.cc
+7
-4
No files found.
extensions/SharedMemory/SharedMemory.cc
View file @
9e8d9030
...
...
@@ -597,25 +597,22 @@ void SharedMemory::checkHistoryFilter( UniXML::iterator& xit )
if
(
xit
.
getProp
(
it
.
filter
).
empty
()
)
continue
;
HistoryItem
ai
;
if
(
!
xit
.
getProp
(
"id"
).
empty
()
)
{
ai
.
id
=
xit
.
getIntProp
(
"id"
);
ai
.
init
(
it
.
size
,
xit
.
getIntProp
(
"default"
)
);
it
.
hlst
.
push_back
(
ai
);
HistoryItem
ai
(
xit
.
getIntProp
(
"id"
),
it
.
size
,
xit
.
getIntProp
(
"default"
)
);
it
.
hlst
.
push_back
(
std
::
move
(
ai
)
);
continue
;
}
ai
.
id
=
uniset_conf
()
->
getSensorID
(
xit
.
getProp
(
"name"
));
if
(
ai
.
id
==
DefaultObjectId
)
ObjectId
id
=
uniset_conf
()
->
getSensorID
(
xit
.
getProp
(
"name"
));
if
(
id
==
DefaultObjectId
)
{
dwarn
<<
myname
<<
"(checkHistoryFilter): not found sensor ID for "
<<
xit
.
getProp
(
"name"
)
<<
endl
;
continue
;
}
ai
.
init
(
it
.
size
,
xit
.
getIntProp
(
"default"
)
);
it
.
hlst
.
push_back
(
ai
);
HistoryItem
ai
(
id
,
it
.
size
,
xit
.
getIntProp
(
"default"
)
);
it
.
hlst
.
push_back
(
std
::
move
(
ai
)
);
}
}
// -----------------------------------------------------------------------------
...
...
extensions/SharedMemory/SharedMemory.h
View file @
9e8d9030
...
...
@@ -277,7 +277,8 @@ class SharedMemory:
struct
HistoryItem
{
HistoryItem
()
:
id
(
UniSetTypes
::
DefaultObjectId
){}
HistoryItem
(
size_t
bufsize
=
0
)
:
id
(
UniSetTypes
::
DefaultObjectId
),
buf
(
bufsize
){}
HistoryItem
(
const
UniSetTypes
::
ObjectId
_id
,
const
size_t
bufsize
,
const
long
val
)
:
id
(
_id
),
buf
(
bufsize
,
val
){}
inline
void
init
(
unsigned
int
size
,
long
val
)
{
...
...
include/Configuration.h
View file @
9e8d9030
...
...
@@ -160,8 +160,8 @@ namespace UniSetTypes
/*! указатель на конфигурационный xml */
inline
const
std
::
shared_ptr
<
UniXML
>
getConfXML
()
const
{
return
unixml
;
}
CORBA
::
ORB_ptr
getORB
()
const
{
return
CORBA
::
ORB
::
_duplicate
(
orb
);
}
CORBA
::
PolicyList
getPolicy
()
const
{
return
policyList
;
}
inline
CORBA
::
ORB_ptr
getORB
()
const
{
return
CORBA
::
ORB
::
_duplicate
(
orb
);
}
inline
const
CORBA
::
PolicyList
getPolicy
()
const
{
return
policyList
;
}
protected
:
Configuration
();
...
...
include/IONotifyController.h
View file @
9e8d9030
...
...
@@ -331,6 +331,9 @@ class IONotifyController:
UniSetTypes
::
uniset_rwmutex
trshMutex
;
int
maxAttemtps
;
/*! timeout for consumer */
sigc
::
connection
conInit
;
sigc
::
connection
conUndef
;
};
// --------------------------------------------------------------------------
#endif
...
...
include/UniXML.h
View file @
9e8d9030
...
...
@@ -188,7 +188,7 @@ public:
xmlNode
*
cur
;
xmlDoc
*
doc
;
std
::
string
filename
;
inline
std
::
string
getFileName
(){
return
filename
;
}
// Создать новый XML-документ
void
newDoc
(
const
std
::
string
&
root_node
,
std
::
string
xml_ver
=
"1.0"
);
...
...
@@ -235,6 +235,8 @@ public:
protected
:
std
::
string
filename
;
// Преобразование текстовой строки из XML в строку нашего внутреннего представления
static
std
::
string
xml2local
(
const
std
::
string
&
text
);
...
...
src/ObjectRepository/ObjectIndex_XML.cc
View file @
9e8d9030
...
...
@@ -180,10 +180,9 @@ unsigned int ObjectIndex_XML::read_section( const std::shared_ptr<UniXML>& xml,
// name
ostringstream
n
;
n
<<
secname
<<
xml
->
getProp
(
it
,
"name"
);
const
string
name
(
n
.
str
());
delete
[]
omap
[
ind
].
repName
;
omap
[
ind
].
repName
=
new
char
[
name
.
size
()
+
1
]
;
strcpy
(
omap
[
ind
].
repName
,
name
.
c_str
()
);
const
string
name
(
n
.
str
())
;
omap
[
ind
].
repName
=
uni_strdup
(
name
);
// mok
mok
[
name
]
=
ind
;
// mok[omap[ind].repName] = ind;
...
...
@@ -194,8 +193,7 @@ unsigned int ObjectIndex_XML::read_section( const std::shared_ptr<UniXML>& xml,
textname
=
xml
->
getProp
(
it
,
"name"
);
delete
[]
omap
[
ind
].
textName
;
omap
[
ind
].
textName
=
new
char
[
textname
.
size
()
+
1
];
strcpy
(
omap
[
ind
].
textName
,
textname
.
c_str
()
);
omap
[
ind
].
textName
=
uni_strdup
(
textname
);
omap
[
ind
].
data
=
(
void
*
)(
xmlNode
*
)
it
;
...
...
@@ -249,8 +247,7 @@ unsigned int ObjectIndex_XML::read_nodes( const std::shared_ptr<UniXML>& xml, co
string
nodename
(
xml
->
getProp
(
it
,
"name"
));
delete
[]
omap
[
ind
].
repName
;
omap
[
ind
].
repName
=
new
char
[
nodename
.
size
()
+
1
];
strcpy
(
omap
[
ind
].
repName
,
nodename
.
c_str
()
);
omap
[
ind
].
repName
=
uni_strdup
(
nodename
);
// textname
string
textname
(
xml
->
getProp
(
it
,
"textname"
));
...
...
@@ -258,9 +255,7 @@ unsigned int ObjectIndex_XML::read_nodes( const std::shared_ptr<UniXML>& xml, co
textname
=
nodename
;
delete
[]
omap
[
ind
].
textName
;
omap
[
ind
].
textName
=
new
char
[
textname
.
size
()
+
1
];
strcpy
(
omap
[
ind
].
textName
,
textname
.
c_str
()
);
omap
[
ind
].
textName
=
uni_strdup
(
textname
);
omap
[
ind
].
data
=
(
void
*
)(
xmlNode
*
)(
it
);
//
mok
[
omap
[
ind
].
repName
]
=
ind
;
...
...
src/ObjectRepository/ObjectIndex_idXML.cc
View file @
9e8d9030
...
...
@@ -149,23 +149,18 @@ void ObjectIndex_idXML::read_section( const std::shared_ptr<UniXML>& xml, const
// name
ostringstream
n
;
n
<<
secname
<<
it
.
getProp
(
"name"
);
string
name
(
n
.
str
());
const
string
name
(
n
.
str
());
inf
.
repName
=
uni_strdup
(
name
);
inf
.
repName
=
new
char
[
name
.
size
()
+
1
];
strcpy
(
inf
.
repName
,
name
.
c_str
()
);
// textname
string
textname
(
xml
->
getProp
(
it
,
"textname"
));
if
(
textname
.
empty
()
)
textname
=
xml
->
getProp
(
it
,
"name"
);
inf
.
textName
=
new
char
[
textname
.
size
()
+
1
];
strcpy
(
inf
.
textName
,
textname
.
c_str
()
);
inf
.
textName
=
uni_strdup
(
textname
);
inf
.
data
=
(
void
*
)(
xmlNode
*
)(
it
);
omap
.
insert
(
MapObjects
::
value_type
(
inf
.
id
,
inf
));
// omap[inf.id] = inf;
mok
.
insert
(
MapObjectKey
::
value_type
(
name
,
inf
.
id
));
// mok[name] = inf.id;
omap
.
insert
(
MapObjects
::
value_type
(
inf
.
id
,
std
::
move
(
inf
)));
// omap[inf.id] = inf;
}
}
// ------------------------------------------------------------------------------------------
...
...
@@ -202,18 +197,14 @@ void ObjectIndex_idXML::read_nodes( const std::shared_ptr<UniXML>& xml, const st
}
string
name
(
it
.
getProp
(
"name"
));
inf
.
repName
=
new
char
[
name
.
size
()
+
1
];
strcpy
(
inf
.
repName
,
name
.
c_str
()
);
inf
.
repName
=
uni_strdup
(
name
);
// textname
string
textname
(
xml
->
getProp
(
it
,
"textname"
));
if
(
textname
.
empty
()
)
textname
=
name
;
inf
.
textName
=
new
char
[
textname
.
size
()
+
1
];
strcpy
(
inf
.
textName
,
textname
.
c_str
()
);
inf
.
textName
=
uni_strdup
(
textname
);
inf
.
data
=
(
void
*
)(
xmlNode
*
)(
it
);
omap
.
insert
(
MapObjects
::
value_type
(
inf
.
id
,
inf
));
// omap[inf.id] = inf;
...
...
src/ObjectRepository/UniSetActivator.cc
View file @
9e8d9030
...
...
@@ -126,7 +126,7 @@ void UniSetActivator::init()
CORBA
::
Object_var
obj
=
orb
->
resolve_initial_references
(
"RootPOA"
);
PortableServer
::
POA_var
root_poa
=
PortableServer
::
POA
::
_narrow
(
obj
);
pman
=
root_poa
->
the_POAManager
();
CORBA
::
PolicyList
pl
=
conf
->
getPolicy
();
const
CORBA
::
PolicyList
pl
=
conf
->
getPolicy
();
poa
=
root_poa
->
create_POA
(
"my poa"
,
pman
,
pl
);
if
(
CORBA
::
is_nil
(
poa
)
)
...
...
@@ -410,7 +410,11 @@ void UniSetActivator::sysCommand( const UniSetTypes::SystemMessage *sm )
// -------------------------------------------------------------------------
void
UniSetActivator
::
set_signals
(
bool
ask
)
{
struct
sigaction
act
,
oact
;
struct
sigaction
act
;
// = { { 0 } };
struct
sigaction
oact
;
// = { { 0 } };
memset
(
&
act
,
0
,
sizeof
(
act
));
memset
(
&
act
,
0
,
sizeof
(
oact
));
sigemptyset
(
&
act
.
sa_mask
);
sigemptyset
(
&
oact
.
sa_mask
);
...
...
src/Processes/IONotifyController.cc
View file @
9e8d9030
...
...
@@ -65,8 +65,8 @@ IONotifyController::IONotifyController( ObjectId id, NCRestorer* d ):
trshMutex
(
string
(
uniset_conf
()
->
oind
->
getMapName
(
id
))
+
"_trshMutex"
),
maxAttemtps
(
uniset_conf
()
->
getPIntField
(
"ConsumerMaxAttempts"
,
5
))
{
signal_change_undefined_state
().
connect
(
sigc
::
mem_fun
(
*
this
,
&
IONotifyController
::
onChangeUndefinedState
));
signal_init
().
connect
(
sigc
::
mem_fun
(
*
this
,
&
IONotifyController
::
initItem
));
conUndef
=
signal_change_undefined_state
().
connect
(
sigc
::
mem_fun
(
*
this
,
&
IONotifyController
::
onChangeUndefinedState
));
conInit
=
signal_init
().
connect
(
sigc
::
mem_fun
(
*
this
,
&
IONotifyController
::
initItem
));
// добавляем фильтры
addIOFilter
(
sigc
::
mem_fun
(
this
,
&
IONotifyController
::
myIOFilter
)
);
...
...
@@ -74,6 +74,8 @@ IONotifyController::IONotifyController( ObjectId id, NCRestorer* d ):
IONotifyController
::~
IONotifyController
()
{
conUndef
.
disconnect
();
conInit
.
disconnect
();
}
// ------------------------------------------------------------------------------------------
...
...
src/Processes/NCRestorer.cc
View file @
9e8d9030
...
...
@@ -159,8 +159,7 @@ void NCRestorer::init_depends_signals( IONotifyController* ic )
<<
" dep_name=("
<<
it
->
second
.
d_si
.
id
<<
")'"
<<
uniset_conf
()
->
oind
->
getMapName
(
it
->
second
.
d_si
.
id
)
<<
"'"
<<
endl
;
IOController
::
ChangeSignal
s
=
ic
->
signal_change_value
(
it
->
second
.
d_si
.
id
);
s
.
connect
(
sigc
::
mem_fun
(
&
it
->
second
,
&
IOController
::
USensorInfo
::
checkDepend
)
);
ic
->
signal_change_value
(
it
->
second
.
d_si
.
id
).
connect
(
sigc
::
mem_fun
(
&
it
->
second
,
&
IOController
::
USensorInfo
::
checkDepend
)
);
}
}
// -----------------------------------------------------------------------------
src/Processes/NCRestorer_XML.cc
View file @
9e8d9030
...
...
@@ -40,7 +40,7 @@ c_filterValue(""),
t_filterField
(
""
),
t_filterValue
(
""
),
fname
(
fname
),
uxml
(
0
)
uxml
(
nullptr
)
{
init
(
fname
);
}
...
...
@@ -55,7 +55,7 @@ c_filterValue(""),
t_filterField
(
""
),
t_filterValue
(
""
),
fname
(
fname
),
uxml
(
0
)
uxml
(
nullptr
)
{
init
(
fname
);
setItemFilter
(
f_field
,
f_value
);
...
...
@@ -63,7 +63,7 @@ uxml(0)
NCRestorer_XML
::
NCRestorer_XML
()
:
fname
(
""
),
uxml
(
0
)
uxml
(
nullptr
)
{
}
...
...
@@ -77,7 +77,7 @@ NCRestorer_XML::~NCRestorer_XML()
}
}
// ------------------------------------------------------------------------------------------
void
NCRestorer_XML
::
init
(
const
std
::
string
&
fnam
e
)
void
NCRestorer_XML
::
init
(
const
std
::
string
&
xmlfil
e
)
{
/*!
\warning Файл открывается только при создании...
...
...
@@ -85,14 +85,22 @@ void NCRestorer_XML::init( const std::string& fname )
*/
try
{
if
(
fnam
e
==
uniset_conf
()
->
getConfFileName
()
)
if
(
xmlfil
e
==
uniset_conf
()
->
getConfFileName
()
)
uxml
=
uniset_conf
()
->
getConfXML
();
else
uxml
=
make_shared
<
UniXML
>
(
fname
);
{
if
(
uxml
)
{
uxml
->
close
();
uxml
.
reset
();
}
uxml
=
make_shared
<
UniXML
>
(
xmlfile
);
}
fname
=
xmlfile
;
}
catch
(
UniSetTypes
::
NameNotFound
&
ex
)
{
uwarn
<<
"(NCRestorer_XML): файл "
<<
fnam
e
<<
" не найден, создаём новый...
\n
"
;
uwarn
<<
"(NCRestorer_XML): файл "
<<
xmlfil
e
<<
" не найден, создаём новый...
\n
"
;
}
}
// ------------------------------------------------------------------------------------------
...
...
@@ -180,9 +188,9 @@ void NCRestorer_XML::read( IONotifyController* ic, const string& fn )
else
if
(
!
fname
.
empty
()
)
{
// оптимизация (не загружаем второй раз xml-файл)
if
(
fname
==
uniset_conf
()
->
getConfFileName
()
&&
confxml
)
read
(
ic
,
confxml
);
else
if
(
uxml
&&
uxml
->
isOpen
()
&&
uxml
->
filename
==
fn
)
if
(
confxml
&&
fname
==
confxml
->
getFileName
()
)
read
(
ic
,
confxml
);
else
if
(
uxml
&&
uxml
->
isOpen
()
&&
uxml
->
getFileName
()
==
fname
)
read
(
ic
,
uxml
);
else
{
...
...
src/Various/Configuration.cc
View file @
9e8d9030
...
...
@@ -107,11 +107,17 @@ Configuration::~Configuration()
delete
[]
_argv
[
i
];
delete
[]
_argv
;
if
(
oind
)
oind
.
reset
();
if
(
unixml
)
unixml
.
reset
();
}
// ---------------------------------------------------------------------------------
Configuration
::
Configuration
(
int
argc
,
const
char
*
const
*
argv
,
const
string
&
xmlfile
)
:
oind
(
NULL
),
oind
(
nullptr
),
unixml
(
nullptr
),
_argc
(
argc
),
_argv
(
argv
),
NSName
(
"NameService"
),
...
...
@@ -129,7 +135,8 @@ Configuration::Configuration( int argc, const char* const* argv, const string& x
// ---------------------------------------------------------------------------------
Configuration
::
Configuration
(
int
argc
,
const
char
*
const
*
argv
,
shared_ptr
<
ObjectIndex
>
_oind
,
const
string
&
fileConf
)
:
oind
(
NULL
),
oind
(
nullptr
),
unixml
(
nullptr
),
_argc
(
argc
),
_argv
(
argv
),
NSName
(
"NameService"
),
...
...
@@ -198,7 +205,7 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
try
{
if
(
unixml
==
nullptr
)
unixml
=
std
::
shared_ptr
<
UniXML
>
(
new
UniXML
()
);
unixml
=
make_shared
<
UniXML
>
(
);
if
(
!
unixml
->
isOpen
()
)
{
...
...
@@ -358,26 +365,23 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
// create policy
CORBA
::
Object_var
obj
=
orb
->
resolve_initial_references
(
"RootPOA"
);
PortableServer
::
POA_var
root_poa
=
PortableServer
::
POA
::
_narrow
(
obj
);
CORBA
::
PolicyList
pl
;
if
(
transientIOR
==
false
)
{
p
l
.
length
(
3
);
p
l
[
0
]
=
root_poa
->
create_lifespan_policy
(
PortableServer
::
PERSISTENT
);
p
l
[
1
]
=
root_poa
->
create_id_assignment_policy
(
PortableServer
::
USER_ID
);
p
l
[
2
]
=
root_poa
->
create_request_processing_policy
(
PortableServer
::
USE_ACTIVE_OBJECT_MAP_ONLY
);
// p
l
[3] = root_poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL);
p
olicyList
.
length
(
3
);
p
olicyList
[
0
]
=
root_poa
->
create_lifespan_policy
(
PortableServer
::
PERSISTENT
);
p
olicyList
[
1
]
=
root_poa
->
create_id_assignment_policy
(
PortableServer
::
USER_ID
);
p
olicyList
[
2
]
=
root_poa
->
create_request_processing_policy
(
PortableServer
::
USE_ACTIVE_OBJECT_MAP_ONLY
);
// p
olicyList
[3] = root_poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL);
}
else
{
p
l
.
length
(
3
);
p
l
[
0
]
=
root_poa
->
create_lifespan_policy
(
PortableServer
::
TRANSIENT
);
p
l
[
1
]
=
root_poa
->
create_servant_retention_policy
(
PortableServer
::
RETAIN
);
p
l
[
2
]
=
root_poa
->
create_request_processing_policy
(
PortableServer
::
USE_ACTIVE_OBJECT_MAP_ONLY
);
// p
l
[3] = root_poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL);
p
olicyList
.
length
(
3
);
p
olicyList
[
0
]
=
root_poa
->
create_lifespan_policy
(
PortableServer
::
TRANSIENT
);
p
olicyList
[
1
]
=
root_poa
->
create_servant_retention_policy
(
PortableServer
::
RETAIN
);
p
olicyList
[
2
]
=
root_poa
->
create_request_processing_policy
(
PortableServer
::
USE_ACTIVE_OBJECT_MAP_ONLY
);
// p
olicyList
[3] = root_poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL);
}
policyList
=
pl
;
// ---------------------------------------
}
...
...
src/Various/UniXML.cc
View file @
9e8d9030
...
...
@@ -118,13 +118,16 @@ string UniXML::getPropUtf8(const xmlNode* node, const string& name)
string
UniXML
::
getProp
(
const
xmlNode
*
node
,
const
string
&
name
)
{
const
char
*
text
=
(
const
char
*
)
::
xmlGetProp
((
xmlNode
*
)
node
,
(
const
xmlChar
*
)
name
.
c_str
());
xmlChar
*
text
=
::
xmlGetProp
((
xmlNode
*
)
node
,
(
const
xmlChar
*
)
name
.
c_str
());
if
(
text
==
NULL
)
{
xmlFree
(
text
);
return
""
;
}
string
t
(
text
);
xmlFree
(
(
void
*
)
text
);
return
t
;
const
string
t
(
(
const
char
*
)
text
);
xmlFree
(
text
);
return
std
::
move
(
t
)
;
}
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