[Log4cplus-devel] [log4cplus:bugs] #318 socket copy operator closes the socket
Logging Framework for C++
Brought to you by:
wilx
From: Václav H. <wi...@us...> - 2017-01-30 20:22:06
|
- **labels**: socket --> socket, v1.2.x - **status**: open --> wont-fix --- ** [bugs:#318] socket copy operator closes the socket** **Status:** wont-fix **Group:** v1.2.x **Labels:** socket v1.2.x **Created:** Sun May 31, 2015 08:14 AM UTC by Alexis Wilke **Last Updated:** Mon Jan 30, 2017 08:21 PM UTC **Owner:** Václav Haisman **Attachments:** - [0002-log4cplus-1.2.0-rc3-socket-copy-operator.patch](https://sourceforge.net/p/log4cplus/bugs/318/attachment/0002-log4cplus-1.2.0-rc3-socket-copy-operator.patch) (262 Bytes; text/x-patch) As I'm working on the simpleserver to make it work properly (especially, so it does not leak all the ClientThread objects--this will be another issue), I noticed that the copy constructor properly transferred a socket, whereas, the copy assignment closes the socket! So if I do this it works as expected: Socket s(rhs); // rhs transferred to s (now rhs is considered closed) Whereas, doing this closes the socket: Socket s; s = rhs; // s is a closed socket (So is rhs) I think that in both cases we should expect the same behavior. There is the function that does it wrong. I suggest to remove the call to the close() function: AbstractSocket& AbstractSocket::operator=(const AbstractSocket& rhs) { if(&rhs != this) { close(); // <-- this should not happen! copy(rhs); } return *this; } I'm attaching a patch. --- Sent from sourceforge.net because log...@li... is subscribed to https://sourceforge.net/p/log4cplus/bugs/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/log4cplus/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |