| OLD | NEW |
| 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 "net/tools/quic/quic_socket_utils.h" | 5 #include "net/tools/quic/quic_socket_utils.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <netinet/in.h> | 8 #include <netinet/in.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 hdr.msg_control = 0; | 206 hdr.msg_control = 0; |
| 207 hdr.msg_controllen = 0; | 207 hdr.msg_controllen = 0; |
| 208 } else { | 208 } else { |
| 209 hdr.msg_control = cbuf; | 209 hdr.msg_control = cbuf; |
| 210 hdr.msg_controllen = kSpaceForIp; | 210 hdr.msg_controllen = kSpaceForIp; |
| 211 cmsghdr* cmsg = CMSG_FIRSTHDR(&hdr); | 211 cmsghdr* cmsg = CMSG_FIRSTHDR(&hdr); |
| 212 SetIpInfoInCmsg(self_address, cmsg); | 212 SetIpInfoInCmsg(self_address, cmsg); |
| 213 hdr.msg_controllen = cmsg->cmsg_len; | 213 hdr.msg_controllen = cmsg->cmsg_len; |
| 214 } | 214 } |
| 215 | 215 |
| 216 int rc = sendmsg(fd, &hdr, 0); | 216 int rc; |
| 217 do { |
| 218 rc = sendmsg(fd, &hdr, 0); |
| 219 } while (rc < 0 && errno == EINTR); |
| 217 if (rc >= 0) { | 220 if (rc >= 0) { |
| 218 return WriteResult(WRITE_STATUS_OK, rc); | 221 return WriteResult(WRITE_STATUS_OK, rc); |
| 219 } | 222 } |
| 220 return WriteResult((errno == EAGAIN || errno == EWOULDBLOCK) | 223 return WriteResult((errno == EAGAIN || errno == EWOULDBLOCK) |
| 221 ? WRITE_STATUS_BLOCKED | 224 ? WRITE_STATUS_BLOCKED |
| 222 : WRITE_STATUS_ERROR, | 225 : WRITE_STATUS_ERROR, |
| 223 errno); | 226 errno); |
| 224 } | 227 } |
| 225 | 228 |
| 226 // static | 229 // static |
| (...skipping 25 matching lines...) Expand all Loading... |
| 252 | 255 |
| 253 rc = QuicSocketUtils::SetGetAddressInfo(fd, address_family); | 256 rc = QuicSocketUtils::SetGetAddressInfo(fd, address_family); |
| 254 if (rc < 0) { | 257 if (rc < 0) { |
| 255 LOG(ERROR) << "IP detection not supported" << strerror(errno); | 258 LOG(ERROR) << "IP detection not supported" << strerror(errno); |
| 256 return -1; | 259 return -1; |
| 257 } | 260 } |
| 258 return fd; | 261 return fd; |
| 259 } | 262 } |
| 260 | 263 |
| 261 } // namespace net | 264 } // namespace net |
| OLD | NEW |