| 1584 | } |
| 1585 | |
| 1586 | void* ShutdownWriter(void* void_arg) { |
| 1587 | auto arg = static_cast<ShutdownWriterArg*>(void_arg); |
| 1588 | brpc::SocketUniquePtr sock; |
| 1589 | if (brpc::Socket::Address(arg->socket_id, &sock) < 0) { |
| 1590 | LOG(INFO) << "Fail to address SocketId=" << arg->socket_id; |
| 1591 | return NULL; |
| 1592 | } |
| 1593 | for (size_t c = 0; c < arg->times; ++c) { |
| 1594 | bthread_id_t write_id; |
| 1595 | EXPECT_EQ(0, bthread_id_create2(&write_id, arg, |
| 1596 | HandleSocketShutdownWrite)); |
| 1597 | brpc::Socket::WriteOptions wopt; |
| 1598 | wopt.id_wait = write_id; |
| 1599 | wopt.notify_on_success = true; |
| 1600 | wopt.shutdown_write = true; |
| 1601 | butil::IOBuf src; |
| 1602 | src.push_back('a'); |
| 1603 | if (sock->Write(&src, &wopt) != 0) { |
| 1604 | if (errno == brpc::EOVERCROWDED) { |
| 1605 | // The buf is full, sleep a while and retry. |
| 1606 | bthread_usleep(1000); |
| 1607 | --c; |
| 1608 | continue; |
| 1609 | } |
| 1610 | } |
| 1611 | } |
| 1612 | return NULL; |
| 1613 | } |
| 1614 | |
| 1615 | void TestShutdownWrite() { |
| 1616 | const size_t REP = 100; |
nothing calls this directly
no test coverage detected