MCPcopy Create free account
hub / github.com/apache/brpc / ShutdownWriter

Function ShutdownWriter

test/brpc_socket_unittest.cpp:1586–1613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1584}
1585
1586void* 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
1615void TestShutdownWrite() {
1616 const size_t REP = 100;

Callers

nothing calls this directly

Calls 4

bthread_id_create2Function · 0.85
bthread_usleepFunction · 0.85
push_backMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected