//关闭quicsocket
QuicCloseSocket(conn);
//跟踪这个函数
int QuicCloseSocket(QuicSocket sock)
{
EntryPtr entry = EntryBase::GetFdManager().Get(sock);
if (!entry || entry->Category() != EntryCategory::Socket) {
DebugPrint(dbg_api, "sock = %d, return = -1, errno = EBADF", sock);
errno = EBADF;
return -1;
}
auto socket = std::dynamic_pointer_cast<QuicSocketEntry>(entry);
socket->Close();
QuicSocketEntry::DeleteQuicSocketEntry(socket);
DebugPrint(dbg_api, "sock = %d, return = 0", sock);
return 0;
}
//CLose()函数
socket->Close();
int QuicSocketEntry::Close()
{
if (socketState_ == QuicSocketState_Closed)
return 0;
std::unique_lock<std::recursive_mutex> lock(mtx_);
if (socketState_ == QuicSocketState_Closed)
return 0;
socketState_ = QuicSocketState_Closed;
connectionVisitor_.CancelNoAckAlarm();
if (udpSocket_)
GetConnectionManager().Delete(*udpSocket_, impl_->connection_id(), Fd());
impl_->CloseConnection("");
ClearWaitingsByClose();
ClearAcceptSocketByClose();
return 0;
}
//流关闭
QuicCloseStream(fd);
跟踪这个函数
int QuicCloseStream(QuicStream stream)
{
auto entry = EntryBase::GetFdManager().Get(stream);
if (!entry || entry->Category() != EntryCategory::Stream) {
DebugPrint(dbg_api, "stream = %d, return = -1, errno = EBADF", stream);
errno = EBADF;
return -1;
}
entry->Close();
auto streamPtr = std::dynamic_pointer_cast<QuicStreamEntry>(entry);
QuicStreamEntry::DeleteQuicStream(streamPtr);
DebugPrint(dbg_api, "stream = %d, return = 0", stream);
return 0;
}
//关闭函数
entry->Close();