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

Side by Side Diff: base/message_loop/message_pump_libevent.cc

Issue 2398253004: Reland "Open MessagePumpLibevent's pipe with O_CLOEXEC" (Closed)
Patch Set: More robust NaCl workaround Created 4 years, 2 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 | « base/files/file_util_posix.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/message_loop/message_pump_libevent.h" 5 #include "base/message_loop/message_pump_libevent.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <unistd.h> 8 #include <unistd.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 void MessagePumpLibevent::ScheduleDelayedWork( 283 void MessagePumpLibevent::ScheduleDelayedWork(
284 const TimeTicks& delayed_work_time) { 284 const TimeTicks& delayed_work_time) {
285 // We know that we can't be blocked on Wait right now since this method can 285 // We know that we can't be blocked on Wait right now since this method can
286 // only be called on the same thread as Run, so we only need to update our 286 // only be called on the same thread as Run, so we only need to update our
287 // record of how long to sleep when we do sleep. 287 // record of how long to sleep when we do sleep.
288 delayed_work_time_ = delayed_work_time; 288 delayed_work_time_ = delayed_work_time;
289 } 289 }
290 290
291 bool MessagePumpLibevent::Init() { 291 bool MessagePumpLibevent::Init() {
292 int fds[2]; 292 int fds[2];
293 if (pipe(fds)) { 293 if (!CreateLocalNonBlockingPipe(fds)) {
294 DLOG(ERROR) << "pipe() failed, errno: " << errno; 294 DPLOG(ERROR) << "pipe creation failed";
295 return false;
296 }
297 if (!SetNonBlocking(fds[0])) {
298 DLOG(ERROR) << "SetNonBlocking for pipe fd[0] failed, errno: " << errno;
299 return false;
300 }
301 if (!SetNonBlocking(fds[1])) {
302 DLOG(ERROR) << "SetNonBlocking for pipe fd[1] failed, errno: " << errno;
303 return false; 295 return false;
304 } 296 }
305 wakeup_pipe_out_ = fds[0]; 297 wakeup_pipe_out_ = fds[0];
306 wakeup_pipe_in_ = fds[1]; 298 wakeup_pipe_in_ = fds[1];
307 299
308 wakeup_event_ = new event; 300 wakeup_event_ = new event;
309 event_set(wakeup_event_, wakeup_pipe_out_, EV_READ | EV_PERSIST, 301 event_set(wakeup_event_, wakeup_pipe_out_, EV_READ | EV_PERSIST,
310 OnWakeup, this); 302 OnWakeup, this);
311 event_base_set(event_base_, wakeup_event_); 303 event_base_set(event_base_, wakeup_event_);
312 304
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 // Remove and discard the wakeup byte. 346 // Remove and discard the wakeup byte.
355 char buf; 347 char buf;
356 int nread = HANDLE_EINTR(read(socket, &buf, 1)); 348 int nread = HANDLE_EINTR(read(socket, &buf, 1));
357 DCHECK_EQ(nread, 1); 349 DCHECK_EQ(nread, 1);
358 that->processed_io_events_ = true; 350 that->processed_io_events_ = true;
359 // Tell libevent to break out of inner loop. 351 // Tell libevent to break out of inner loop.
360 event_base_loopbreak(that->event_base_); 352 event_base_loopbreak(that->event_base_);
361 } 353 }
362 354
363 } // namespace base 355 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file_util_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698