Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: mojo/public/cpp/bindings/lib/multiplex_router.cc

Issue 2666423002: Assert sequence validity on non-thread-safe RefCount manipulations (2) (Closed)
Patch Set: rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" 5 #include "mojo/public/cpp/bindings/lib/multiplex_router.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 MayAutoLock locker(&lock_); 433 MayAutoLock locker(&lock_);
434 do { 434 do {
435 if (next_interface_id_value_ >= kInterfaceIdNamespaceMask) 435 if (next_interface_id_value_ >= kInterfaceIdNamespaceMask)
436 next_interface_id_value_ = 1; 436 next_interface_id_value_ = 1;
437 id = next_interface_id_value_++; 437 id = next_interface_id_value_++;
438 if (set_interface_id_namespace_bit_) 438 if (set_interface_id_namespace_bit_)
439 id |= kInterfaceIdNamespaceMask; 439 id |= kInterfaceIdNamespaceMask;
440 } while (base::ContainsKey(endpoints_, id)); 440 } while (base::ContainsKey(endpoints_, id));
441 441
442 InterfaceEndpoint* endpoint = new InterfaceEndpoint(this, id); 442 InterfaceEndpoint* endpoint = new InterfaceEndpoint(this, id);
443 endpoint->DisableSequenceConsistencyAssertions();
443 endpoints_[id] = endpoint; 444 endpoints_[id] = endpoint;
444 if (encountered_error_) 445 if (encountered_error_)
445 UpdateEndpointStateMayRemove(endpoint, PEER_ENDPOINT_CLOSED); 446 UpdateEndpointStateMayRemove(endpoint, PEER_ENDPOINT_CLOSED);
446 endpoint->set_handle_created(); 447 endpoint->set_handle_created();
447 } 448 }
448 449
449 if (!NotifyAssociation(&handle_to_send, id)) { 450 if (!NotifyAssociation(&handle_to_send, id)) {
450 // The peer handle of |handle_to_send|, which is supposed to join this 451 // The peer handle of |handle_to_send|, which is supposed to join this
451 // associated group, has been closed. 452 // associated group, has been closed.
452 { 453 {
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 InterfaceId id, 954 InterfaceId id,
954 bool* inserted) { 955 bool* inserted) {
955 AssertLockAcquired(); 956 AssertLockAcquired();
956 // Either |inserted| is nullptr or it points to a boolean initialized as 957 // Either |inserted| is nullptr or it points to a boolean initialized as
957 // false. 958 // false.
958 DCHECK(!inserted || !*inserted); 959 DCHECK(!inserted || !*inserted);
959 960
960 InterfaceEndpoint* endpoint = FindEndpoint(id); 961 InterfaceEndpoint* endpoint = FindEndpoint(id);
961 if (!endpoint) { 962 if (!endpoint) {
962 endpoint = new InterfaceEndpoint(this, id); 963 endpoint = new InterfaceEndpoint(this, id);
964 endpoint->DisableSequenceConsistencyAssertions();
gab 2017/03/24 15:46:45 That seems like a very large hammer, can we use th
yzshen1 2017/03/24 16:58:09 I am the one who suggested that the check should b
963 endpoints_[id] = endpoint; 965 endpoints_[id] = endpoint;
964 if (inserted) 966 if (inserted)
965 *inserted = true; 967 *inserted = true;
966 } 968 }
967 969
968 return endpoint; 970 return endpoint;
969 } 971 }
970 972
971 MultiplexRouter::InterfaceEndpoint* MultiplexRouter::FindEndpoint( 973 MultiplexRouter::InterfaceEndpoint* MultiplexRouter::FindEndpoint(
972 InterfaceId id) { 974 InterfaceId id) {
973 AssertLockAcquired(); 975 AssertLockAcquired();
974 auto iter = endpoints_.find(id); 976 auto iter = endpoints_.find(id);
975 return iter != endpoints_.end() ? iter->second.get() : nullptr; 977 return iter != endpoints_.end() ? iter->second.get() : nullptr;
976 } 978 }
977 979
978 void MultiplexRouter::AssertLockAcquired() { 980 void MultiplexRouter::AssertLockAcquired() {
979 #if DCHECK_IS_ON() 981 #if DCHECK_IS_ON()
980 if (lock_) 982 if (lock_)
981 lock_->AssertAcquired(); 983 lock_->AssertAcquired();
982 #endif 984 #endif
983 } 985 }
984 986
985 } // namespace internal 987 } // namespace internal
986 } // namespace mojo 988 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698