-
Notifications
You must be signed in to change notification settings - Fork 686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor of RpcapdServerInitializer #1410
Conversation
} | ||
public: | ||
RpcapdServerInitializer(bool activateRemoteDevice, const std::string& ip, uint16_t port) | ||
: m_ProcessHandle(nullptr), m_JobHandle(nullptr) | ||
{ | ||
if (!activateRemoteDevice) | ||
return; | ||
|
||
std::string cmd = "rpcapd\\rpcapd.exe"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can move this line to around L163 (new)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, tho IMO I prefer the variables being initialized in the sequence they are used in the CreateProcess
call.
@seladb I think this is ready for review. |
RpcapdServerInitializer(RpcapdServerInitializer&& other) noexcept | ||
: m_ProcessHandle(other.m_ProcessHandle), m_JobHandle(other.m_JobHandle) | ||
{ | ||
other.m_ProcessHandle = nullptr; | ||
other.m_JobHandle = nullptr; | ||
} | ||
RpcapdServerInitializer& operator=(const RpcapdServerInitializer&) = delete; | ||
RpcapdServerInitializer& operator=(RpcapdServerInitializer&& other) noexcept | ||
{ | ||
killProcessAndCloseHandles(); | ||
m_ProcessHandle = other.m_ProcessHandle; | ||
m_JobHandle = other.m_JobHandle; | ||
other.m_ProcessHandle = nullptr; | ||
other.m_JobHandle = nullptr; | ||
return *this; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need all of these methods? We don't the copy c'tor or the assignment operator anywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the class is not safe to copy, but since it only holds POD members, a copy ctor will be implicitly declared by the compiler if not explicitly deleted. As for the move ctor, @tigercosmos wanted them added as deleted too, but since the class is technically movable, I decided to write them out instead of declaring them deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I have no specific objection. It's a helper class in our test suite so it doesn't have to be perfect 🙂
} | ||
public: | ||
RpcapdServerInitializer(bool activateRemoteDevice, const std::string& ip, uint16_t port) | ||
: m_ProcessHandle(nullptr), m_JobHandle(nullptr) | ||
{ | ||
if (!activateRemoteDevice) | ||
return; | ||
|
||
std::string cmd = "rpcapd\\rpcapd.exe"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I don't remember why I defined this string twice (here and in line 127). Maybe we can use cmd
when we write args
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added 519b35a
This PR refactors the
RpcapdServerInitializer
object and contains the following changes:getHandle
method marked asconst
.RpcapdServerInitializer
.NB: Move constructor can be added at a later date if needed.
ostringstream
in favor of straightstring
allocation withreserve
+append
.