diff -ru boost_1_39_0/boost/asio/detail/reactive_socket_service.hpp boost_1_39_0.patched/boost/asio/detail/reactive_socket_service.hpp
old
|
new
|
|
1435 | 1435 | // Accept a new connection. |
1436 | 1436 | template <typename Socket> |
1437 | 1437 | boost::system::error_code accept(implementation_type& impl, |
1438 | | Socket& peer, endpoint_type* peer_endpoint, boost::system::error_code& ec) |
| 1438 | Socket& peer, endpoint_type* peer_endpoint, boost::system::error_code& the_error_code) |
1439 | 1439 | { |
1440 | 1440 | if (!is_open(impl)) |
1441 | 1441 | { |
1442 | | ec = boost::asio::error::bad_descriptor; |
1443 | | return ec; |
| 1442 | the_error_code = boost::asio::error::bad_descriptor; |
| 1443 | return the_error_code; |
1444 | 1444 | } |
1445 | 1445 | |
1446 | 1446 | // We cannot accept a socket that is already open. |
1447 | 1447 | if (peer.is_open()) |
1448 | 1448 | { |
1449 | | ec = boost::asio::error::already_open; |
1450 | | return ec; |
| 1449 | the_error_code = boost::asio::error::already_open; |
| 1450 | return the_error_code; |
1451 | 1451 | } |
1452 | 1452 | |
1453 | 1453 | // Accept a socket. |
1454 | 1454 | for (;;) |
1455 | 1455 | { |
1456 | 1456 | // Try to complete the operation without blocking. |
1457 | | boost::system::error_code ec; |
| 1457 | boost::system::error_code tmp_ec; |
1458 | 1458 | socket_holder new_socket; |
1459 | 1459 | std::size_t addr_len = 0; |
1460 | 1460 | if (peer_endpoint) |
1461 | 1461 | { |
1462 | 1462 | addr_len = peer_endpoint->capacity(); |
1463 | 1463 | new_socket.reset(socket_ops::accept(impl.socket_, |
1464 | | peer_endpoint->data(), &addr_len, ec)); |
| 1464 | peer_endpoint->data(), &addr_len, tmp_ec)); |
1465 | 1465 | } |
1466 | 1466 | else |
1467 | 1467 | { |
1468 | | new_socket.reset(socket_ops::accept(impl.socket_, 0, 0, ec)); |
| 1468 | new_socket.reset(socket_ops::accept(impl.socket_, 0, 0, tmp_ec)); |
1469 | 1469 | } |
1470 | 1470 | |
1471 | 1471 | // Check if operation succeeded. |
… |
… |
|
1473 | 1473 | { |
1474 | 1474 | if (peer_endpoint) |
1475 | 1475 | peer_endpoint->resize(addr_len); |
1476 | | peer.assign(impl.protocol_, new_socket.get(), ec); |
1477 | | if (!ec) |
| 1476 | peer.assign(impl.protocol_, new_socket.get(), tmp_ec); |
| 1477 | if (!tmp_ec) |
1478 | 1478 | new_socket.release(); |
1479 | | return ec; |
| 1479 | return tmp_ec; |
1480 | 1480 | } |
1481 | 1481 | |
1482 | 1482 | // Operation failed. |
1483 | | if (ec == boost::asio::error::would_block |
1484 | | || ec == boost::asio::error::try_again) |
| 1483 | if (tmp_ec == boost::asio::error::would_block |
| 1484 | || tmp_ec == boost::asio::error::try_again) |
1485 | 1485 | { |
1486 | 1486 | if (impl.flags_ & implementation_type::user_set_non_blocking) |
1487 | | return ec; |
| 1487 | return tmp_ec; |
1488 | 1488 | // Fall through to retry operation. |
1489 | 1489 | } |
1490 | | else if (ec == boost::asio::error::connection_aborted) |
| 1490 | else if (tmp_ec == boost::asio::error::connection_aborted) |
1491 | 1491 | { |
1492 | 1492 | if (impl.flags_ & implementation_type::enable_connection_aborted) |
1493 | | return ec; |
| 1493 | return tmp_ec; |
1494 | 1494 | // Fall through to retry operation. |
1495 | 1495 | } |
1496 | 1496 | #if defined(EPROTO) |
1497 | | else if (ec.value() == EPROTO) |
| 1497 | else if (tmp_ec.value() == EPROTO) |
1498 | 1498 | { |
1499 | 1499 | if (impl.flags_ & implementation_type::enable_connection_aborted) |
1500 | | return ec; |
| 1500 | return tmp_ec; |
1501 | 1501 | // Fall through to retry operation. |
1502 | 1502 | } |
1503 | 1503 | #endif // defined(EPROTO) |
1504 | 1504 | else |
1505 | | return ec; |
| 1505 | return tmp_ec; |
1506 | 1506 | |
1507 | 1507 | // Wait for socket to become ready. |
1508 | | if (socket_ops::poll_read(impl.socket_, ec) < 0) |
1509 | | return ec; |
| 1508 | if (socket_ops::poll_read(impl.socket_, tmp_ec) < 0) |
| 1509 | return tmp_ec; |
1510 | 1510 | } |
1511 | 1511 | } |
1512 | 1512 | |