Bug 16190 - kio forgets to close socket after ERR_UNKNOWN_HOST(23)
Summary: kio forgets to close socket after ERR_UNKNOWN_HOST(23)
Status: CLOSED FIXED
Alias: None
Product: kio
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 1.9.8
Platform: unspecified Linux
: NOR grave
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2000-11-28 12:03 UTC by Wolfgang Rohdewald
Modified: 2002-09-16 14:43 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Rohdewald 2000-11-28 11:58:45 UTC
(*** This bug was imported into bugs.kde.org ***)

Package: kio
Version: v1.9.8 (KDE 2.0 >= 20001117)
Severity: grave
Compiler: gcc version 2.95.2 19991024 (release)
OS: Linux 2.2.16 i686 (compiled sources)

in TCPSlaveBase::ConnectToHost is this code correct ? Should
there be no close(m_iSock) before the return statements ? Fix
see below untested yet. Please edit the line ::connect first might
be wrapped.

Problem: This morning the system had run out of file descriptors
caused by kmail. Kmail output (filtered:)

kio (KIOJob): error 23 pop.dplanet.ch
kio (KIOJob): error 23 pop.dplanet.ch

8 lines per minute (I was testing interval mail checking)

/tmp# diff -u old /u2/src/cvs/kde/kdelibs/kio/tcpslavebase.cpp
--- old Tue Nov 28 12:30:44 2000
+++ /u2/src/cvs/kde/kdelibs/kio/tcpslavebase.cpp        Tue Nov 28 12:56:08 2000@@ -12111 +12113 @@
        if (!KSocket::initSockaddr(&server_name host port))
         {
                error( ERR_UNKNOWN_HOST host);
+               CloseDescriptor();
                return false;
         }
 
        if (::connect(m_iSock (struct sockaddr*)(&server_name) sizeof(server_name))) {
                error( ERR_COULD_NOT_CONNECT host);
+               CloseDescriptor();
                return false;
        }
 
@@ -1756 +17710 @@
                fp=0;
                m_iSock=-1;
                CleanSSL();
+       }
+       if (m_iSock != -1) {
+               close(m_iSock);
+               m_iSock=-1;
        }
 }
Comment 1 Wolfgang Rohdewald 2000-12-25 11:03:18 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sunday 24 December 2000 11:29 Michael Häckel wrote:
> On Sunday 24. December 2000 00:27 Wolfgang Rohdewald wrote:
> > for whatever reason kmail gave me a popup window
> > "cannot access //usr/spool/mail/wr". I did not note the exact message
> > sorry.
> >
> > After pressing OK and going online lots of QTimers started to get mail. I
> > normally check 3 pop servers every minute - at least that's how it is
> > configured.
>
> Hopefully fixed. KMail should check now it the account is already in the
> list for mail checking. Please tell me if it still doesn't work.

I suppose meanwhile I have the updated cvs but there is still a problem -
if it is the same. There a no longer so many qtimers going off so your
patch seems to work. BUT - All my 4 pop3 slaves have hundreds of open sockets.

Please have a look at bug report 16190 - it contains a proposed patch to
kio which in my opinion forgets to close sockets when it should. I never
got any response to this bug report. I never tried it either yet because
until 3 days ago this never happened again. Now I have it every morning.



Package: kio
Version: v1.9.8 (KDE 2.0 >= 20001117)
Severity: grave
Compiler: gcc version 2.95.2 19991024 (release)
OS: Linux 2.2.16 i686 (compiled sources)

in TCPSlaveBase::ConnectToHost is this code correct ? Should
there be no close(m_iSock) before the return statements ? Fix
see below untested yet. Please edit the line ::connect first might
be wrapped.

Problem: This morning the system had run out of file descriptors
caused by kmail. Kmail output (filtered:)

kio (KIOJob): error 23 pop.dplanet.ch
kio (KIOJob): error 23 pop.dplanet.ch

8 lines per minute (I was testing interval mail checking)

