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

Method CheckConnectedAndKeepWrite

src/brpc/socket.cpp:1537–1564  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1535}
1536
1537void Socket::CheckConnectedAndKeepWrite(int fd, int err, void* data) {
1538 butil::fd_guard sockfd(fd);
1539 WriteRequest* req = static_cast<WriteRequest*>(data);
1540 Socket* s = req->get_socket();
1541 if (NULL == s->_conn) {
1542 CHECK_GE(sockfd, 0);
1543 }
1544 if (err == 0 && s->CheckConnected(sockfd) == 0
1545 && s->ResetFileDescriptor(sockfd) == 0) {
1546 if (s->CreatedByConnect()) {
1547 g_vars->channel_conn << 1;
1548 }
1549 if (s->_app_connect) {
1550 s->_app_connect->StartConnect(req->get_socket(),
1551 AfterAppConnected, req);
1552 } else {
1553 // Successfully created a connection
1554 AfterAppConnected(0, req);
1555 }
1556 // Release this socket for KeepWrite
1557 sockfd.release();
1558 } else {
1559 if (err == 0) {
1560 err = errno ? errno : -1;
1561 }
1562 AfterAppConnected(err, req);
1563 }
1564}
1565
1566inline int SetError(bthread_id_t id_wait, int ec) {
1567 if (id_wait != INVALID_BTHREAD_ID) {

Callers

nothing calls this directly

Calls 5

CheckConnectedMethod · 0.80
ResetFileDescriptorMethod · 0.80
CreatedByConnectMethod · 0.80
StartConnectMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected