OLD | NEW |
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 const int kOneSecondInMicros = 1000000; | 47 const int kOneSecondInMicros = 1000000; |
48 | 48 |
49 // Allow this socket to reuse port even if still in TIME_WAIT. | 49 // Allow this socket to reuse port even if still in TIME_WAIT. |
50 server_->SetReuseAddress(true); | 50 server_->SetReuseAddress(true); |
51 | 51 |
52 // First bind the socket to the requested port. | 52 // First bind the socket to the requested port. |
53 bool bound = false; | 53 bool bound = false; |
54 while (!bound && !terminate_) { | 54 while (!bound && !terminate_) { |
55 bound = server_->Bind(port_); | 55 bound = server_->Bind(port_); |
56 | 56 |
57 // If an error occoured wait a bit before retrying. The most common error | 57 // If an error occurred wait a bit before retrying. The most common error |
58 // would be that the port is already in use so this avoids a busy loop and | 58 // would be that the port is already in use so this avoids a busy loop and |
59 // make the agent take over the port when it becomes free. | 59 // make the agent take over the port when it becomes free. |
60 if (!bound) { | 60 if (!bound) { |
| 61 PrintF("Failed to open socket on port %d, " |
| 62 "waiting %d ms before retrying\n", port_, kOneSecondInMicros / 1000); |
61 terminate_now_->Wait(kOneSecondInMicros); | 63 terminate_now_->Wait(kOneSecondInMicros); |
62 } | 64 } |
63 } | 65 } |
64 | 66 |
65 // Accept connections on the bound port. | 67 // Accept connections on the bound port. |
66 while (!terminate_) { | 68 while (!terminate_) { |
67 bool ok = server_->Listen(1); | 69 bool ok = server_->Listen(1); |
68 listening_->Signal(); | 70 listening_->Signal(); |
69 if (ok) { | 71 if (ok) { |
70 // Accept the new connection. | 72 // Accept the new connection. |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 return total_received; | 418 return total_received; |
417 } | 419 } |
418 total_received += received; | 420 total_received += received; |
419 } | 421 } |
420 return total_received; | 422 return total_received; |
421 } | 423 } |
422 | 424 |
423 } } // namespace v8::internal | 425 } } // namespace v8::internal |
424 | 426 |
425 #endif // ENABLE_DEBUGGER_SUPPORT | 427 #endif // ENABLE_DEBUGGER_SUPPORT |
OLD | NEW |