| 814 | } |
| 815 | |
| 816 | void Socket::BeforeRecycled() { |
| 817 | const bool create_by_connect = CreatedByConnect(); |
| 818 | if (_app_connect) { |
| 819 | std::shared_ptr<AppConnect> tmp; |
| 820 | _app_connect.swap(tmp); |
| 821 | tmp->StopConnect(this); |
| 822 | } |
| 823 | if (_conn) { |
| 824 | SocketConnection* const saved_conn = _conn; |
| 825 | _conn = NULL; |
| 826 | saved_conn->BeforeRecycle(this); |
| 827 | } |
| 828 | if (_user) { |
| 829 | SocketUser* const saved_user = _user; |
| 830 | _user = NULL; |
| 831 | saved_user->BeforeRecycle(this); |
| 832 | } |
| 833 | SharedPart* sp = _shared_part.exchange(NULL, butil::memory_order_acquire); |
| 834 | if (sp) { |
| 835 | sp->RemoveRefManually(); |
| 836 | } |
| 837 | |
| 838 | // Reset `_io_event' at the end. |
| 839 | BRPC_SCOPE_EXIT { |
| 840 | _io_event.Reset(); |
| 841 | }; |
| 842 | const int prev_fd = _fd.exchange(-1, butil::memory_order_relaxed); |
| 843 | if (ValidFileDescriptor(prev_fd)) { |
| 844 | if (_transport->HasOnEdgeTrigger()) { |
| 845 | _io_event.RemoveConsumer(prev_fd); |
| 846 | } |
| 847 | close(prev_fd); |
| 848 | if (create_by_connect) { |
| 849 | g_vars->channel_conn << -1; |
| 850 | } |
| 851 | } |
| 852 | _transport->Release(); |
| 853 | reset_parsing_context(NULL); |
| 854 | _read_buf.clear(); |
| 855 | |
| 856 | _auth_flag_error.store(0, butil::memory_order_relaxed); |
| 857 | bthread_id_error(_auth_id, 0); |
| 858 | |
| 859 | bthread_id_list_destroy(&_id_wait_list); |
| 860 | |
| 861 | if (_ssl_session) { |
| 862 | SSL_free(_ssl_session); |
| 863 | _ssl_session = NULL; |
| 864 | } |
| 865 | |
| 866 | _ssl_ctx = NULL; |
| 867 | |
| 868 | delete _pipeline_q; |
| 869 | _pipeline_q = NULL; |
| 870 | |
| 871 | delete _auth_context; |
| 872 | _auth_context = NULL; |
| 873 |
no test coverage detected