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
29b8b3a1
Commit
29b8b3a1
authored
May 09, 2018
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
thread safe processing for errno
parent
2e6eb5e1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
8 deletions
+21
-8
LogDB.cc
extensions/LogDB/LogDB.cc
+8
-4
ModbusTCPSession.cc
src/Communications/Modbus/ModbusTCPSession.cc
+3
-2
LogSession.cc
src/Log/LogSession.cc
+10
-2
No files found.
extensions/LogDB/LogDB.cc
View file @
29b8b3a1
...
...
@@ -710,9 +710,10 @@ void LogDB::Log::write( ev::io& io )
if
(
ret
<
0
)
{
dbwarn
<<
peername
<<
"(write): write to socket error("
<<
errno
<<
"): "
<<
strerror
(
errno
)
<<
endl
;
int
errnum
=
errno
;
dbwarn
<<
peername
<<
"(write): write to socket error("
<<
errnum
<<
"): "
<<
strerror
(
errnum
)
<<
endl
;
if
(
errn
o
==
EPIPE
||
errno
==
EBADF
)
if
(
errn
um
==
EPIPE
||
errnum
==
EBADF
)
{
dbwarn
<<
peername
<<
"(write): write error.. terminate session.."
<<
endl
;
io
.
set
(
EV_NONE
);
...
...
@@ -816,6 +817,7 @@ void LogDB::handleRequest( Poco::Net::HTTPServerRequest& req, Poco::Net::HTTPSer
uri
.
getPathSegments
(
seg
);
// проверка подключения к страничке со списком websocket-ов
// http://[xxxx:port]/logdb/ws/
if
(
seg
.
size
()
>
1
&&
seg
[
0
]
==
"logdb"
&&
seg
[
1
]
==
"ws"
)
{
// подключение..
...
...
@@ -1398,10 +1400,12 @@ void LogDB::LogWebSocket::write()
if
(
ret
<
0
)
{
int
errnum
=
errno
;
dblog3
<<
"(websocket): "
<<
req
->
clientAddress
().
toString
()
<<
" write to socket error("
<<
errn
o
<<
"): "
<<
strerror
(
errno
)
<<
endl
;
<<
" write to socket error("
<<
errn
um
<<
"): "
<<
strerror
(
errnum
)
<<
endl
;
if
(
errn
o
==
EPIPE
||
errno
==
EBADF
)
if
(
errn
um
==
EPIPE
||
errnum
==
EBADF
)
{
dblog3
<<
"(websocket): "
<<
req
->
clientAddress
().
toString
()
...
...
src/Communications/Modbus/ModbusTCPSession.cc
View file @
29b8b3a1
...
...
@@ -307,8 +307,9 @@ namespace uniset
if
(
res
<
0
)
{
if
(
errno
!=
EAGAIN
&&
dlog
->
is_warn
()
)
dlog
->
warn
()
<<
peername
<<
"(getNextData): read from socket error("
<<
errno
<<
"): "
<<
strerror
(
errno
)
<<
endl
;
int
errnum
=
errno
;
if
(
errnum
!=
EAGAIN
&&
dlog
->
is_warn
()
)
dlog
->
warn
()
<<
peername
<<
"(getNextData): read from socket error("
<<
errnum
<<
"): "
<<
strerror
(
errnum
)
<<
endl
;
return
0
;
}
...
...
src/Log/LogSession.cc
View file @
29b8b3a1
...
...
@@ -301,10 +301,18 @@ namespace uniset
if
(
ret
<
0
)
{
// копируем, а потом проверяем
// хоть POSIX говорит о том, что errno thread-local
// но почему-то словил, что errno (по крайней мере для EPIPE "broken pipe")
// в лог выводилось, а в if( ... ) уже не ловилось
// возможно связано с тем, что ввод/вывод "прерываемая" операция при многопоточности
int
errnum
=
errno
;
// можно было бы конечно убрать вывод лога в else, после проверки в if
if
(
mylog
.
is_warn
()
)
mylog
.
warn
()
<<
peername
<<
"(LogSession::writeEvent): write to socket error("
<<
errn
o
<<
"): "
<<
strerror
(
errno
)
<<
endl
;
mylog
.
warn
()
<<
peername
<<
"(LogSession::writeEvent): write to socket error("
<<
errn
um
<<
"): "
<<
strerror
(
errnum
)
<<
endl
;
if
(
errn
o
==
EPIPE
||
errno
==
EBADF
)
if
(
errn
um
==
EPIPE
||
errnum
==
EBADF
)
{
if
(
mylog
.
is_warn
()
)
mylog
.
warn
()
<<
peername
<<
"(LogSession::writeEvent): write error.. terminate session.."
<<
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