[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/kdepim-3.5.5+/kpilot/lib
From:       Jason vanRijn Kasper <vR () movingparts ! net>
Date:       2007-03-07 13:23:51
Message-ID: 1173273831.948758.17617.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 640241 by vanrijn:

ack. okay, we have to use a temp socket and can't close it until after the main \
socket closes.  weird.  I think jpilot has the same leak I saw yesterday with \
multiple CHR links to /dev/null

 M  +11 -13    branches/work/kdepim-3.5.5+/kpilot/lib/kpilotdevicelink.cc  


--- branches/work/kdepim-3.5.5+/kpilot/lib/kpilotdevicelink.cc #640240:640241
@@ -223,6 +223,7 @@
 		QThread(),
 		fDone(true),
 		fHandle(d),
+		fTempSocket(-1),
 		fPilotSocket(-1)
 	{ };
 	virtual ~DeviceCommThread();
@@ -262,6 +263,7 @@
 	* Pilot-link library handles for the device once it's opened.
 	*/
 	int fPilotSocket;
+	int fTempSocket;
 
 protected:
 	/**
@@ -388,9 +390,9 @@
 
 	DEBUGKPILOT << fname << ": Trying to create socket." << endl;
 
-	fPilotSocket = pi_socket(PI_AF_PILOT, PI_SOCK_STREAM, PI_PF_DLP);
+	fTempSocket = pi_socket(PI_AF_PILOT, PI_SOCK_STREAM, PI_PF_DLP);
 
-	if (fPilotSocket < 0)
+	if (fTempSocket < 0)
 	{
 		e = errno;
 		msg = i18n("Cannot create socket for communicating "
@@ -406,14 +408,14 @@
 		return false;
 	}
 
-	DEBUGKPILOT << fname << ": Got socket: [" << fPilotSocket << "]" << endl;
+	DEBUGKPILOT << fname << ": Got socket: [" << fTempSocket << "]" << endl;
 
 	link()->fLinkStatus = CreatedSocket;
 
 	DEBUGKPILOT << fname << ": Binding to path: [" 
 		<< link()->fRealPilotPath << "]" << endl;
 
-	ret = pi_bind(fPilotSocket, QFile::encodeName(link()->fRealPilotPath));
+	ret = pi_bind(fTempSocket, QFile::encodeName(link()->fRealPilotPath));
 
 	if (ret < 0)
 	{
@@ -444,9 +446,9 @@
 	DEBUGKPILOT << fname
 		<< ": Current status: ["
 		<< link()->statusString()
-		<< "] and socket: [" << fPilotSocket << "]" << endl;
+		<< "] and socket: [" << fTempSocket << "]" << endl;
 
-	ret = pi_listen(fPilotSocket, 1);
+	ret = pi_listen(fTempSocket, 1);
 	if (ret < 0)
 	{
 		char *s = strerror(errno);
@@ -474,10 +476,9 @@
 	if (link()->fWorkaroundUSB)
 		timeout=10;
 
-	int sd;
-	sd = pi_accept_to(fPilotSocket, 0, 0, timeout);
+	fPilotSocket = pi_accept_to(fTempSocket, 0, 0, timeout);
 
-	if (sd < 0)
+	if (fPilotSocket < 0)
 	{
 		char *s = strerror(errno);
 
@@ -493,10 +494,6 @@
 
 	DEBUGKPILOT << fname << ": Link accept done." << endl;
 
-	// make sure we close old socket so we don't leak...
-	pi_close(fPilotSocket);
-	fPilotSocket = sd;
-
 	if ((link()->fLinkStatus != DeviceOpen) || (fPilotSocket == -1))
 	{
 		link()->fLinkStatus = PilotLinkError;
@@ -579,6 +576,7 @@
 			<< fPilotSocket << "]" << endl;
 
 		pi_close(fPilotSocket);
+		pi_close(fTempSocket);
 	}
 	fPilotSocket = (-1);
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic