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
d0fe3b0b
Commit
d0fe3b0b
authored
May 31, 2017
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(libev): рефакторинг работы с ev::timer,
исправил ошибку в CommonEventLoop
parent
b42665ff
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
20 additions
and
10 deletions
+20
-10
logserver.cc
Utilities/ULog/logserver.cc
+11
-1
libuniset2.spec
conf/libuniset2.spec
+3
-0
ModbusTCPServer.cc
src/Communications/Modbus/ModbusTCPServer.cc
+0
-2
ModbusTCPSession.cc
src/Communications/Modbus/ModbusTCPSession.cc
+2
-1
LogSession.cc
src/Log/LogSession.cc
+3
-6
CommonEventLoop.cc
src/Processes/CommonEventLoop.cc
+1
-0
No files found.
Utilities/ULog/logserver.cc
View file @
d0fe3b0b
...
@@ -19,6 +19,7 @@ static struct option longopts[] =
...
@@ -19,6 +19,7 @@ static struct option longopts[] =
{
"verbose"
,
no_argument
,
0
,
'v'
},
{
"verbose"
,
no_argument
,
0
,
'v'
},
{
"delay"
,
required_argument
,
0
,
'd'
},
{
"delay"
,
required_argument
,
0
,
'd'
},
{
"max-sessions"
,
required_argument
,
0
,
'm'
},
{
"max-sessions"
,
required_argument
,
0
,
'm'
},
{
"silent"
,
no_argument
,
0
,
's'
},
{
NULL
,
0
,
0
,
0
}
{
NULL
,
0
,
0
,
0
}
};
};
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
...
@@ -31,6 +32,7 @@ static void print_help()
...
@@ -31,6 +32,7 @@ static void print_help()
printf
(
"[-p|--port] port - Bind port.
\n
"
);
printf
(
"[-p|--port] port - Bind port.
\n
"
);
printf
(
"[-d|--delay] msec - Delay for generate message. Default 5000.
\n
"
);
printf
(
"[-d|--delay] msec - Delay for generate message. Default 5000.
\n
"
);
printf
(
"[-m|--max-sessions] num - Maximum count sessions for server. Default: 5
\n
"
);
printf
(
"[-m|--max-sessions] num - Maximum count sessions for server. Default: 5
\n
"
);
printf
(
"[-s|--silent] - Silent mode. Not write logs..
\n
"
);
}
}
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
...
@@ -45,12 +47,13 @@ int main( int argc, char** argv )
...
@@ -45,12 +47,13 @@ int main( int argc, char** argv )
//int tout = 2000;
//int tout = 2000;
timeout_t
delay
=
5000
;
timeout_t
delay
=
5000
;
int
msess
=
5
;
int
msess
=
5
;
bool
silent
=
false
;
try
try
{
{
while
(
1
)
while
(
1
)
{
{
opt
=
getopt_long
(
argc
,
argv
,
"hvi:p:d:m:"
,
longopts
,
&
optindex
);
opt
=
getopt_long
(
argc
,
argv
,
"hvi:p:d:m:
s
"
,
longopts
,
&
optindex
);
if
(
opt
==
-
1
)
if
(
opt
==
-
1
)
break
;
break
;
...
@@ -81,6 +84,10 @@ int main( int argc, char** argv )
...
@@ -81,6 +84,10 @@ int main( int argc, char** argv )
verb
=
1
;
verb
=
1
;
break
;
break
;
case
's'
:
silent
=
true
;
break
;
case
'?'
:
case
'?'
:
default:
default:
printf
(
"? argumnet
\n
"
);
printf
(
"? argumnet
\n
"
);
...
@@ -192,6 +199,8 @@ int main( int argc, char** argv )
...
@@ -192,6 +199,8 @@ int main( int argc, char** argv )
while
(
true
)
while
(
true
)
// for( int n=0; n<2; n++ )
// for( int n=0; n<2; n++ )
{
{
if
(
!
silent
)
{
dlog
->
any
()
<<
"["
<<
++
i
<<
"] Test message for log"
<<
endl
;
dlog
->
any
()
<<
"["
<<
++
i
<<
"] Test message for log"
<<
endl
;
dlog
->
info
()
<<
": dlog : INFO message"
<<
endl
;
dlog
->
info
()
<<
": dlog : INFO message"
<<
endl
;
dlog
->
warn
()
<<
": dlog : WARN message"
<<
endl
;
dlog
->
warn
()
<<
": dlog : WARN message"
<<
endl
;
...
@@ -208,6 +217,7 @@ int main( int argc, char** argv )
...
@@ -208,6 +217,7 @@ int main( int argc, char** argv )
dlog4
->
info
()
<<
": dlog4: INFO message"
<<
endl
;
dlog4
->
info
()
<<
": dlog4: INFO message"
<<
endl
;
dlog4
->
warn
()
<<
": dlog4: WARN message"
<<
endl
;
dlog4
->
warn
()
<<
": dlog4: WARN message"
<<
endl
;
dlog4
->
crit
()
<<
": dlog4: CRIT message"
<<
endl
;
dlog4
->
crit
()
<<
": dlog4: CRIT message"
<<
endl
;
}
msleep
(
delay
);
msleep
(
delay
);
}
}
...
...
conf/libuniset2.spec
View file @
d0fe3b0b
...
@@ -511,6 +511,9 @@ rm -f %buildroot%_libdir/*.la
...
@@ -511,6 +511,9 @@ rm -f %buildroot%_libdir/*.la
* Tue Sep 12 2017 Alexei Takaseev <taf@altlinux.org> 2.6-alt19.1
* Tue Sep 12 2017 Alexei Takaseev <taf@altlinux.org> 2.6-alt19.1
- Rebuild with poco 1.7.9
- Rebuild with poco 1.7.9
# * Wed May 31 2017 Pavel Vainerman <pv@altlinux.ru> 2.6-alt25
# - test build (devel)
# * Wed May 31 2017 Pavel Vainerman <pv@altlinux.ru> 2.6-alt24
# * Wed May 31 2017 Pavel Vainerman <pv@altlinux.ru> 2.6-alt24
# - minor release
# - minor release
...
...
src/Communications/Modbus/ModbusTCPServer.cc
View file @
d0fe3b0b
...
@@ -312,8 +312,6 @@ namespace uniset
...
@@ -312,8 +312,6 @@ namespace uniset
if
(
dlog
->
is_crit
()
)
if
(
dlog
->
is_crit
()
)
dlog
->
crit
()
<<
myname
<<
"(onTimer): "
<<
ex
.
what
()
<<
endl
;
dlog
->
crit
()
<<
myname
<<
"(onTimer): "
<<
ex
.
what
()
<<
endl
;
}
}
t
.
start
(
tmTime
);
// restart timer
}
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
...
...
src/Communications/Modbus/ModbusTCPSession.cc
View file @
d0fe3b0b
...
@@ -163,11 +163,12 @@ namespace uniset
...
@@ -163,11 +163,12 @@ namespace uniset
ioTimeout
.
start
(
sessTimeout
);
// restart timer..
ioTimeout
.
start
(
sessTimeout
);
// restart timer..
}
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
void
ModbusTCPSession
::
onTimeout
(
ev
::
timer
&
watcher
,
int
revents
)
void
ModbusTCPSession
::
onTimeout
(
ev
::
timer
&
t
,
int
revents
)
{
{
if
(
dlog
->
is_info
()
)
if
(
dlog
->
is_info
()
)
dlog
->
info
()
<<
peername
<<
": timeout connection activity..(terminate session)"
<<
endl
;
dlog
->
info
()
<<
peername
<<
": timeout connection activity..(terminate session)"
<<
endl
;
t
.
stop
();
terminate
();
terminate
();
}
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
...
...
src/Log/LogSession.cc
View file @
d0fe3b0b
...
@@ -568,7 +568,7 @@ namespace uniset
...
@@ -568,7 +568,7 @@ namespace uniset
}
}
}
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
void
LogSession
::
onCmdTimeout
(
ev
::
timer
&
watcher
,
int
revents
)
noexcept
void
LogSession
::
onCmdTimeout
(
ev
::
timer
&
t
,
int
revents
)
noexcept
{
{
if
(
EV_ERROR
&
revents
)
if
(
EV_ERROR
&
revents
)
{
{
...
@@ -578,11 +578,12 @@ namespace uniset
...
@@ -578,11 +578,12 @@ namespace uniset
return
;
return
;
}
}
t
.
stop
();
io
.
set
(
ev
::
WRITE
);
io
.
set
(
ev
::
WRITE
);
asyncEvent
.
start
();
asyncEvent
.
start
();
}
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
void
LogSession
::
onCheckConnectionTimer
(
ev
::
timer
&
watcher
,
int
revents
)
noexcept
void
LogSession
::
onCheckConnectionTimer
(
ev
::
timer
&
t
,
int
revents
)
noexcept
{
{
if
(
EV_ERROR
&
revents
)
if
(
EV_ERROR
&
revents
)
{
{
...
@@ -595,10 +596,7 @@ namespace uniset
...
@@ -595,10 +596,7 @@ namespace uniset
std
::
unique_lock
<
std
::
mutex
>
lk
(
logbuf_mutex
);
std
::
unique_lock
<
std
::
mutex
>
lk
(
logbuf_mutex
);
if
(
!
logbuf
.
empty
()
)
if
(
!
logbuf
.
empty
()
)
{
checkConnectionTimer
.
start
(
checkConnectionTime
);
// restart timer
return
;
return
;
}
// если клиент уже отвалился.. то при попытке write.. сессия будет закрыта.
// если клиент уже отвалился.. то при попытке write.. сессия будет закрыта.
...
@@ -612,7 +610,6 @@ namespace uniset
...
@@ -612,7 +610,6 @@ namespace uniset
catch
(...)
{}
catch
(...)
{}
io
.
set
(
ev
::
WRITE
);
io
.
set
(
ev
::
WRITE
);
checkConnectionTimer
.
start
(
checkConnectionTime
);
// restart timer
}
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
void
LogSession
::
final
()
noexcept
void
LogSession
::
final
()
noexcept
...
...
src/Processes/CommonEventLoop.cc
View file @
d0fe3b0b
...
@@ -277,6 +277,7 @@ namespace uniset
...
@@ -277,6 +277,7 @@ namespace uniset
evterm
.
stop
();
evterm
.
stop
();
evprep
.
stop
();
evprep
.
stop
();
evruntimer
.
stop
();
term_notify
=
true
;
term_notify
=
true
;
term_event
.
notify_all
();
term_event
.
notify_all
();
...
...
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