Merge pull request #12304 from sepalani/pcap-io
BBA/HLE: Fix random PCAP file corruption
This commit is contained in:
commit
feeac104d8
|
@ -49,6 +49,7 @@ void PCAP::AddHeader(u32 link_type)
|
||||||
m_fp->WriteBytes(&hdr, sizeof(hdr));
|
m_fp->WriteBytes(&hdr, sizeof(hdr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Not thread-safe, concurrency between multiple calls to IOFile::WriteBytes.
|
||||||
void PCAP::AddPacket(const u8* bytes, size_t size)
|
void PCAP::AddPacket(const u8* bytes, size_t size)
|
||||||
{
|
{
|
||||||
std::chrono::system_clock::time_point now(std::chrono::system_clock::now());
|
std::chrono::system_clock::time_point now(std::chrono::system_clock::now());
|
||||||
|
|
|
@ -123,6 +123,9 @@ void PCAPSSLCaptureLogger::LogBBA(const void* data, std::size_t length)
|
||||||
{
|
{
|
||||||
if (!Config::Get(Config::MAIN_NETWORK_DUMP_BBA))
|
if (!Config::Get(Config::MAIN_NETWORK_DUMP_BBA))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Concurrency between CEXIETHERNET's RecvHandlePacket and SendFromDirectFIFO
|
||||||
|
const std::lock_guard lock(m_io_mutex);
|
||||||
m_file->AddPacket(static_cast<const u8*>(data), length);
|
m_file->AddPacket(static_cast<const u8*>(data), length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <WinSock2.h>
|
#include <WinSock2.h>
|
||||||
|
@ -111,6 +112,7 @@ private:
|
||||||
const sockaddr_in& to);
|
const sockaddr_in& to);
|
||||||
|
|
||||||
std::unique_ptr<Common::PCAP> m_file;
|
std::unique_ptr<Common::PCAP> m_file;
|
||||||
|
std::mutex m_io_mutex;
|
||||||
std::map<s32, u32> m_read_sequence_number;
|
std::map<s32, u32> m_read_sequence_number;
|
||||||
std::map<s32, u32> m_write_sequence_number;
|
std::map<s32, u32> m_write_sequence_number;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue