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

Side by Side Diff: mojo/edk/system/message_pipe_dispatcher.cc

Issue 1712773002: Mojo: Don't allow closed pipe handles to be sent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « no previous file | mojo/edk/system/ports/node.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/edk/system/message_pipe_dispatcher.h" 5 #include "mojo/edk/system/message_pipe_dispatcher.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 PlatformHandle* handles) { 480 PlatformHandle* handles) {
481 SerializedState* state = static_cast<SerializedState*>(destination); 481 SerializedState* state = static_cast<SerializedState*>(destination);
482 state->pipe_id = pipe_id_; 482 state->pipe_id = pipe_id_;
483 state->endpoint = static_cast<int8_t>(endpoint_); 483 state->endpoint = static_cast<int8_t>(endpoint_);
484 ports[0] = port_.name(); 484 ports[0] = port_.name();
485 return true; 485 return true;
486 } 486 }
487 487
488 bool MessagePipeDispatcher::BeginTransit() { 488 bool MessagePipeDispatcher::BeginTransit() {
489 base::AutoLock lock(signal_lock_); 489 base::AutoLock lock(signal_lock_);
490 if (in_transit_) 490 if (in_transit_ || port_closed_)
491 return false; 491 return false;
492 in_transit_ = true; 492 in_transit_ = true;
493 return in_transit_; 493 return in_transit_;
494 } 494 }
495 495
496 void MessagePipeDispatcher::CompleteTransitAndClose() { 496 void MessagePipeDispatcher::CompleteTransitAndClose() {
497 node_controller_->SetPortObserver(port_, nullptr); 497 node_controller_->SetPortObserver(port_, nullptr);
498 498
499 base::AutoLock lock(signal_lock_); 499 base::AutoLock lock(signal_lock_);
500 in_transit_ = false; 500 in_transit_ = false;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 DVLOG(1) << "Peer closure detected on message pipe " << pipe_id_ 606 DVLOG(1) << "Peer closure detected on message pipe " << pipe_id_
607 << " endpoint " << endpoint_ << " [port=" << port_.name() << "]"; 607 << " endpoint " << endpoint_ << " [port=" << port_.name() << "]";
608 } 608 }
609 #endif 609 #endif
610 610
611 awakables_.AwakeForStateChange(GetHandleSignalsStateNoLock()); 611 awakables_.AwakeForStateChange(GetHandleSignalsStateNoLock());
612 } 612 }
613 613
614 } // namespace edk 614 } // namespace edk
615 } // namespace mojo 615 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/edk/system/ports/node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698