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
921bf412
Commit
921bf412
authored
Aug 12, 2017
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(UniSetActivator): небольшая правка механизма завершения
parent
b596a688
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
104 deletions
+51
-104
UniSetActivator.h
include/UniSetActivator.h
+2
-10
UniSetActivator.cc
src/ObjectRepository/UniSetActivator.cc
+49
-94
No files found.
include/UniSetActivator.h
View file @
921bf412
...
@@ -66,7 +66,6 @@ namespace uniset
...
@@ -66,7 +66,6 @@ namespace uniset
public
:
public
:
static
UniSetActivatorPtr
Instance
();
static
UniSetActivatorPtr
Instance
();
void
Destroy
();
std
::
shared_ptr
<
UniSetActivator
>
get_aptr
();
std
::
shared_ptr
<
UniSetActivator
>
get_aptr
();
// ------------------------------------
// ------------------------------------
...
@@ -84,15 +83,8 @@ namespace uniset
...
@@ -84,15 +83,8 @@ namespace uniset
typedef
sigc
::
signal
<
void
,
int
>
TerminateEvent_Signal
;
typedef
sigc
::
signal
<
void
,
int
>
TerminateEvent_Signal
;
TerminateEvent_Signal
signal_terminate_event
();
TerminateEvent_Signal
signal_terminate_event
();
inline
bool
noUseGdbForStackTrace
()
const
bool
noUseGdbForStackTrace
()
const
;
{
const
std
::
string
getAbortScript
()
const
;
return
_noUseGdbForStackTrace
;
}
inline
const
std
::
string
getAbortScript
()
{
return
abortScript
;
}
#ifndef DISABLE_REST_API
#ifndef DISABLE_REST_API
// Поддрежка REST API (IHttpRequestRegistry)
// Поддрежка REST API (IHttpRequestRegistry)
...
...
src/ObjectRepository/UniSetActivator.cc
View file @
921bf412
...
@@ -296,15 +296,32 @@ static void on_stacktrace_timeout()
...
@@ -296,15 +296,32 @@ static void on_stacktrace_timeout()
ulogsys
<<
"****** STACK TRACE guard thread finish ******"
<<
endl
<<
flush
;
ulogsys
<<
"****** STACK TRACE guard thread finish ******"
<<
endl
<<
flush
;
}
}
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
static
void
start_terminate_process
()
{
// посылаем сигнал потоку завершения, чтобы проснулся и начал заверешение
{
std
::
unique_lock
<
std
::
mutex
>
lk
(
g_termmutex
);
if
(
g_term
)
return
;
g_term
=
true
;
}
g_termevent
.
notify_all
();
}
// ------------------------------------------------------------------------------------------
static
void
wait_done
()
{
std
::
unique_lock
<
std
::
mutex
>
lk
(
g_donemutex
);
while
(
!
g_done
)
g_doneevent
.
wait
(
lk
,
[]()
{
return
(
g_done
==
true
);
}
);
}
// ------------------------------------------------------------------------------------------
static
void
activator_terminate
(
int
signo
)
static
void
activator_terminate
(
int
signo
)
{
{
if
(
g_term
)
if
(
g_term
)
return
;
return
;
ulogsys
<<
"****** TERMINATE SIGNAL="
<<
signo
<<
endl
<<
flush
;
g_signo
=
signo
;
g_term
=
true
;
if
(
signo
==
SIGABRT
)
if
(
signo
==
SIGABRT
)
{
{
if
(
g_act
&&
!
g_act
->
noUseGdbForStackTrace
()
)
if
(
g_act
&&
!
g_act
->
noUseGdbForStackTrace
()
)
...
@@ -314,11 +331,14 @@ static void activator_terminate( int signo )
...
@@ -314,11 +331,14 @@ static void activator_terminate( int signo )
}
}
else
else
printStackTrace
();
printStackTrace
();
// exit(EXIT_FAILURE);
// return;
}
}
// else
// exit(EXIT_SUCCESS);
ulogsys
<<
"****** TERMINATE NOTIFY...(signo="
<<
signo
<<
")"
<<
endl
<<
flush
;
start_terminate_process
();
g_signo
=
signo
;
g_termevent
.
notify_one
();
}
}
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
static
void
activator_terminate_with_calltrace
(
int
signo
)
static
void
activator_terminate_with_calltrace
(
int
signo
)
...
@@ -338,7 +358,7 @@ static void activator_terminate_with_calltrace( int signo )
...
@@ -338,7 +358,7 @@ static void activator_terminate_with_calltrace( int signo )
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
void
finished_thread
()
void
finished_thread
()
{
{
ulogsys
<<
"******
FINISHED
START **** "
<<
endl
<<
flush
;
ulogsys
<<
"******
WAIT FINISH
START **** "
<<
endl
<<
flush
;
std
::
unique_lock
<
std
::
mutex
>
lk
(
g_finimutex
);
std
::
unique_lock
<
std
::
mutex
>
lk
(
g_finimutex
);
if
(
g_finished
)
if
(
g_finished
)
...
@@ -351,7 +371,7 @@ void finished_thread()
...
@@ -351,7 +371,7 @@ void finished_thread()
{
{
return
(
g_work_stopped
==
true
);
return
(
g_work_stopped
==
true
);
}
);
}
);
ulogsys
<<
"******
FINISHED END
****"
<<
endl
<<
flush
;
ulogsys
<<
"******
WAIT FINISH END("
<<
g_work_stopped
<<
")
****"
<<
endl
<<
flush
;
}
}
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
void
on_finish_timeout
()
void
on_finish_timeout
()
...
@@ -368,11 +388,11 @@ void on_finish_timeout()
...
@@ -368,11 +388,11 @@ void on_finish_timeout()
if
(
!
g_done
)
if
(
!
g_done
)
{
{
ulogsys
<<
"
****** KILL TIMEOUT..
*******"
<<
endl
<<
flush
;
ulogsys
<<
"
(KILL THREAD): WAIT TIMEOUT..KILL
*******"
<<
endl
<<
flush
;
raise
(
SIGKILL
);
raise
(
SIGKILL
);
}
}
ulogsys
<<
"
KILL THREAD
: ..bye.."
<<
endl
;
ulogsys
<<
"
(KILL THREAD)
: ..bye.."
<<
endl
;
}
}
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
namespace
uniset
namespace
uniset
...
@@ -475,7 +495,7 @@ namespace uniset
...
@@ -475,7 +495,7 @@ namespace uniset
}
}
}
}
g_act
.
reset
()
;
g_act
=
nullptr
;
UniSetActivator
::
set_signals
(
false
);
UniSetActivator
::
set_signals
(
false
);
}
}
...
@@ -505,11 +525,6 @@ UniSetActivatorPtr UniSetActivator::Instance()
...
@@ -505,11 +525,6 @@ UniSetActivatorPtr UniSetActivator::Instance()
}
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
void
UniSetActivator
::
Destroy
()
{
inst
.
reset
();
}
// ---------------------------------------------------------------------------
std
::
shared_ptr
<
UniSetActivator
>
UniSetActivator
::
get_aptr
()
std
::
shared_ptr
<
UniSetActivator
>
UniSetActivator
::
get_aptr
()
{
{
return
std
::
dynamic_pointer_cast
<
UniSetActivator
>
(
get_ptr
());
return
std
::
dynamic_pointer_cast
<
UniSetActivator
>
(
get_ptr
());
...
@@ -565,35 +580,12 @@ void UniSetActivator::init()
...
@@ -565,35 +580,12 @@ void UniSetActivator::init()
}
}
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
UniSetActivator
::~
UniSetActivator
()
UniSetActivator
::~
UniSetActivator
()
{
{
if
(
!
g_term
&&
orbthr
)
{
{
std
::
unique_lock
<
std
::
mutex
>
locker
(
g_termmutex
);
g_term
=
true
;
}
g_signo
=
0
;
g_termevent
.
notify_one
();
ulogsys
<<
myname
<<
"(~UniSetActivator): wait done.."
<<
endl
;
#if 1
// if( g_term_thread->joinable() )
// g_term_thread->join();
#else
std
::
unique_lock
<
std
::
mutex
>
locker
(
g_donemutex
);
while
(
!
g_done
)
g_doneevent
.
wait
(
locker
);
#endif
ulogsys
<<
myname
<<
"(~UniSetActivator): wait done OK."
<<
endl
;
}
}
}
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
void
UniSetActivator
::
uaDestroy
(
int
signo
)
void
UniSetActivator
::
uaDestroy
(
int
signo
)
{
{
if
(
omDestroy
||
!
g_act
)
if
(
omDestroy
||
!
g_act
)
return
;
return
;
...
@@ -783,13 +775,7 @@ void UniSetActivator::work()
...
@@ -783,13 +775,7 @@ void UniSetActivator::work()
g_finievent
.
notify_one
();
g_finievent
.
notify_one
();
if
(
orbthr
)
if
(
orbthr
)
{
wait_done
();
// HACK: почему-то мы должны тут застрять,
// иначе "где-то" возникает "гонка" с потоком завершения
// и мы получаем SIGABRT уже на самом завершении
// (помоему как-то связано с завершением потоков)
msleep
(
THREAD_TERMINATE_PAUSE
);
// pause();
}
}
}
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
CORBA
::
ORB_ptr
UniSetActivator
::
getORB
()
CORBA
::
ORB_ptr
UniSetActivator
::
getORB
()
...
@@ -882,6 +868,16 @@ UniSetActivator::TerminateEvent_Signal UniSetActivator::signal_terminate_event()
...
@@ -882,6 +868,16 @@ UniSetActivator::TerminateEvent_Signal UniSetActivator::signal_terminate_event()
return
s_term
;
return
s_term
;
}
}
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
bool
UniSetActivator
::
noUseGdbForStackTrace
()
const
{
return
_noUseGdbForStackTrace
;
}
// ------------------------------------------------------------------------------------------
const
string
UniSetActivator
::
getAbortScript
()
const
{
return
abortScript
;
}
// ------------------------------------------------------------------------------------------
#ifndef DISABLE_REST_API
#ifndef DISABLE_REST_API
Poco
::
JSON
::
Object
::
Ptr
UniSetActivator
::
httpGetByName
(
const
string
&
name
,
const
Poco
::
URI
::
QueryParameters
&
p
)
Poco
::
JSON
::
Object
::
Ptr
UniSetActivator
::
httpGetByName
(
const
string
&
name
,
const
Poco
::
URI
::
QueryParameters
&
p
)
{
{
...
@@ -986,21 +982,10 @@ void UniSetActivator::normalexit()
...
@@ -986,21 +982,10 @@ void UniSetActivator::normalexit()
if
(
!
g_act
)
if
(
!
g_act
)
return
;
return
;
ulogsys
<<
g_act
->
getName
()
<<
"(default exit): ..begin..."
<<
endl
<<
flush
;
ulogsys
<<
g_act
->
getName
()
<<
"(exit): ..begin..."
<<
endl
<<
flush
;
start_terminate_process
();
if
(
!
g_term
)
{
// прежде чем вызывать notify_one(), мы должны освободить mutex!
{
std
::
unique_lock
<
std
::
mutex
>
locker
(
g_termmutex
);
g_term
=
true
;
g_signo
=
0
;
}
ulogsys
<<
"(default exit): notify terminate.."
<<
endl
<<
flush
;
g_termevent
.
notify_one
();
}
ulogsys
<<
"(
default
exit): wait done.."
<<
endl
<<
flush
;
ulogsys
<<
"(exit): wait done.."
<<
endl
<<
flush
;
#if 1
#if 1
if
(
g_term_thread
&&
g_term_thread
->
joinable
()
)
if
(
g_term_thread
&&
g_term_thread
->
joinable
()
)
...
@@ -1018,7 +1003,7 @@ void UniSetActivator::normalexit()
...
@@ -1018,7 +1003,7 @@ void UniSetActivator::normalexit()
#endif
#endif
ulogsys
<<
"(
default
exit): wait done OK (good bye)"
<<
endl
<<
flush
;
ulogsys
<<
"(exit): wait done OK (good bye)"
<<
endl
<<
flush
;
}
}
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
void
UniSetActivator
::
normalterminate
()
void
UniSetActivator
::
normalterminate
()
...
@@ -1027,37 +1012,7 @@ void UniSetActivator::normalterminate()
...
@@ -1027,37 +1012,7 @@ void UniSetActivator::normalterminate()
return
;
return
;
ulogsys
<<
g_act
->
getName
()
<<
"(default terminate): ..begin..."
<<
endl
<<
flush
;
ulogsys
<<
g_act
->
getName
()
<<
"(default terminate): ..begin..."
<<
endl
<<
flush
;
normalexit
();
if
(
!
g_term
)
{
// прежде чем вызывать notify_one(), мы должны освободить mutex!
{
std
::
unique_lock
<
std
::
mutex
>
locker
(
g_termmutex
);
g_term
=
true
;
g_signo
=
0
;
}
ulogsys
<<
"(default terminate): notify terminate.."
<<
endl
<<
flush
;
g_termevent
.
notify_one
();
}
ulogsys
<<
"(default terminate): wait done.."
<<
endl
<<
flush
;
#if 1
if
(
g_term_thread
&&
g_term_thread
->
joinable
()
)
g_term_thread
->
join
();
#else
if
(
g_doneevent
)
{
std
::
unique_lock
<
std
::
mutex
>
locker
(
g_donemutex
);
while
(
!
g_done
)
g_doneevent
.
wait
(
locker
);
}
#endif
ulogsys
<<
"(default terminate): wait done OK (good bye)"
<<
endl
<<
flush
;
}
}
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
void
UniSetActivator
::
term
(
int
signo
)
void
UniSetActivator
::
term
(
int
signo
)
...
...
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