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

Side by Side Diff: net/socket/socket_libevent.cc

Issue 509133002: Raw SocketDescriptor variant of UnixDomainServerSocket::Accept (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ReleaseSocketDescriptor to UnixDomainClientSocket class Created 6 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/socket/socket_libevent.h" 5 #include "net/socket/socket_libevent.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <netinet/in.h> 8 #include <netinet/in.h>
9 #include <sys/socket.h> 9 #include <sys/socket.h>
10 10
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 if (SetNonBlocking(socket_fd_)) { 99 if (SetNonBlocking(socket_fd_)) {
100 int rv = MapSystemError(errno); 100 int rv = MapSystemError(errno);
101 Close(); 101 Close();
102 return rv; 102 return rv;
103 } 103 }
104 104
105 SetPeerAddress(address); 105 SetPeerAddress(address);
106 return OK; 106 return OK;
107 } 107 }
108 108
109 SocketDescriptor SocketLibevent::ReleaseConnectedSocket() {
110 SocketDescriptor tmp_fd = socket_fd_;
111 socket_fd_ = kInvalidSocket;
112 Close();
113 return tmp_fd;
114 }
115
109 int SocketLibevent::Bind(const SockaddrStorage& address) { 116 int SocketLibevent::Bind(const SockaddrStorage& address) {
110 DCHECK(thread_checker_.CalledOnValidThread()); 117 DCHECK(thread_checker_.CalledOnValidThread());
111 DCHECK_NE(kInvalidSocket, socket_fd_); 118 DCHECK_NE(kInvalidSocket, socket_fd_);
112 119
113 int rv = bind(socket_fd_, address.addr, address.addr_len); 120 int rv = bind(socket_fd_, address.addr, address.addr_len);
114 if (rv < 0) { 121 if (rv < 0) {
115 PLOG(ERROR) << "bind() returned an error, errno=" << errno; 122 PLOG(ERROR) << "bind() returned an error, errno=" << errno;
116 return MapSystemError(errno); 123 return MapSystemError(errno);
117 } 124 }
118 125
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 return; 469 return;
463 470
464 bool ok = write_socket_watcher_.StopWatchingFileDescriptor(); 471 bool ok = write_socket_watcher_.StopWatchingFileDescriptor();
465 DCHECK(ok); 472 DCHECK(ok);
466 write_buf_ = NULL; 473 write_buf_ = NULL;
467 write_buf_len_ = 0; 474 write_buf_len_ = 0;
468 base::ResetAndReturn(&write_callback_).Run(rv); 475 base::ResetAndReturn(&write_callback_).Run(rv);
469 } 476 }
470 477
471 } // namespace net 478 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698