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
053f990d
Commit
053f990d
authored
Jun 28, 2017
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(step 2): fixes after converity scan (
https://scan9.coverity.com
)
parent
94c9da47
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
114 additions
and
53 deletions
+114
-53
IOControl.cc
extensions/IOControl/IOControl.cc
+4
-4
MBTCPMaster.cc
extensions/ModbusMaster/MBTCPMaster.cc
+10
-3
MBTCPMultiMaster.cc
extensions/ModbusMaster/MBTCPMultiMaster.cc
+6
-0
MBTCPMultiMaster.h
extensions/ModbusMaster/MBTCPMultiMaster.h
+1
-0
mq-test.cc
extensions/tests/MQPerfTest/mq-test.cc
+1
-1
UInterface.h
include/UInterface.h
+2
-2
ModbusTypes.cc
src/Communications/Modbus/ModbusTypes.cc
+4
-2
UInterface.cc
src/Interfaces/UInterface.cc
+41
-24
DebugStream.cc
src/Log/DebugStream.cc
+4
-0
UniSetActivator.cc
src/ObjectRepository/UniSetActivator.cc
+8
-1
IOController.cc
src/Processes/IOController.cc
+2
-2
IONotifyController.cc
src/Processes/IONotifyController.cc
+4
-0
Configuration.cc
src/Various/Configuration.cc
+7
-12
Mutex.cc
src/Various/Mutex.cc
+17
-2
SViewer.cc
src/Various/SViewer.cc
+2
-0
develop.cc
tests/develop.cc
+1
-0
No files found.
extensions/IOControl/IOControl.cc
View file @
053f990d
...
...
@@ -466,7 +466,7 @@ namespace uniset
return
;
// Опрос приоритетной очереди
for
(
auto
it
:
pmap
)
for
(
auto
&&
it
:
pmap
)
{
if
(
it
.
priority
>
0
)
{
...
...
@@ -491,7 +491,7 @@ namespace uniset
// опять опросим приоритетные
if
(
!
prior
&&
i
>
maxHalf
)
{
for
(
auto
&
p
:
pmap
)
for
(
auto
&
&
p
:
pmap
)
{
if
(
p
.
priority
>
1
)
{
...
...
@@ -505,7 +505,7 @@ namespace uniset
}
// Опрос приоритетной очереди
for
(
auto
&
it
:
pmap
)
for
(
auto
&
&
it
:
pmap
)
{
if
(
it
.
priority
>
2
)
{
...
...
@@ -1304,8 +1304,8 @@ namespace uniset
{
if
(
!
force
)
{
force
=
true
;
std
::
lock_guard
<
std
::
mutex
>
l
(
iopollMutex
);
force
=
true
;
iopoll
();
force
=
false
;
}
...
...
extensions/ModbusMaster/MBTCPMaster.cc
View file @
053f990d
...
...
@@ -80,10 +80,17 @@ MBTCPMaster::~MBTCPMaster()
{
if
(
pollThread
)
{
pollThread
->
stop
();
try
{
pollThread
->
stop
();
if
(
pollThread
->
isRunning
()
)
pollThread
->
join
();
if
(
pollThread
->
isRunning
()
)
pollThread
->
join
();
}
catch
(
Poco
::
NullPointerException
&
ex
)
{
}
}
}
// -----------------------------------------------------------------------------
...
...
extensions/ModbusMaster/MBTCPMultiMaster.cc
View file @
053f990d
...
...
@@ -422,6 +422,12 @@ void MBTCPMultiMaster::MBSlaveInfo::setUse( bool st )
use
=
st
;
}
// -----------------------------------------------------------------------------
bool
MBTCPMultiMaster
::
MBSlaveInfo
::
isUse
()
{
std
::
lock_guard
<
std
::
mutex
>
l
(
mutInit
);
return
use
;
}
// -----------------------------------------------------------------------------
bool
MBTCPMultiMaster
::
MBSlaveInfo
::
init
(
std
::
shared_ptr
<
DebugStream
>&
mblog
)
{
std
::
lock_guard
<
std
::
mutex
>
l
(
mutInit
);
...
...
extensions/ModbusMaster/MBTCPMultiMaster.h
View file @
053f990d
...
...
@@ -354,6 +354,7 @@ namespace uniset
bool
init
(
std
::
shared_ptr
<
DebugStream
>&
mblog
);
bool
check
();
void
setUse
(
bool
st
);
bool
isUse
();
timeout_t
recv_timeout
;
timeout_t
aftersend_pause
;
...
...
extensions/tests/MQPerfTest/mq-test.cc
View file @
053f990d
...
...
@@ -45,7 +45,7 @@ int main(int argc, const char** argv)
end
=
std
::
chrono
::
system_clock
::
now
();
int
elapsed_seconds
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
end
-
start
).
count
();
std
::
cerr
<<
"elapsed time: "
<<
elapsed_seconds
<<
" ms num="
<<
num
<<
endl
;
std
::
cerr
<<
"speed: "
<<
(
(
float
)
elapsed_seconds
/
num
)
<<
" msg per sec"
<<
endl
;
std
::
cerr
<<
"speed: "
<<
(
num
>
0
?
((
float
)
elapsed_seconds
/
num
)
:
0
)
<<
" msg per sec"
<<
endl
;
return
0
;
}
...
...
include/UInterface.h
View file @
053f990d
...
...
@@ -37,7 +37,7 @@
#include "Configuration.h"
// -----------------------------------------------------------------------------------------
#define UI_THROW_EXCEPTIONS uniset::TimeOut,uniset::IOBadParam,uniset::ORepFailed
#define UI_THROW_EXCEPTIONS uniset::TimeOut,uniset::IOBadParam,uniset::ORepFailed
,uniset::SystemError
// -----------------------------------------------------------------------------------------
namespace
uniset
{
...
...
@@ -248,7 +248,7 @@ namespace uniset
MaxSize
(
maxsize
),
minCallCount
(
cleancount
)
{};
~
CacheOfResolve
()
{};
uniset
::
ObjectPtr
resolve
(
const
uniset
::
ObjectId
id
,
const
uniset
::
ObjectId
node
)
const
throw
(
uniset
::
NameNotFound
);
uniset
::
ObjectPtr
resolve
(
const
uniset
::
ObjectId
id
,
const
uniset
::
ObjectId
node
)
const
throw
(
uniset
::
NameNotFound
,
uniset
::
SystemError
);
void
cache
(
const
uniset
::
ObjectId
id
,
const
uniset
::
ObjectId
node
,
uniset
::
ObjectVar
&
ptr
)
const
;
void
erase
(
const
uniset
::
ObjectId
id
,
const
uniset
::
ObjectId
node
)
const
noexcept
;
...
...
src/Communications/Modbus/ModbusTypes.cc
View file @
053f990d
...
...
@@ -757,7 +757,7 @@ namespace uniset
void
ReadInputStatusMessage
::
init
(
const
ModbusMessage
&
m
)
{
assert
(
m
.
pduhead
.
func
==
fnReadInputStatus
);
memcpy
(
this
,
&
m
.
pduhead
,
sizeof
(
m
.
pduhead
)
+
szData
());
memcpy
(
this
,
&
(
m
.
pduhead
)
,
sizeof
(
m
.
pduhead
)
+
szData
());
// переворачиваем слова
start
=
SWAPSHORT
(
start
);
...
...
@@ -961,8 +961,10 @@ namespace uniset
void
ReadOutputMessage
::
init
(
const
ModbusMessage
&
m
)
{
assert
(
m
.
pduhead
.
func
==
fnReadOutputRegisters
);
func
=
m
.
pduhead
.
func
;
addr
=
m
.
pduhead
.
addr
;
//memset(this, 0, sizeof(*this));
memcpy
(
this
,
&
m
.
pduhead
,
sizeof
(
m
.
pduhead
)
+
szData
());
memcpy
(
&
start
,
&
m
.
data
,
szData
());
// переворачиваем слова
start
=
SWAPSHORT
(
start
);
...
...
src/Interfaces/UInterface.cc
View file @
053f990d
...
...
@@ -1265,23 +1265,30 @@ namespace uniset
}
// ------------------------------------------------------------------------------------------------------------
uniset
::
ObjectPtr
UInterface
::
CacheOfResolve
::
resolve
(
const
uniset
::
ObjectId
id
,
const
uniset
::
ObjectId
node
)
const
throw
(
uniset
::
NameNotFound
)
throw
(
uniset
::
NameNotFound
,
uniset
::
SystemError
)
{
uniset
::
uniset_rwmutex_rlock
l
(
cmutex
);
auto
it
=
mcache
.
find
(
uniset
::
key
(
id
,
node
)
);
if
(
it
==
mcache
.
end
()
)
throw
uniset
::
NameNotFound
();
try
{
uniset
::
uniset_rwmutex_rlock
l
(
cmutex
);
it
->
second
.
ncall
++
;
auto
it
=
mcache
.
find
(
uniset
::
key
(
id
,
node
)
)
;
// т.к. функция возвращает указатель
// и тот кто вызывает отвечает за освобождение памяти
// то мы делаем _duplicate....
if
(
it
!=
mcache
.
end
()
)
{
it
->
second
.
ncall
++
;
if
(
!
CORBA
::
is_nil
(
it
->
second
.
ptr
)
)
return
CORBA
::
Object
::
_duplicate
(
it
->
second
.
ptr
);
// т.к. функция возвращает указатель
// и тот кто вызывает отвечает за освобождение памяти
// то мы делаем _duplicate....
if
(
!
CORBA
::
is_nil
(
it
->
second
.
ptr
)
)
return
CORBA
::
Object
::
_duplicate
(
it
->
second
.
ptr
);
}
}
catch
(
std
::
exception
&
ex
)
{
uwarn
<<
"UI(CacheOfResolve::resolve): exception: "
<<
ex
.
what
()
<<
endl
;
throw
uniset
::
SystemError
(
ex
.
what
());
}
throw
uniset
::
NameNotFound
();
}
...
...
@@ -1305,22 +1312,29 @@ namespace uniset
// ------------------------------------------------------------------------------------------------------------
bool
UInterface
::
CacheOfResolve
::
clean
()
noexcept
{
uniset
::
uniset_rwmutex_wrlock
l
(
cmutex
);
try
{
uniset
::
uniset_rwmutex_wrlock
l
(
cmutex
);
uinfo
<<
"UI: clean cache...."
<<
endl
;
uinfo
<<
"UI: clean cache...."
<<
endl
;
for
(
auto
it
=
mcache
.
begin
();
it
!=
mcache
.
end
();)
{
if
(
it
->
second
.
ncall
<=
minCallCount
)
for
(
auto
it
=
mcache
.
begin
();
it
!=
mcache
.
end
();)
{
try
if
(
it
->
second
.
ncall
<=
minCallCount
)
{
mcache
.
erase
(
it
++
);
try
{
mcache
.
erase
(
it
++
);
}
catch
(...)
{}
}
catch
(...)
{}
else
++
it
;
}
else
++
it
;
}
catch
(
std
::
exception
&
ex
)
{
uwarn
<<
"UI::Chache::clean: exception: "
<<
ex
.
what
()
<<
endl
;
}
if
(
mcache
.
size
()
<
MaxSize
)
...
...
@@ -1341,7 +1355,10 @@ namespace uniset
if
(
it
!=
mcache
.
end
()
)
mcache
.
erase
(
it
);
}
catch
(...)
{}
catch
(
std
::
exception
&
ex
)
{
uwarn
<<
"UI::Chache::erase: exception: "
<<
ex
.
what
()
<<
endl
;
}
}
// ------------------------------------------------------------------------------------------------------------
...
...
src/Log/DebugStream.cc
View file @
053f990d
...
...
@@ -238,11 +238,15 @@ std::ostream& DebugStream::printDateTime(Debug::type t) noexcept
<<
std
::
setw
(
2
)
<<
std
::
setfill
(
'0'
)
<<
tms
.
tm_sec
;
#endif
std
::
ios_base
::
fmtflags
old_flags
=
this
->
flags
();
if
(
show_usec
)
(
*
this
)
<<
"."
<<
std
::
setw
(
6
)
<<
std
::
setfill
(
'0'
)
<<
(
tv
.
tv_nsec
/
1000
);
else
if
(
show_msec
)
(
*
this
)
<<
"."
<<
std
::
setw
(
3
)
<<
std
::
setfill
(
'0'
)
<<
(
tv
.
tv_nsec
/
1000000
);
this
->
setf
(
old_flags
);
return
*
this
;
}
...
...
src/ObjectRepository/UniSetActivator.cc
View file @
053f990d
...
...
@@ -215,7 +215,14 @@ bool gdb_print_trace()
char
pid_buf
[
30
];
sprintf
(
pid_buf
,
"%d"
,
getpid
());
char
name_buf
[
512
];
name_buf
[
readlink
(
"/proc/self/exe"
,
name_buf
,
511
)]
=
0
;
ssize_t
ind
=
readlink
(
"/proc/self/exe"
,
name_buf
,
511
);
if
(
ind
<
0
)
{
perror
(
"Can't readlink..."
);
return
false
;
}
name_buf
[
ind
]
=
0
;
TRACELOG
<<
"stack trace: for "
<<
name_buf
<<
" pid="
<<
pid_buf
<<
endl
;
...
...
src/Processes/IOController.cc
View file @
053f990d
...
...
@@ -624,7 +624,7 @@ IOController::USensorInfo::operator=(IOController_i::SensorIOInfo* r)
// ----------------------------------------------------------------------------------------
void
*
IOController
::
USensorInfo
::
getUserData
(
size_t
index
)
{
if
(
index
>
MaxUserData
)
if
(
index
>
=
MaxUserData
)
return
nullptr
;
uniset
::
uniset_rwmutex_rlock
ulock
(
userdata_lock
);
...
...
@@ -633,7 +633,7 @@ void* IOController::USensorInfo::getUserData( size_t index )
void
IOController
::
USensorInfo
::
setUserData
(
size_t
index
,
void
*
data
)
{
if
(
index
>
MaxUserData
)
if
(
index
>
=
MaxUserData
)
return
;
uniset
::
uniset_rwmutex_wrlock
ulock
(
userdata_lock
);
...
...
src/Processes/IONotifyController.cc
View file @
053f990d
...
...
@@ -175,6 +175,8 @@ void IONotifyController::showStatisticsForConsumer( ostringstream& inf, const st
}
else
{
std
::
ios_base
::
fmtflags
old_flags
=
inf
.
flags
();
inf
<<
std
::
right
;
auto
oind
=
uniset_conf
()
->
oind
;
...
...
@@ -190,6 +192,8 @@ void IONotifyController::showStatisticsForConsumer( ostringstream& inf, const st
<<
" ]"
<<
endl
;
}
inf
.
setf
(
old_flags
);
}
inf
<<
"--------------------------------------------"
<<
endl
;
...
...
src/Various/Configuration.cc
View file @
053f990d
...
...
@@ -139,9 +139,6 @@ namespace uniset
localNodeName
(
""
),
fileConfName
(
xmlfile
)
{
if
(
xmlfile
.
empty
()
)
setConfFileName
();
initConfiguration
(
argc
,
argv
);
}
// ---------------------------------------------------------------------------------
...
...
@@ -158,9 +155,6 @@ namespace uniset
localNodeName
(
""
),
fileConfName
(
fileConf
)
{
if
(
fileConf
.
empty
()
)
setConfFileName
();
oind
=
_oind
;
initConfiguration
(
argc
,
argv
);
}
...
...
@@ -177,9 +171,6 @@ namespace uniset
localNodeName
(
""
),
fileConfName
(
fileConf
)
{
if
(
fileConf
.
empty
()
)
setConfFileName
();
shared_ptr
<
ObjectIndex_Array
>
_oi
=
make_shared
<
ObjectIndex_Array
>
(
omap
);
oind
=
static_pointer_cast
<
ObjectIndex
>
(
_oi
);
...
...
@@ -188,9 +179,6 @@ namespace uniset
// ---------------------------------------------------------------------------------
void
Configuration
::
initConfiguration
(
int
argc
,
const
char
*
const
*
argv
)
{
// PassiveTimer pt(UniSetTimer::WaitUpTime);
ulogsys
<<
"*** configure from file: "
<<
fileConfName
<<
endl
;
// т.к. мы не знаем откуда эти argc и argv и может они будут удалены сразу после завершения функции
// то надёжнее скопировать себе всё..
_argc
=
argc
;
...
...
@@ -201,6 +189,13 @@ namespace uniset
iorfile
=
make_shared
<
IORFile
>
();
// инициализировать надо после argc,argv
if
(
fileConfName
.
empty
()
)
setConfFileName
();
// PassiveTimer pt(UniSetTimer::WaitUpTime);
ulogsys
<<
"*** configure from file: "
<<
fileConfName
<<
endl
;
// -------------------------------------------------------------------------
xmlSensorsSec
=
0
;
xmlObjectsSec
=
0
;
...
...
src/Various/Mutex.cc
View file @
053f990d
...
...
@@ -102,7 +102,15 @@ uniset_rwmutex_wrlock::uniset_rwmutex_wrlock( uniset_rwmutex& _m ):
uniset_rwmutex_wrlock
::~
uniset_rwmutex_wrlock
()
{
m
.
unlock
();
try
{
m
.
unlock
();
}
//catch( Poco::SystemException& ex )
catch
(
std
::
exception
&
ex
)
{
std
::
terminate
();
}
}
// -------------------------------------------------------------------------------------------
uniset_rwmutex_rlock
::
uniset_rwmutex_rlock
(
uniset_rwmutex
&
_m
)
:
...
...
@@ -113,6 +121,13 @@ uniset_rwmutex_rlock::uniset_rwmutex_rlock( uniset_rwmutex& _m ):
uniset_rwmutex_rlock
::~
uniset_rwmutex_rlock
()
{
m
.
unlock
();
try
{
m
.
unlock
();
}
catch
(
std
::
exception
&
ex
)
{
std
::
terminate
();
}
}
// -----------------------------------------------------------------------------
src/Various/SViewer.cc
View file @
053f990d
...
...
@@ -306,8 +306,10 @@ void SViewer::updateThresholds( IONotifyController_i::ThresholdsListSeq_var& tls
void
SViewer
::
printInfo
(
uniset
::
ObjectId
id
,
const
string
&
sname
,
long
value
,
const
string
&
supplier
,
const
string
&
txtname
,
const
string
&
iotype
)
{
std
::
ios_base
::
fmtflags
old_flags
=
cout
.
flags
();
cout
<<
"("
<<
setw
(
5
)
<<
id
<<
")"
<<
" | "
<<
setw
(
2
)
<<
iotype
<<
" | "
<<
setw
(
60
)
<<
sname
<<
" | "
<<
setw
(
5
)
<<
value
<<
"
\t
| "
<<
setw
(
40
)
<<
left
<<
supplier
<<
endl
;
// "\t | " << txtname << endl;
cout
.
setf
(
old_flags
);
}
// ---------------------------------------------------------------------------
tests/develop.cc
View file @
053f990d
...
...
@@ -22,6 +22,7 @@ struct TestClass
{
TestClass
()
{
memset
(
&
data
,
0
,
sizeof
(
data
));
cerr
<<
"TEST CLASS CREATE.."
<<
endl
;
}
...
...
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