OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/sync/notifier/base/async_network_alive.h" | 5 #include "chrome/browser/sync/notifier/base/async_network_alive.h" |
6 | 6 |
7 #include <sys/socket.h> | 7 #include <sys/socket.h> |
8 #include <asm/types.h> | 8 #include <asm/types.h> |
9 #include <linux/netlink.h> | 9 #include <linux/netlink.h> |
10 #include <linux/rtnetlink.h> | 10 #include <linux/rtnetlink.h> |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 int result = select(max_fd + 1, &rdfs, NULL, NULL, NULL); | 62 int result = select(max_fd + 1, &rdfs, NULL, NULL, NULL); |
63 | 63 |
64 if (result <= 0) { | 64 if (result <= 0) { |
65 error_ = true; | 65 error_ = true; |
66 PLOG(ERROR) << "select() returned unexpected result " << result; | 66 PLOG(ERROR) << "select() returned unexpected result " << result; |
67 close(fd); | 67 close(fd); |
68 close(exit_pipe_[0]); | 68 close(exit_pipe_[0]); |
69 return; | 69 return; |
70 } | 70 } |
71 | 71 |
72 // Since we recieved a change from the socket, read the change in. | 72 // Since we received a change from the socket, read the change in. |
73 if (FD_ISSET(fd, &rdfs)) { | 73 if (FD_ISSET(fd, &rdfs)) { |
74 char buf[4096]; | 74 char buf[4096]; |
75 struct iovec iov = { buf, sizeof(buf) }; | 75 struct iovec iov = { buf, sizeof(buf) }; |
76 struct sockaddr_nl sa; | 76 struct sockaddr_nl sa; |
77 | 77 |
78 struct msghdr msg = { (void *)&sa, sizeof(sa), &iov, 1, NULL, 0, 0 }; | 78 struct msghdr msg = { (void *)&sa, sizeof(sa), &iov, 1, NULL, 0, 0 }; |
79 recvmsg(fd, &msg, 0); | 79 recvmsg(fd, &msg, 0); |
80 } | 80 } |
81 | 81 |
82 close(fd); | 82 close(fd); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 private: | 115 private: |
116 int exit_pipe_[2]; | 116 int exit_pipe_[2]; |
117 DISALLOW_COPY_AND_ASSIGN(AsyncNetworkAliveLinux); | 117 DISALLOW_COPY_AND_ASSIGN(AsyncNetworkAliveLinux); |
118 }; | 118 }; |
119 | 119 |
120 AsyncNetworkAlive* AsyncNetworkAlive::Create() { | 120 AsyncNetworkAlive* AsyncNetworkAlive::Create() { |
121 return new AsyncNetworkAliveLinux(); | 121 return new AsyncNetworkAliveLinux(); |
122 } | 122 } |
123 | 123 |
124 } // namespace notifier | 124 } // namespace notifier |
OLD | NEW |