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

Side by Side Diff: src/debug-agent.cc

Issue 50050: Allow the debugger agent to reuse ports stuck in TIME_WAIT for listening (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | test/cctest/test-debug.cc » ('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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 26 matching lines...) Expand all
37 void DebuggerAgentMessageHandler(const uint16_t* message, int length, 37 void DebuggerAgentMessageHandler(const uint16_t* message, int length,
38 void *data) { 38 void *data) {
39 reinterpret_cast<DebuggerAgent*>(data)->DebuggerMessage(message, length); 39 reinterpret_cast<DebuggerAgent*>(data)->DebuggerMessage(message, length);
40 } 40 }
41 41
42 42
43 // Debugger agent main thread. 43 // Debugger agent main thread.
44 void DebuggerAgent::Run() { 44 void DebuggerAgent::Run() {
45 const int kOneSecondInMicros = 1000000; 45 const int kOneSecondInMicros = 1000000;
46 46
47 // Allow this socket to reuse port even if still in TIME_WAIT.
48 server_->SetReuseAddress(true);
49
47 // First bind the socket to the requested port. 50 // First bind the socket to the requested port.
48 bool bound = false; 51 bool bound = false;
49 while (!bound && !terminate_) { 52 while (!bound && !terminate_) {
50 bound = server_->Bind(port_); 53 bound = server_->Bind(port_);
51 54
52 // If an error occoured wait a bit before retrying. The most common error 55 // If an error occoured wait a bit before retrying. The most common error
53 // would be that the port is already in use so this avoids a busy loop and 56 // would be that the port is already in use so this avoids a busy loop and
54 // make the agent take over the port when it becomes free. 57 // make the agent take over the port when it becomes free.
55 if (!bound) { 58 if (!bound) {
56 terminate_now_->Wait(kOneSecondInMicros); 59 terminate_now_->Wait(kOneSecondInMicros);
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 if (received <= 0) { 350 if (received <= 0) {
348 return total_received; 351 return total_received;
349 } 352 }
350 total_received += received; 353 total_received += received;
351 } 354 }
352 return total_received; 355 return total_received;
353 } 356 }
354 357
355 358
356 } } // namespace v8::internal 359 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698