/tmp# diff -u old /u2/src/cvs/kde/kdelibs/kio/tcpslavebase.cpp
- --- old Tue Nov 28 12:30:44 2000
+++ /u2/src/cvs/kde/kdelibs/kio/tcpslavebase.cpp        Tue Nov 28 12:56:08 2000@@ -12111 +12113 @@
        if (!KSocket::initSockaddr(&server_name host port))
         {
                error( ERR_UNKNOWN_HOST host);
+               CloseDescriptor();
                return false;
         }
 
        if (::connect(m_iSock (struct sockaddr*)(&server_name) sizeof(server_name))) {
                error( ERR_COULD_NOT_CONNECT host);
+               CloseDescriptor();
                return false;
        }
 
@@ -1756 +17710 @@
                fp=0;
                m_iSock=-1;
                CleanSSL();
+       }
+       if (m_iSock != -1) {
+               close(m_iSock);
+               m_iSock=-1;
        }
 } 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAjpHKYAACgkQMoa7xU5silpARACgs50HOmi4LEsyStAar/eYaFH3
5qUAn38s+fk8a7vjCKUmfcHlTjxa8cFJ
=eAmL
-----END PGP SIGNATURE-----
Comment 2 Michael Haeckel 2000-12-26 09:31:24 UTC
> Please have a look at bug report 16190 - it contains a proposed patch to
> kio which in my opinion forgets to close sockets when it should. I never
> got any response to this bug report. I never tried it either yet because
> until 3 days ago this never happened again. Now I have it every morning.

Committed.

Regards
Michael Haeckel
Comment 3 Wolfgang Rohdewald 2000-12-26 11:50:00 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday 26 December 2000 10:33 Stephan Kulow wrote:
> This is an automatic notification regarding your bug report.
>
> It has been closed by one of the developers namely
> Michael =?iso-8859-1?q?H=E4ckel?= <Michael@Haeckel.Net>.

>
> Committed.
>
> Regards
> Michael Haeckel

I just got cvs. In that copy only the second part is committed.
The problem code is unchanged: If host unknown or could not connect
the socket still does not close. Or is there something I don't
understand ?

This is the missing part. As I said in my bug report the line
with ::connect might need to be edited first - it might wrap.


/tmp# diff -u old /u2/src/cvs/kde/kdelibs/kio/tcpslavebase.cpp
- --- old Tue Nov 28 12:30:44 2000
+++ /u2/src/cvs/kde/kdelibs/kio/tcpslavebase.cpp        Tue Nov 28 12:56:08 
2000@@ -12111 +12113 @@
        if (!KSocket::initSockaddr(&server_name host port))
         {
                error( ERR_UNKNOWN_HOST host);
+               CloseDescriptor();
                return false;
         }

        if (::connect(m_iSock (struct sockaddr*)(&server_name) 
sizeof(server_name))) {
                error( ERR_COULD_NOT_CONNECT host);
+               CloseDescriptor();
                return false;
        }

Regards Wolfgang
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAjpIhekACgkQMoa7xU5silpAwwCglI6iQonVjc6kQRa6Y5P2dU/i
/H8Anj9ks+Z68gQP8Yi6apYtuOn5S3yA
=QunK
-----END PGP SIGNATURE-----
Comment 4 Michael Haeckel 2000-12-26 14:19:05 UTC
On Tuesday 26. December 2000 12:50 Wolfgang Rohdewald wrote:
>
> I just got cvs. In that copy only the second part is committed.
> The problem code is unchanged: If host unknown or could not connect
> the socket still does not close. Or is there something I don't
> understand ?
>
> This is the missing part. As I said in my bug report the line
> with ::connect might need to be edited first - it might wrap.

Sorry for that should be correct now.
There was a problem because the patch didn't apply plainly and I edited th=
e=20
file manually.

Regards
Michael H=E4ckel
Comment 5 David Faure 2001-01-03 22:38:29 UTC
Thanks for applying the patch. Closing the bug.

--=20
David FAURE david@mandrakesoft.com faure@kde.org
http://www.mandrakesoft.com/~david/ http://www.konqueror.org/
KDE Making The Future of Computing Available Today