Bug 127253 - Reentrant function prototypes are wrong for NetBSD
Summary: Reentrant function prototypes are wrong for NetBSD
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Unmaintained
Component: knetwork (show other bugs)
Version: unspecified
Platform: Compiled Sources NetBSD
: NOR normal
Target Milestone: ---
Assignee: Thiago Macieira
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-13 14:25 UTC by Hasso Tepper
Modified: 2007-03-31 20:29 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hasso Tepper 2006-05-13 14:25:06 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
OS:                NetBSD

Bug was discovered while debuging kprinter crash on NetBSD - it always crashed at startup in getservbyname_r.

Recent NetBSD releases don't provide reentrant (*_r) function declarations in headers - getservbyname, getservbyport etc. are already reentrant. There is nothing wrong with this and there is no any reason to bug NetBSD developers - *_r function declarations were removed quite recently from public headers in NetBSD. However, *_r function symbols exist in libc for backward binary compatibility.

So, in while compiling KDE HAVE_GETSERVBYNAME_R will be set to 1 on NetBSD because symbol exists in libc, but HAVE_DECL_GETSERVBYNAME_R will be 0, because there is no declaration in public headers. KDE provides own getservbyname_r, getservbyport_r, getprotobyname_r and getprotobynumber_r in such case (kdecore/network/kresolver_p.h). Problem is that these declarations are wrong for NetBSD. NetBSD *_r API is similar (if not the same, I'm not familiar enough with internals of these platforms to say that) to the one used in case of OpenBSD - see for example http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/net/getservbyname_r.c?rev=1.3.

IMHO the logic used in kdecore/network/kresolver_p.h is just plain wrong. It can't be assumed that if symbol exists then declaration provided there should work. Is there any more platforms which use this assumption at the moment? For NetBSD this logic should work - if *_r declarations exist, these should be used, if these don't exist, then it should be assumed that getservbyname etc are already reentrant. 

I volunteer to work on solution and provide patches (both 3.5 and trunk are affected of course), but I'd like to have discussion at first what direction to go.
Comment 1 Thiago Macieira 2006-05-13 15:15:19 UTC
I thought we had fixed that recently in Subversion.
Comment 2 Hasso Tepper 2006-09-17 17:54:50 UTC
I don't see any progress on this. Does it mean that there will be no solution in KDE3?
Comment 3 Thiago Macieira 2007-03-31 20:29:21 UTC
SVN commit 648568 by thiago:

Add the code for KSocketFactory. For now, it doesn't support any
proxies. I'll add the code for that later.

Let's see if it breaks compilation anywhere.

Also, use this opportunity to fix an old-time NetBSD problem: it
provides reentrant a getservbyname() function. So assume all NetBSDs
running KDE 4 have it reentrant.

BUG:127253


 M  +1 -0      CMakeLists.txt  
 AM            network/ksocketfactory.cpp   [License: LGPL (v2+)]
 M  +6 -0      network/ksocketfactory.h  


--- trunk/KDE/kdelibs/kdecore/CMakeLists.txt #648567:648568
@@ -186,6 +186,7 @@
    network/kstreamsocket.cpp
    network/ksocketbuffer.cpp
    network/klocalsocket.cpp
+   network/ksocketfactory.cpp
    network/netsupp.cpp
    localization/kcatalog.cpp
    localization/kcharsets.cpp
** trunk/KDE/kdelibs/kdecore/network/ksocketfactory.cpp #property svn:eol-style
   + native
--- trunk/KDE/kdelibs/kdecore/network/ksocketfactory.h #648567:648568
@@ -23,9 +23,11 @@
 
 #include <kdecore_export.h>
 #include <QtCore/QString>
+#include <QtNetwork/QNetworkProxy>
 
 class QTcpSocket;
 class QTcpServer;
+class QUdpSocket;
 class QHostAddress;
 
 /**
@@ -164,6 +166,10 @@
     static QTcpServer *listenAt(const QString &service, int defaultPort = -1, QObject *parent = 0);
 
     static QUdpSocket *datagramSocket(const QString &node, const QString &service, QObject *parent = 0);
+
+    static QNetworkProxy proxyForConnection(const QString &node, const QString &service);
+    static QNetworkProxy proxyForListening(const QString &service);
+    static QNetworkProxy proxyForDatagram(const QString &node, const QString &service);
 };
 
 #endif