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

Side by Side Diff: base/message_loop_unittest.cc

Issue 2805026: Clang: Do not ignore result of HANDLE_EINTR. (Closed)
Patch Set: '' Created 10 years, 6 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 (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/eintr_wrapper.h" 5 #include "base/eintr_wrapper.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/platform_thread.h" 8 #include "base/platform_thread.h"
9 #include "base/ref_counted.h" 9 #include "base/ref_counted.h"
10 #include "base/task.h" 10 #include "base/task.h"
(...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 base::MessagePumpLibevent::FileDescriptorWatcher controller; 1571 base::MessagePumpLibevent::FileDescriptorWatcher controller;
1572 { 1572 {
1573 MessageLoopForIO message_loop; 1573 MessageLoopForIO message_loop;
1574 1574
1575 QuitDelegate delegate; 1575 QuitDelegate delegate;
1576 message_loop.WatchFileDescriptor(fd, 1576 message_loop.WatchFileDescriptor(fd,
1577 true, MessageLoopForIO::WATCH_WRITE, &controller, &delegate); 1577 true, MessageLoopForIO::WATCH_WRITE, &controller, &delegate);
1578 // and don't run the message loop, just destroy it. 1578 // and don't run the message loop, just destroy it.
1579 } 1579 }
1580 } 1580 }
1581 HANDLE_EINTR(close(pipefds[0])); 1581 if (HANDLE_EINTR(close(pipefds[0])) < 0)
1582 HANDLE_EINTR(close(pipefds[1])); 1582 PLOG(ERROR) << "close";
1583 if (HANDLE_EINTR(close(pipefds[1])) < 0)
1584 PLOG(ERROR) << "close";
1583 } 1585 }
1584 1586
1585 TEST(MessageLoopTest, FileDescriptorWatcherDoubleStop) { 1587 TEST(MessageLoopTest, FileDescriptorWatcherDoubleStop) {
1586 // Verify that it's ok to call StopWatchingFileDescriptor(). 1588 // Verify that it's ok to call StopWatchingFileDescriptor().
1587 // (Errors only showed up in valgrind.) 1589 // (Errors only showed up in valgrind.)
1588 int pipefds[2]; 1590 int pipefds[2];
1589 int err = pipe(pipefds); 1591 int err = pipe(pipefds);
1590 ASSERT_TRUE(err == 0); 1592 ASSERT_TRUE(err == 0);
1591 int fd = pipefds[1]; 1593 int fd = pipefds[1];
1592 { 1594 {
1593 // Arrange for message loop to live longer than controller. 1595 // Arrange for message loop to live longer than controller.
1594 MessageLoopForIO message_loop; 1596 MessageLoopForIO message_loop;
1595 { 1597 {
1596 base::MessagePumpLibevent::FileDescriptorWatcher controller; 1598 base::MessagePumpLibevent::FileDescriptorWatcher controller;
1597 1599
1598 QuitDelegate delegate; 1600 QuitDelegate delegate;
1599 message_loop.WatchFileDescriptor(fd, 1601 message_loop.WatchFileDescriptor(fd,
1600 true, MessageLoopForIO::WATCH_WRITE, &controller, &delegate); 1602 true, MessageLoopForIO::WATCH_WRITE, &controller, &delegate);
1601 controller.StopWatchingFileDescriptor(); 1603 controller.StopWatchingFileDescriptor();
1602 } 1604 }
1603 } 1605 }
1604 HANDLE_EINTR(close(pipefds[0])); 1606 if (HANDLE_EINTR(close(pipefds[0])) < 0)
1605 HANDLE_EINTR(close(pipefds[1])); 1607 PLOG(ERROR) << "close";
1608 if (HANDLE_EINTR(close(pipefds[1])) < 0)
1609 PLOG(ERROR) << "close";
1606 } 1610 }
1607 1611
1608 } // namespace 1612 } // namespace
1609 1613
1610 #endif // defined(OS_POSIX) 1614 #endif // defined(OS_POSIX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698