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
c82b9bb1
Commit
c82b9bb1
authored
Nov 02, 2011
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(unet2): Сделал "сброс таймера" через mutex, т.к.
ведётся работа из разных потоков. Добавил дополнительные информационные логи..
parent
73ff04a1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
6 deletions
+30
-6
UNetExchange.cc
extensions/UNet2/UNetExchange.cc
+4
-1
UNetReceiver.cc
extensions/UNet2/UNetReceiver.cc
+22
-3
UNetReceiver.h
extensions/UNet2/UNetReceiver.h
+2
-1
UNetSender.cc
extensions/UNet2/UNetSender.cc
+2
-1
No files found.
extensions/UNet2/UNetExchange.cc
View file @
c82b9bb1
...
...
@@ -206,6 +206,9 @@ sender2(0)
throw
SystemError
(
err
.
str
());
}
}
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): (node='"
<<
n
<<
"') add receiver "
<<
h2
<<
":"
<<
p2
<<
endl
;
UNetReceiver
*
r
=
new
UNetReceiver
(
h
,
p
,
shm
);
// на всякий принудительно разблокируем,
...
...
@@ -227,7 +230,7 @@ sender2(0)
{
if
(
!
h2
.
empty
()
)
// создаём читателя впо второму каналу
{
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init): add reserv receiver "
dlog
[
Debug
::
INFO
]
<<
myname
<<
"(init):
(node='"
<<
n
<<
"')
add reserv receiver "
<<
h2
<<
":"
<<
p2
<<
endl
;
r2
=
new
UNetReceiver
(
h2
,
p2
,
shm
);
...
...
extensions/UNet2/UNetReceiver.cc
View file @
c82b9bb1
#include <sstream>
#include <iomanip>
#include "Exceptions.h"
#include "Extensions.h"
#include "UNetReceiver.h"
...
...
@@ -44,7 +45,7 @@ a_cache_init_ok(false)
{
{
ostringstream
s
;
s
<<
"R("
<<
s
_host
<<
":"
<<
port
<<
")"
;
s
<<
"R("
<<
s
etw
(
15
)
<<
s_host
<<
":"
<<
setw
(
4
)
<<
port
<<
")"
;
myname
=
s
.
str
();
}
...
...
@@ -135,6 +136,13 @@ void UNetReceiver::setLockUpdate( bool st )
lockUpdate
=
st
;
}
// -----------------------------------------------------------------------------
void
UNetReceiver
::
resetTimeout
()
{
uniset_mutex_lock
l
(
tmMutex
,
200
);
ptRecvTimeout
.
reset
();
trTimeout
.
change
(
false
);
}
// -----------------------------------------------------------------------------
void
UNetReceiver
::
start
()
{
if
(
!
activated
)
...
...
@@ -356,12 +364,16 @@ void UNetReceiver::receive()
{
dlog
[
Debug
::
INFO
]
<<
myname
<<
": ******************* receive start"
<<
endl
;
ptRecvTimeout
.
setTiming
(
recvTimeout
);
bool
tout
=
false
;
while
(
activated
)
{
try
{
if
(
recv
()
)
{
uniset_mutex_lock
l
(
tmMutex
,
100
);
ptRecvTimeout
.
reset
();
}
}
catch
(
UniSetTypes
::
Exception
&
ex
)
{
...
...
@@ -376,9 +388,16 @@ void UNetReceiver::receive()
dlog
[
Debug
::
WARN
]
<<
myname
<<
"(receive): catch ..."
<<
std
::
endl
;
}
if
(
trTimeout
.
change
(
ptRecvTimeout
.
checkTime
())
)
// делаем через промежуточную переменную
// чтобы поскорее освободить mutex
{
uniset_mutex_lock
l
(
tmMutex
,
100
);
tout
=
ptRecvTimeout
.
checkTime
();
}
if
(
trTimeout
.
change
(
tout
)
)
{
if
(
ptRecvTimeout
.
checkTime
()
)
if
(
tout
)
slEvent
(
this
,
evTimeout
);
else
slEvent
(
this
,
evOK
);
...
...
extensions/UNet2/UNetReceiver.h
View file @
c82b9bb1
...
...
@@ -64,7 +64,7 @@ class UNetReceiver
// блокировать сохранение данный в SM
void
setLockUpdate
(
bool
st
);
inline
void
resetTimeout
(){
ptRecvTimeout
.
reset
();
trTimeout
.
change
(
false
);
}
void
resetTimeout
();
inline
bool
isRecvOK
(){
return
ptRecvTimeout
.
checkTime
();
}
inline
unsigned
long
getLostPacketsNum
(){
return
lostPackets
;
}
...
...
@@ -162,6 +162,7 @@ class UNetReceiver
EventSlot
slEvent
;
Trigger
trTimeout
;
UniSetTypes
::
uniset_mutex
tmMutex
;
struct
ItemInfo
{
...
...
extensions/UNet2/UNetSender.cc
View file @
c82b9bb1
#include <sstream>
#include <iomanip>
#include "Exceptions.h"
#include "Extensions.h"
#include "UNetSender.h"
...
...
@@ -23,7 +24,7 @@ s_thr(0)
{
ostringstream
s
;
s
<<
"S("
<<
s
_host
<<
":"
<<
port
<<
")"
;
s
<<
"S("
<<
s
etw
(
15
)
<<
s_host
<<
":"
<<
setw
(
4
)
<<
port
<<
")"
;
myname
=
s
.
str
();
}
...
...
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