Commit graph

17 commits

Author SHA1 Message Date
Taylor Brandstetter
7b69a44c8b Fix ABA problem when iterating epoll events.
Original patch contributed by andrey.semashev@gmail.com.

In PhysicalSocketServer::WaitEpoll(), the loop verifies that the
signalled dispatcher is in dispatchers_ set. It does so by looking up
the dispatcher pointer in the set. This is vulnerable to the ABA
problem because one dispatcher may be removed and destroyed and another
created and added with the same address before epoll reports an event
for the old dispatcher. The same issue exists for other Wait
implementations, if a dispatcher is removed and a new one added with
the same socket handle is the old.

This is avoided by using a 64-bit key for looking up the dispatcher
in the set. The key is set from a running counter which gets incremented
when a dispatcher is added to the set, so even if the same dispatcher
pointer is added, removed and added again, the key value will be
different.

This changes the storage of dispatchers_ from a set to a flat_hash_map,
which uses a bit more memory but has faster lookup (O(1) as opposed to
O(log n)).

Bug: webrtc:11124
Change-Id: I6d206e1a367b58ba971edca9b48af7664384b797
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/181027
Commit-Queue: Taylor <deadbeef@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32019}
2020-08-31 20:26:37 +00:00
Markus Handell
3cb525b378 Rename CriticalSection to RecursiveCriticalSection.
This name change communicates that the recursive critical section
should not be used for new code.
The relevant files are renamed rtc_base/critical_section* ->
rtc_base/deprecated/recursive_critical_section*

Bug: webrtc:11567
Change-Id: I73483a1c5e59c389407a981efbfc2cfe76ccdb43
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/179483
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31754}
2020-07-17 09:19:50 +00:00
Markus Handell
b7c63ab83a PhysicalSocketServer: remove heap-based epoll_event handling.
This change deletes heap-based handling of dynamic number of epoll
events handled per call to epoll, with the assumption
that PSS load is likely not dominated by the epoll syscalls. This
simplifies the logic in the code and removes a heap allocation.

Bug: webrtc:11567
Change-Id: I34fbe1fa8bf0a037bf849a4adac1a0a333c9dd86
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175563
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31358}
2020-05-26 17:41:51 +00:00
Niels Möller
6ee67936bd Reland "Delete unused code to handle posix signals in PhysicalSocketServer"
This is a reland of d2490aef20
Earlier link errors were likely a single trybot with corrupted dep files.

Original change's description:
> Delete unused code to handle posix signals in PhysicalSocketServer
>
> Bug: None
> Change-Id: I3abddef4f1af5499f39a8d3f643c779effe9e01d
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175006
> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> Commit-Queue: Niels Moller <nisse@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31237}

Bug: webrtc:11571
Change-Id: I7ea14f26a2186a9d51a75493b7280fc0ad6b8c77
Tbr: kwiberg@webrtc.org
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175042
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31251}
2020-05-14 09:39:45 +00:00
Niels Möller
611fba4517 Mark construction time members of PhysicalSocketServer as const
Bug: webrtc:11567
Change-Id: I06d48aa1636ce1dc684e6a1f6332366be9df22d0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175007
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31242}
2020-05-13 14:37:35 +00:00
Mirko Bonadei
ff88a64b67 Revert "Delete unused code to handle posix signals in PhysicalSocketServer"
This reverts commit d2490aef20.

Reason for revert: peerconnection_client fails to link.

Original change's description:
> Delete unused code to handle posix signals in PhysicalSocketServer
> 
> Bug: None
> Change-Id: I3abddef4f1af5499f39a8d3f643c779effe9e01d
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175006
> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
> Commit-Queue: Niels Moller <nisse@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#31237}

TBR=kwiberg@webrtc.org,nisse@webrtc.org

Change-Id: Ia5a44b4f1a54f6b444b8c53e64d1a3972d166728
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: None
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175011
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31240}
2020-05-13 13:48:28 +00:00
Niels Möller
d2490aef20 Delete unused code to handle posix signals in PhysicalSocketServer
Bug: None
Change-Id: I3abddef4f1af5499f39a8d3f643c779effe9e01d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175006
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31237}
2020-05-13 12:33:09 +00:00
Mirko Bonadei
f7f6870f1b Mark static const class/struct members as constexpr.
This change fixes declarations that have initial values but are
technically not definitions by marking them constexpr (which counts as a
definition).

Bug: None
Change-Id: Icbecf8d83faffa83b9f7e1ffe4d6ef3a3f0b0c2a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173587
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31073}
2020-04-15 09:30:07 +00:00
mmorrison
25eeda1872 Fix socket not getting registered for epoll events
When epoll is enabled in the PhysicalSocketServer, a socket may
not get registered for its epoll events. If an AsyncSocket is
closed and re-created during one of its signal callbacks, its
old epoll events and new epolls events bitmasks may be the same,
even though the fd has changed. This causes the epoll implementation
to not register the new fd for any events.

