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
a20dcb5f
Commit
a20dcb5f
authored
Sep 09, 2014
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(LogServer): решение проблеммы с закрытием соединения на стороне сервера
parent
7e0f414b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
23 deletions
+28
-23
LogReader.cc
src/Log/LogReader.cc
+3
-6
LogServer.cc
src/Log/LogServer.cc
+18
-11
LogServerTypes.cc
src/Log/LogServerTypes.cc
+0
-0
LogSession.cc
src/Log/LogSession.cc
+7
-6
No files found.
src/Log/LogReader.cc
View file @
a20dcb5f
...
...
@@ -20,10 +20,7 @@ cmdonly(false)
LogReader
::~
LogReader
()
{
if
(
isConnection
()
)
{
(
*
tcp
)
<<
endl
;
disconnect
();
}
}
// -------------------------------------------------------------------------
void
LogReader
::
connect
(
const
std
::
string
&
addr
,
ost
::
tpport_t
_port
,
timeout_t
msec
)
...
...
@@ -155,8 +152,11 @@ void LogReader::readlogs( const std::string& _addr, ost::tpport_t _port, LogServ
rlog
.
warn
()
<<
"**** SEND COMMAND ('"
<<
msg
.
cmd
<<
"' FAILED!"
<<
endl
;
if
(
cmdonly
)
{
disconnect
();
return
;
}
}
while
(
!
cmdonly
&&
tcp
->
isPending
(
ost
::
Socket
::
pendingInput
,
inTimeout
)
)
{
...
...
@@ -177,9 +177,6 @@ void LogReader::readlogs( const std::string& _addr, ost::tpport_t _port, LogServ
}
if
(
isConnection
()
)
{
(
*
tcp
)
<<
endl
;
disconnect
();
}
}
// -------------------------------------------------------------------------
src/Log/LogServer.cc
View file @
a20dcb5f
...
...
@@ -10,18 +10,24 @@ using namespace UniSetTypes;
LogServer
::~
LogServer
()
{
cancelled
=
true
;
if
(
thr
)
{
thr
->
stop
();
if
(
thr
->
isRunning
()
)
thr
->
join
();
delete
thr
;
}
{
uniset_rwmutex_wrlock
l
(
mutSList
);
//
uniset_rwmutex_wrlock l(mutSList);
for
(
auto
&
i
:
slist
)
{
if
(
i
->
isRunning
()
)
delete
i
;
}
if
(
thr
)
{
thr
->
stop
();
delete
thr
;
}
delete
tcp
;
}
// -------------------------------------------------------------------------
LogServer
::
LogServer
(
std
::
ostream
&
os
)
:
...
...
@@ -102,7 +108,7 @@ void LogServer::work()
{
try
{
while
(
tcp
->
isPendingConnection
(
timeout
)
)
while
(
!
cancelled
&&
tcp
->
isPendingConnection
(
timeout
)
)
{
LogSession
*
s
=
new
LogSession
(
*
tcp
,
elog
,
sessTimeout
,
cmdTimeout
,
outTimeout
);
{
...
...
@@ -129,10 +135,12 @@ void LogServer::work()
}
}
cerr
<<
"*** LOG SERVER THREAD STOPPED.."
<<
endl
;
{
uniset_rwmutex_wrlock
l
(
mutSList
);
for
(
SessionList
::
iterator
i
=
slist
.
begin
();
i
!=
slist
.
end
();
++
i
)
(
*
i
)
->
disconnect
();
//
uniset_rwmutex_wrlock l(mutSList);
for
(
auto
&
i
:
slist
)
i
->
disconnect
();
}
}
// -------------------------------------------------------------------------
...
...
@@ -143,7 +151,6 @@ void LogServer::sessionFinished( LogSession* s )
{
if
(
(
*
i
)
==
s
)
{
// cerr << "session '" << s->getClientAddress() << "' closed.." << endl;
slist
.
erase
(
i
);
return
;
}
...
...
src/Log/LogServerTypes.cc
View file @
a20dcb5f
src/Log/LogSession.cc
View file @
a20dcb5f
...
...
@@ -68,6 +68,9 @@ void LogSession::run()
string
oldLogFile
(
log
->
getLogFile
()
);
setKeepAlive
(
true
);
// setTimeout(sessTimeout);
// Команды могут посылаться только в начале сессии..
if
(
isPending
(
Socket
::
pendingInput
,
cmdTimeout
)
)
{
...
...
@@ -142,7 +145,7 @@ void LogSession::run()
}
cancelled
=
false
;
while
(
!
cancelled
&&
!
ptSessionTimeout
.
checkTime
()
)
while
(
!
cancelled
&&
isConnected
()
)
// !ptSessionTimeout.checkTime(
)
{
// проверка только ради проверки "целостности" соединения
if
(
isPending
(
Socket
::
pendingInput
,
10
)
)
...
...
@@ -155,11 +158,9 @@ void LogSession::run()
if
(
isPending
(
Socket
::
pendingOutput
,
outTimeout
)
)
{
//
slog.warn
() << peername << "(run): send.." << endl;
ptSessionTimeout
.
reset
();
//
slog.info
() << peername << "(run): send.." << endl;
//
ptSessionTimeout.reset();
if
(
log
)
{
// чтобы не застревать на посылке в сеть..
// делаем через промежуточный буффер (stringstream)
ostringstream
sbuf
;
...
...
@@ -177,6 +178,7 @@ void LogSession::run()
send
=
true
;
}
}
if
(
send
)
{
*
tcp
()
<<
sbuf
.
str
();
...
...
@@ -187,7 +189,6 @@ void LogSession::run()
sleep
(
delayTime
);
}
}
}
if
(
slog
.
debugging
(
Debug
::
INFO
)
)
slog
[
Debug
::
INFO
]
<<
peername
<<
"(run): stop thread of sessions..disconnect.."
<<
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