Commit Graph

604 Commits

Author SHA1 Message Date
sebastien-guay
a9982e68ba "SocketReactor::addEventHandler" and "SocketReactor::removeEventHandler" must protect the access to "NotifierPtr pNotifier" (#1709)
Those two methods already use FastMutex::ScopedLock lock(_mutex), but
the scope is not large enough to protect "NotifierPtr pNotifier" that is
accessed by calling SocketNotifier::addObserver() and
SocketNotifier::removeObserver().

It is mentioned in SocketReator.h that it is safe to call
addEventHandler() and removeEventHandler() from another thread while the
SocketReactor is running. My current use of the SocketReactor
encountered an issue where the SocketNotifier::_events has been
corrupted by a concurent write access done by
SocketReactor::addEventHandler() and
SocketReactor::removeEventHandler().
The call stack show that the SocketReactor::addEventHandler is stuck in
a while loop in gcc/libstdc++/tree.cc Rb_tree_insert_and_rebalance()

I clearly see in my logs that it happened while my
SocketConnector::unregisterConnector() and
SocketConnector::registerConnector() were called by two different
threads.

#0 0x00a80a7b in std::_Rb_tree_insert_and_rebalance () from
/usr/lib/libstdc++.so.6
#1 0x06ccb430 in std::_Rb_tree<Poco::Net::SocketNotification*,
Poco::Net::SocketNotification*,
std::_IdentityPoco::Net::SocketNotification*,
std::lessPoco::Net::SocketNotification*,
std::allocatorPoco::Net::SocketNotification* >::_M_insert
(this=0xac75dc90, __x=0x0, __p=0xac7ed0c8, __v=@0xb5fb0c40) at
/usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_tree.h:816
#2 0x06ccb15d in std::_Rb_tree<Poco::Net::SocketNotification*,
Poco::Net::SocketNotification*,
std::_IdentityPoco::Net::SocketNotification*,
std::lessPoco::Net::SocketNotification*,
std::allocatorPoco::Net::SocketNotification* >::insert_equal
(this=0xac75dc90, __v=@0xb5fb0c40) at
/usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_tree.h:858
#3 0x06ccad86 in std::multiset<Poco::Net::SocketNotification*,
std::lessPoco::Net::SocketNotification*,
std::allocatorPoco::Net::SocketNotification* >::insert (this=0xac75dc90,
__x=@0xb5fb0c40)
at
/usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_multiset.h:306
#4 0x06cca72b in Poco::Net::SocketNotifier::addObserver
(this=0xac75dc70, pReactor=0x8d27958, observer=@0xb5fb0cd0) at
src/SocketNotifier.cpp:45
#5 0x06cd060f in Poco::Net::SocketReactor::addEventHandler
(this=0x8d27958, socket=@0xac7f5a74, observer=@0xb5fb0cd0) at
src/SocketReactor.cpp:178

SocketReactor::run() is already protecting the access to the
SocketNotifier.
2017-08-10 10:10:09 +02:00
TimTim
5b7d9d2b18 avoid multipart boundary conflict (#1753)
when nesting multipart, descendant parts currently may have the same boundary as the top-level multipart.
2017-08-10 10:07:19 +02:00
micheleselea
5fe775dfc3 SQlite 3.19.3 and Socket::select fix (#1825)
* SQlite 3.19.3

changelog
http://www.sqlite.org/releaselog/3_19_3.html

* epoll_event memset fix

with -std=c++14 the sizeof(eventsIn) give as result the number of array elements not the bytes number, so the memset is wrong

* fix for older gcc

on older version of gcc struct epoll_event eventsOut[epollSize] = { 0 }; does not compile
2017-07-25 14:20:19 +02:00
Yasuhiro Horimoto
fd1d113acb Fix VisualStudio warning C4245 in NetworkInterface.h (#1823) 2017-07-23 21:09:57 +02:00
Matt Tucker
4da941f869 TCPServerDispatcher: fix thread accounting leak (#1801)
* TCPServerDispatcher::run: catch errors in connection creation and handling to prevent threads from exiting without accounting for them
2017-07-10 22:37:11 +02:00
Stefan Weil
8ccee8928c Fix typos in comments, documentation and strings (#1615)
All of them were found using codespell.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2017-07-06 00:17:38 +02:00
Alex Fabijanic
72b826651f src/Var.cpp: 2 * sanity check in wrong place ? #1784 2017-07-03 21:03:50 +02:00
Reg Arvidson
e0b64badfe Fix always true condition, possible out-of-bounds 2017-02-22 13:09:32 -08:00
Guenter Obiltschnig
f453dd145c added Visual Studio 2017 project files 2017-02-20 16:46:44 +01:00
Christopher Baker
2267feb475 Fixed position of scope parameter. Fixes #1552 2017-02-19 23:41:12 -06:00
Guenter Obiltschnig
fe8e4bfc27 fix incorrect auto_ptr usage in testsuite 2017-02-18 07:04:41 +01:00
Guenter Obiltschnig
6ecaa675cc style fixes 2017-02-17 13:43:48 +01:00
Guenter Obiltschnig
5b0df5fcd5 fixed test due to changed URI::encode() behavior 2017-02-17 13:42:50 +01:00
Guenter Obiltschnig
c1b868d642 detect malformed MIME messages earlier 2017-02-12 15:45:17 +01:00
Guenter Obiltschnig
aa803f3657 fixed GH #1570: IPv6AddressImpl::toString() returns wrong output for IPv6 address "::" 2017-02-11 19:02:01 +01:00
Guenter Obiltschnig
3eda8f40bb fix a potential DoS (through memory exhaustion) by restricting HTML form field name and value sizes 2017-01-24 13:15:19 +01:00
Guenter Obiltschnig
11845334dc fix potential DoS vulnerability (through memory exhaustion) by restricting maximum line length 2017-01-24 13:15:12 +01:00
Guenter Obiltschnig
29f259cc24 fix a potential DoS vulnerability by restricting the length of the HTTP chunk size in chunked transfer encoding 2017-01-24 13:15:04 +01:00
Guenter Obiltschnig
a44217d0a2 remove unneeded declaration introduced through cherry-pick 2017-01-12 16:12:20 +01:00
Guenter Obiltschnig
5ac7959b11 fixed GH #1212: Lost WebSocket Frames after Client Websocket Handshake is complete
Conflicts:
	Net/include/Poco/Net/HTTPServerRequestImpl.h
2017-01-12 16:03:52 +01:00
proller
cc2f754d4d Net::HTTPSession: split timeout to connection, recieve, send 2017-01-11 22:00:56 +03:00
theAirC
2a7568c737 Detection of closed websocket connection
When the websocket connection is closed, a non-empty frame (n>0) may be received with FRAME_OP_CLOSE flag bit set.
Tested with chrome 54.0.2840.99 ; after establishing the websocket connection, if the connection is not closed by javascript and the tab is closed, a frame of length n=2 is received with FRAME_OP_CLOSE flag set.
2016-12-08 22:04:15 +02:00
vm2mv
9141f38035 * Net: fixed adding content part to mail message with empty content-disposition 2016-11-22 13:53:27 +01:00
Guenter Obiltschnig
0b0c808408 rename TCPConnectionFilter to TCPServerConnectionFilter; pass a StreamSocket to accept() 2016-11-11 14:30:37 +01:00
Guenter Obiltschnig
fe59f959ef GH #1485: add TCPConnectionFilter 2016-11-11 14:13:04 +01:00
Guenter Obiltschnig
f38a1a38de more Net testsuite fixes 2016-11-09 13:04:40 +01:00
Guenter Obiltschnig
696a9de502 GH #1481, GH #1449: fix broken tests due to changed dns resolution 2016-11-09 12:22:49 +01:00
Xu Yifeng
0ad635c5d4 Add a new bind() and bind6() interface and make REUSEPORT as an option.
SO_REUSEADDR is to reuse a socket in time-wait state, this is often turned on
by server applicationis, but if a port is being used, the server could fail,
this is expected. But with SO_REUSEPORT option, it even can open a port which
is being used, this is a more error prone than SO_REUSEADDR, because we
normally don't want to share a port with irrelevant application without
notice, the behavior should not be default.
2016-11-09 17:05:50 +08:00
Guenter Obiltschnig
5df7f69b08 fixed GH #1472: HTTP(S)StreamFactory should send a User-Agent header 2016-10-26 12:59:33 +02:00
Guenter Obiltschnig
b22501f692 another fix for GH #1458 - handle case when all sockets are invalid 2016-10-18 22:25:01 +02:00
Guenter Obiltschnig
6d373825fa fixed GH #1458: always pass 1 to epoll_create() 2016-10-17 18:33:41 +02:00
Guenter Obiltschnig
8293f93f7a use std::unique_ptr instead of std::auto_ptr with C++11 or newer compilers to avoid std::auto_ptr deprecation warnings 2016-10-14 12:01:25 +02:00
Guenter Obiltschnig
6195c97a86 make port constructor explicit; no longer prefer IPv4 addresses over IPv6 addresses 2016-10-10 18:44:55 +02:00
Guenter Obiltschnig
92a0f0f0aa improved EchoServer error handling 2016-10-07 22:04:10 +02:00
Guenter Obiltschnig
835d0365d9 fixed bad disconnect handling in onSocketReadable 2016-10-07 22:03:58 +02:00
Scott Davis
48862bf08e Use stable_sort to preserve order of IP addresses from DNS 2016-10-04 14:43:01 -04:00
Guenter Obiltschnig
eabae863bb fixed uninitialized member in ctor 2016-09-26 19:21:07 +02:00
Guenter Obiltschnig
34b9b1284c fixed uninitialized _encoding member 2016-09-26 19:18:56 +02:00
Guenter Obiltschnig
b1004587b2 code cleanup; fixed some issues reported by Klocwork 2016-09-26 19:18:28 +02:00
Guenter Obiltschnig
ae3c4a4ba3 fixed some warnings and minor issues detected by clang-analyzer
Conflicts:
	Data/src/RecordSet.cpp
2016-09-13 11:40:59 +02:00
Guenter Obiltschnig
20c7392c21 giving up on strerror_r 2016-09-08 10:10:39 +02:00
Guenter Obiltschnig
28ff1f2530 fixed strerror_r issue 2016-09-08 09:36:28 +02:00
Guenter Obiltschnig
d074e5e6ea fixed warnings with GCC on Linux 2016-09-06 16:30:59 +02:00
Günter Obiltschnig
7491374264 Revert "GH #1050 Net: fix gcc -Wshadow warnings" 2016-09-05 08:35:17 +02:00
Günter Obiltschnig
81b140e0a9 Revert "GH #1050 NetSSL_OpenSSL: fix gcc -Wshadow warnings" 2016-09-05 08:31:43 +02:00
Günter Obiltschnig
34bbbe256d Revert "GH #1050 Net tests: fix gcc -Wshadow warnings" 2016-09-05 08:25:44 +02:00
Guenter Obiltschnig
aed776b7ae added additional HTTP status codes 2016-08-02 22:57:26 +08:00
Guenter Obiltschnig
bfc2ee99a0 Proper fix for #1337 2016-08-02 13:00:20 +08:00
Guenter Obiltschnig
7c32d02f61 fixed GH #1316: Empty SocketReactor never sleeps 2016-07-18 18:55:49 +02:00
Miklos Vajna
c298c4f689 GH #1050 Net tests: fix gcc -Wshadow warnings 2016-05-16 21:39:58 +02:00