Fix this by resetting the saved events bitmask when the socket is
closed. This ensures the new fd, if any, is registered if needed.

Bug: webrtc:11497
Change-Id: Idea499e09aefdf292430d1a774a046f963603b95
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173103
Reviewed-by: Taylor <deadbeef@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31039}
2020-04-09 10:17:47 +00:00
Paulina Hensman
b239a2e357 Remove some more instances of IP logging.
Bug: b/152662380
Change-Id: I1f33f470c4dd5458c2d2598e2f17f6691f72df4a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/172446
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Paulina Hensman <phensman@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30957}
2020-04-01 08:17:47 +00:00
Taylor Brandstetter
ecd6fc84cf Add DSCP support for POSIX platforms.
This CL only includes the necessary changes in PhysicalSocketServer,
and doesn't include the Java or Objective C API.

Note that this is doing exactly the same thing as UDPSocketPosix
in chromium.

BUG=webrtc:5658

Change-Id: I295455eaccba2a83cdd1bc55848f325c310f8d32
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168260
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Qingsi Wang <qingsi@webrtc.org>
Commit-Queue: Taylor <deadbeef@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30478}
2020-02-07 03:25:28 +00:00
Jonas Olsson
b2b2031457 Concatenate string literals at compile time.
This CL was generated by running:
git ls-files | grep ".cc" | xargs perl -i -ne 'BEGIN {undef $/}; s/("[\s\n]*<<[\s\n]*")/" "/g; print;'; git cl format

After that I manually edited modules/audio_processing/gain_controller2.cc to preserve its original
formatting.

This primary benefit of this change is a small reduction in binary size.

Bug: None
Change-Id: I689fa7ba9c717c314bb167e5d592c3c4e0871e29
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/165961
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Jonas Olsson <jonasolsson@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30251}
2020-01-14 14:47:48 +00:00
Mirko Bonadei
108a2f025d Preventively fix missing braces warnings.
This CL fixes warnings that will cause issues with new versions of the
Android NDK.

Bug: None
Change-Id: Icd119efec6039d4861d89401b84f94c8da29a314
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160080
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29851}
2019-11-20 19:38:55 +00:00
Jonas Olsson
a4d873786f Format almost everything.
This CL was generated by running

git ls-files | grep -P "(\.h|\.cc)$" | grep -v 'sdk/' | grep -v 'rtc_base/ssl_' | \
grep -v 'fake_rtc_certificate_generator.h' | grep -v 'modules/audio_device/win/' | \
grep -v 'system_wrappers/source/clock.cc' | grep -v 'rtc_base/trace_event.h' | \
grep -v 'modules/audio_coding/codecs/ilbc/' | grep -v 'screen_capturer_mac.h' | \
grep -v 'spl_inl_mips.h' | grep -v 'data_size_unittest.cc' | grep -v 'timestamp_unittest.cc' \
| xargs clang-format -i ; git cl format

Most of these changes are clang-format grouping and reordering includes
differently.

Bug: webrtc:9340
Change-Id: Ic83ddbc169bfacd21883e381b5181c3dd4fe8a63
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/144051
Commit-Queue: Jonas Olsson <jonasolsson@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28505}
2019-07-08 13:45:15 +00:00
Emilio Cobos Álvarez
6806550d5d Fix build with recent linux kernel.
Recent kernel commit[1] moved a bit the define for this constant. This revealed
a missing include in WebRTC.

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0768e17073dc5

Bug: webrtc:10677
Change-Id: I6ed69d307599d077760ae6ad74be10bfbdd1cac6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/138270
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28108}
2019-05-29 15:04:55 +00:00
Steve Anton
10542f21c8 (4) Rename files to snake_case: update BUILD.gn, include paths, header guards, and DEPS entries
Mechanically generated by running this command:

tools_webrtc/do-renames.sh update all-renames.txt && git cl format

Then manually updating:

tools_webrtc/sanitizers/tsan_suppressions_webrtc.cc

Bug: webrtc:10159
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I54824cd91dada8fc3ee3d098f971bc319d477833
Reviewed-on: https://webrtc-review.googlesource.com/c/115653
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26226}
2019-01-11 17:11:39 +00:00
Steve Anton
1c05765831 (3) Rename files to snake_case: move the files
Mechanically generated with this command:

tools_webrtc/do-rename.sh move all-renames.txt

Bug: webrtc:10159
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I8b05b6eab9b9d18b29c2199bbea239e9add1e690
Reviewed-on: https://webrtc-review.googlesource.com/c/115481
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26225}
2019-01-11 17:05:20 +00:00
Renamed from rtc_base/physicalsocketserver.cc (Browse further)