IOCPPASSINDATA 복사 생성자,대입 연산자 추가
This commit is contained in:
@@ -46,6 +46,56 @@ struct IOCPPASSINDATA {
|
||||
#ifdef __linux__
|
||||
std::shared_ptr<std::queue<IOCPPASSINDATA*>> sendQueue;
|
||||
#endif
|
||||
|
||||
IOCPPASSINDATA() {
|
||||
event = IOCPEVENT::QUIT;
|
||||
socket = nullptr;
|
||||
recvbytes = 0;
|
||||
sendbytes = 0;
|
||||
transferredbytes = 0;
|
||||
wsabuf.len = 1500;
|
||||
wsabuf.buf = this->buf;
|
||||
IOCPInstance = nullptr;
|
||||
}
|
||||
IOCPPASSINDATA(const IOCPPASSINDATA& other)
|
||||
: event(other.event),
|
||||
socket(other.socket),
|
||||
transferredbytes(other.transferredbytes),
|
||||
wsabuf(other.wsabuf),
|
||||
IOCPInstance(other.IOCPInstance)
|
||||
#ifdef __linux__
|
||||
, sendQueue(other.sendQueue)
|
||||
#endif
|
||||
{
|
||||
recvbytes = 0;
|
||||
sendbytes = 0;
|
||||
wsabuf.buf = this->buf;
|
||||
// buf는 memcpy로 복사
|
||||
std::memcpy(buf, other.buf, sizeof(buf));
|
||||
// overlapped는 0으로 초기화 (복사하면 안 됨)
|
||||
std::memset(&overlapped, 0, sizeof(overlapped));
|
||||
}
|
||||
|
||||
~IOCPPASSINDATA() = default;
|
||||
|
||||
// 복사 대입 연산자
|
||||
IOCPPASSINDATA& operator=(const IOCPPASSINDATA& other) {
|
||||
if (this != &other) {
|
||||
event = other.event;
|
||||
socket = other.socket;
|
||||
recvbytes = 0;
|
||||
sendbytes = 0;
|
||||
transferredbytes = other.transferredbytes;
|
||||
wsabuf.buf = this->buf;
|
||||
IOCPInstance = other.IOCPInstance;
|
||||
#ifdef __linux__
|
||||
sendQueue = other.sendQueue;
|
||||
#endif
|
||||
std::memcpy(buf, other.buf, sizeof(buf));
|
||||
std::memset(&overlapped, 0, sizeof(overlapped));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
class IOCP {
|
||||
@@ -106,11 +156,7 @@ public:
|
||||
return;
|
||||
}
|
||||
}
|
||||
Chattr::IOCPPASSINDATA* ptr = new Chattr::IOCPPASSINDATA;
|
||||
::memcpy(ptr, rootIocpData, sizeof(IOCPPASSINDATA));
|
||||
::memset(&ptr->overlapped, 0, sizeof(OVERLAPPED));
|
||||
ptr->recvbytes = ptr->sendbytes = 0;
|
||||
ptr->wsabuf.buf = ptr->buf;
|
||||
Chattr::IOCPPASSINDATA* ptr = new Chattr::IOCPPASSINDATA(*rootIocpData);
|
||||
ptr->wsabuf.len = 1500;
|
||||
|
||||
int redSize = 0;
|
||||
|
||||
Reference in New Issue
Block a user