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

Side by Side Diff: net/tools/quic/quic_socket_utils.cc

Issue 1780323002: Correctly handle EINTR during sendmsg in QuicSocketUtils::WritePacket. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@116249386
Patch Set: Created 4 years, 9 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 | 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 "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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698