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

Side by Side Diff: net/udp/udp_socket_libevent.cc

Issue 914853002: Add CHECK() in UdpSocketLibevent to debug crbug.com/452121 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 | « net/udp/udp_socket_libevent.h ('k') | net/udp/udp_socket_win.h » ('j') | 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/udp/udp_socket_libevent.h" 5 #include "net/udp/udp_socket_libevent.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <netdb.h> 9 #include <netdb.h>
10 #include <net/if.h> 10 #include <net/if.h>
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 if (socket_ == kInvalidSocket) 98 if (socket_ == kInvalidSocket)
99 return MapSystemError(errno); 99 return MapSystemError(errno);
100 if (SetNonBlocking(socket_)) { 100 if (SetNonBlocking(socket_)) {
101 const int err = MapSystemError(errno); 101 const int err = MapSystemError(errno);
102 Close(); 102 Close();
103 return err; 103 return err;
104 } 104 }
105 return OK; 105 return OK;
106 } 106 }
107 107
108 void UDPSocketLibevent::Close() { 108 int UDPSocketLibevent::Close() {
109 DCHECK(CalledOnValidThread()); 109 DCHECK(CalledOnValidThread());
110 110
111 if (socket_ == kInvalidSocket) 111 if (socket_ == kInvalidSocket)
112 return; 112 return OK;
113 113
114 // Zero out any pending read/write callback state. 114 // Zero out any pending read/write callback state.
115 read_buf_ = NULL; 115 read_buf_ = NULL;
116 read_buf_len_ = 0; 116 read_buf_len_ = 0;
117 read_callback_.Reset(); 117 read_callback_.Reset();
118 recv_from_address_ = NULL; 118 recv_from_address_ = NULL;
119 write_buf_ = NULL; 119 write_buf_ = NULL;
120 write_buf_len_ = 0; 120 write_buf_len_ = 0;
121 write_callback_.Reset(); 121 write_callback_.Reset();
122 send_to_address_.reset(); 122 send_to_address_.reset();
123 123
124 bool ok = read_socket_watcher_.StopWatchingFileDescriptor(); 124 bool ok = read_socket_watcher_.StopWatchingFileDescriptor();
125 DCHECK(ok); 125 DCHECK(ok);
126 ok = write_socket_watcher_.StopWatchingFileDescriptor(); 126 ok = write_socket_watcher_.StopWatchingFileDescriptor();
127 DCHECK(ok); 127 DCHECK(ok);
128 128
129 if (IGNORE_EINTR(close(socket_)) < 0) 129 int result = OK;
130 if (IGNORE_EINTR(close(socket_)) < 0) {
130 PLOG(ERROR) << "close"; 131 PLOG(ERROR) << "close";
132 result = MapSystemError(errno);
133 }
131 134
132 socket_ = kInvalidSocket; 135 socket_ = kInvalidSocket;
133 addr_family_ = 0; 136 addr_family_ = 0;
134 is_connected_ = false; 137 is_connected_ = false;
138
139 return result;
135 } 140 }
136 141
137 int UDPSocketLibevent::GetPeerAddress(IPEndPoint* address) const { 142 int UDPSocketLibevent::GetPeerAddress(IPEndPoint* address) const {
138 DCHECK(CalledOnValidThread()); 143 DCHECK(CalledOnValidThread());
139 DCHECK(address); 144 DCHECK(address);
140 if (!is_connected()) 145 if (!is_connected())
141 return ERR_SOCKET_NOT_CONNECTED; 146 return ERR_SOCKET_NOT_CONNECTED;
142 147
143 if (!remote_address_.get()) { 148 if (!remote_address_.get()) {
144 SockaddrStorage storage; 149 SockaddrStorage storage;
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 return MapSystemError(errno); 749 return MapSystemError(errno);
745 750
746 return OK; 751 return OK;
747 } 752 }
748 753
749 void UDPSocketLibevent::DetachFromThread() { 754 void UDPSocketLibevent::DetachFromThread() {
750 base::NonThreadSafe::DetachFromThread(); 755 base::NonThreadSafe::DetachFromThread();
751 } 756 }
752 757
753 } // namespace net 758 } // namespace net
OLDNEW
« no previous file with comments | « net/udp/udp_socket_libevent.h ('k') | net/udp/udp_socket_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698