| 1535 | } |
| 1536 | |
| 1537 | void 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 | |
| 1566 | inline int SetError(bthread_id_t id_wait, int ec) { |
| 1567 | if (id_wait != INVALID_BTHREAD_ID) { |
nothing calls this directly
no test coverage detected