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

Function FailedWriter

test/brpc_socket_unittest.cpp:447–471  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

445};
446
447void* FailedWriter(void* void_arg) {
448 WriterArg* arg = static_cast<WriterArg*>(void_arg);
449 brpc::SocketUniquePtr sock;
450 if (brpc::Socket::Address(arg->socket_id, &sock) < 0) {
451 printf("Fail to address SocketId=%" PRIu64 "\n", arg->socket_id);
452 return NULL;
453 }
454 char buf[32];
455 for (size_t i = 0; i < arg->times; ++i) {
456 bthread_id_t id;
457 EXPECT_EQ(0, bthread_id_create(&id, NULL, NULL));
458 snprintf(buf, sizeof(buf), "%0" BAIDU_SYMBOLSTR(NUMBER_WIDTH) "lu",
459 i + arg->offset);
460 butil::IOBuf src;
461 src.append(buf);
462 brpc::Socket::WriteOptions wopt;
463 wopt.id_wait = id;
464 sock->Write(&src, &wopt);
465 EXPECT_EQ(0, bthread_id_join(id));
466 // Only the first connect can see ECONNREFUSED and then
467 // calls `SetFailed' making others' error_code=EINVAL
468 //EXPECT_EQ(ECONNREFUSED, error_code);
469 }
470 return NULL;
471}
472
473TEST_F(SocketTest, fail_to_connect) {
474 const size_t REP = 10;

Callers

nothing calls this directly

Calls 5

bthread_id_createFunction · 0.85
snprintfFunction · 0.85
bthread_id_joinFunction · 0.85
appendMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected