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
98b2caf9
Commit
98b2caf9
authored
Sep 05, 2014
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(ULogServer): добавил возможность настраивать timeout-ы для сессий
parent
d2f864c5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
14 deletions
+27
-14
log.cc
Utilities/ULog/log.cc
+1
-1
LogServer.h
include/LogServer.h
+8
-1
LogSession.h
include/LogSession.h
+4
-2
LogServer.cc
src/LogServer/LogServer.cc
+7
-3
LogSession.cc
src/LogServer/LogSession.cc
+7
-7
No files found.
Utilities/ULog/log.cc
View file @
98b2caf9
...
...
@@ -124,7 +124,7 @@ int main( int argc, char **argv )
data
=
(
int
)
Debug
::
value
(
sdata
);
if
(
verb
)
cout
<<
"SEND COMMAND: '"
<<
(
LogServerTypes
::
Command
)
cmd
<<
" data='"
<<
sdata
<<
"'"
<<
endl
;
cout
<<
"SEND COMMAND: '"
<<
(
LogServerTypes
::
Command
)
cmd
<<
" data='"
<<
sdata
<<
"'"
<<
endl
;
}
lr
.
readlogs
(
addr
,
port
,
(
LogServerTypes
::
Command
)
cmd
,
data
,
verb
);
...
...
include/LogServer.h
View file @
98b2caf9
...
...
@@ -17,6 +17,10 @@ class LogServer
LogServer
(
DebugStream
&
log
);
~
LogServer
();
inline
void
setSessionTimeout
(
timeout_t
msec
){
sessTimeout
=
msec
;
}
inline
void
setCmdTimeout
(
timeout_t
msec
){
cmdTimeout
=
msec
;
}
inline
void
setOutTimeout
(
timeout_t
msec
){
outTimeout
=
msec
;
}
void
run
(
const
std
::
string
&
addr
,
ost
::
tpport_t
port
,
bool
thread
=
true
);
protected
:
...
...
@@ -31,7 +35,10 @@ class LogServer
UniSetTypes
::
uniset_rwmutex
mutSList
;
timeout_t
timeout
;
timeout_t
session_timeout
;
timeout_t
sessTimeout
;
timeout_t
cmdTimeout
;
timeout_t
outTimeout
;
std
::
atomic_bool
cancelled
;
DebugStream
mylog
;
ThreadCreator
<
LogServer
>*
thr
;
...
...
include/LogSession.h
View file @
98b2caf9
...
...
@@ -14,7 +14,7 @@ class LogSession:
{
public
:
LogSession
(
ost
::
TCPSocket
&
server
,
DebugStream
*
log
,
timeout_t
timeout
);
LogSession
(
ost
::
TCPSocket
&
server
,
DebugStream
*
log
,
timeout_t
sessTimeout
=
10000
,
timeout_t
cmdTimeout
=
2000
,
timeout_t
outTimeout
=
2000
);
virtual
~
LogSession
();
typedef
sigc
::
slot
<
void
,
LogSession
*>
FinalSlot
;
...
...
@@ -34,7 +34,9 @@ class LogSession:
std
::
string
caddr
;
DebugStream
*
log
;
timeout_t
timeout
;
timeout_t
sessTimeout
;
timeout_t
cmdTimeout
;
timeout_t
outTimeout
;
PassiveTimer
ptSessionTimeout
;
FinalSlot
slFin
;
...
...
src/LogServer/LogServer.cc
View file @
98b2caf9
...
...
@@ -26,7 +26,9 @@ LogServer::~LogServer()
// -------------------------------------------------------------------------
LogServer
::
LogServer
(
DebugStream
&
log
)
:
timeout
(
TIMEOUT_INF
),
session_timeout
(
3600000
),
sessTimeout
(
3600000
),
cmdTimeout
(
2000
),
outTimeout
(
2000
),
cancelled
(
false
),
thr
(
0
),
tcp
(
0
),
...
...
@@ -36,7 +38,9 @@ elog(&log)
// -------------------------------------------------------------------------
LogServer
::
LogServer
()
:
timeout
(
TIMEOUT_INF
),
session_timeout
(
3600000
),
sessTimeout
(
3600000
),
cmdTimeout
(
2000
),
outTimeout
(
2000
),
cancelled
(
false
),
thr
(
0
),
tcp
(
0
),
...
...
@@ -86,7 +90,7 @@ void LogServer::work()
{
while
(
tcp
->
isPendingConnection
(
timeout
)
)
{
LogSession
*
s
=
new
LogSession
(
*
tcp
,
elog
,
sess
ion_t
imeout
);
LogSession
*
s
=
new
LogSession
(
*
tcp
,
elog
,
sess
Timeout
,
cmdTimeout
,
outT
imeout
);
{
uniset_rwmutex_wrlock
l
(
mutSList
);
slist
.
push_back
(
s
);
...
...
src/LogServer/LogSession.cc
View file @
98b2caf9
...
...
@@ -21,12 +21,14 @@ LogSession::~LogSession()
}
}
// -------------------------------------------------------------------------
LogSession
::
LogSession
(
ost
::
TCPSocket
&
server
,
DebugStream
*
_log
,
timeout_t
msec
)
:
LogSession
::
LogSession
(
ost
::
TCPSocket
&
server
,
DebugStream
*
_log
,
timeout_t
_sessTimeout
,
timeout_t
_cmdTimeout
,
timeout_t
_outTimeout
)
:
TCPSession
(
server
),
peername
(
""
),
caddr
(
""
),
log
(
_log
),
timeout
(
msec
),
sessTimeout
(
_sessTimeout
),
cmdTimeout
(
_cmdTimeout
),
outTimeout
(
_outTimeout
),
cancelled
(
false
)
{
// slog.addLevel(Debug::ANY);
...
...
@@ -59,14 +61,12 @@ void LogSession::run()
if
(
slog
.
debugging
(
Debug
::
INFO
)
)
slog
[
Debug
::
INFO
]
<<
peername
<<
"(run): run thread of sessions.."
<<
endl
;
ptSessionTimeout
.
setTiming
(
10000
);
timeout_t
inTimeout
=
2000
;
timeout_t
outTimeout
=
2000
;
ptSessionTimeout
.
setTiming
(
sessTimeout
);
string
oldLogFile
(
log
->
getLogFile
()
);
// Команды могут посылаться только в начале сессии..
if
(
isPending
(
Socket
::
pendingInput
,
in
Timeout
)
)
if
(
isPending
(
Socket
::
pendingInput
,
cmd
Timeout
)
)
{
LogServerTypes
::
lsMessage
msg
;
// проверяем канал..(если данных нет, значит "клиент отвалился"...
...
...
@@ -167,7 +167,7 @@ void LogSession::run()
// -------------------------------------------------------------------------
void
LogSession
::
final
()
{
*
tcp
()
<<
endl
;
tcp
()
->
sync
()
;
slFin
(
this
);
delete
this
;
}
...
...
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