author | zecke <zecke> | 2005-03-02 19:42:04 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-03-02 19:42:04 (UTC) |
commit | a349b5d092c392aba28c6fbd99221559c33bc5e1 (patch) (unidiff) | |
tree | 56a809f42d20c6f2fe7a60f243dd1aebca359b39 | |
parent | 9f3e0913c7b01c1e14f907e756999b9d9bf9ceef (diff) | |
download | opie-a349b5d092c392aba28c6fbd99221559c33bc5e1.zip opie-a349b5d092c392aba28c6fbd99221559c33bc5e1.tar.gz opie-a349b5d092c392aba28c6fbd99221559c33bc5e1.tar.bz2 |
Close the Filedescriptor for the QCopBridge and Transferserver on exit
-rw-r--r-- | core/launcher/qcopbridge.cpp | 4 | ||||
-rw-r--r-- | core/launcher/transferserver.cpp | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/core/launcher/qcopbridge.cpp b/core/launcher/qcopbridge.cpp index e339dc7..64eb096 100644 --- a/core/launcher/qcopbridge.cpp +++ b/core/launcher/qcopbridge.cpp | |||
@@ -24,66 +24,68 @@ | |||
24 | /* OPIE */ | 24 | /* OPIE */ |
25 | #include <opie2/odebug.h> | 25 | #include <opie2/odebug.h> |
26 | #include <opie2/oglobal.h> | 26 | #include <opie2/oglobal.h> |
27 | #ifdef Q_WS_QWS | 27 | #ifdef Q_WS_QWS |
28 | #include <qtopia/qcopenvelope_qws.h> | 28 | #include <qtopia/qcopenvelope_qws.h> |
29 | #endif | 29 | #endif |
30 | #include <qtopia/qpeapplication.h> | 30 | #include <qtopia/qpeapplication.h> |
31 | #include <qtopia/version.h> | 31 | #include <qtopia/version.h> |
32 | using namespace Opie::Core; | 32 | using namespace Opie::Core; |
33 | 33 | ||
34 | /* QT */ | 34 | /* QT */ |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qtimer.h> | 36 | #include <qtimer.h> |
37 | #ifdef Q_WS_QWS | 37 | #ifdef Q_WS_QWS |
38 | #include <qcopchannel_qws.h> | 38 | #include <qcopchannel_qws.h> |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | /* STD */ | 41 | /* STD */ |
42 | #ifndef _XOPEN_SOURCE | 42 | #ifndef _XOPEN_SOURCE |
43 | #define _XOPEN_SOURCE | 43 | #define _XOPEN_SOURCE |
44 | #endif | 44 | #endif |
45 | #ifndef Q_OS_WIN32 | 45 | #ifndef Q_OS_WIN32 |
46 | #include <pwd.h> | 46 | #include <pwd.h> |
47 | #include <unistd.h> | 47 | #include <unistd.h> |
48 | #include <fcntl.h> | ||
48 | #include <sys/types.h> | 49 | #include <sys/types.h> |
49 | #endif | 50 | #endif |
50 | 51 | ||
51 | #if defined(_OS_LINUX_) | 52 | #if defined(_OS_LINUX_) |
52 | #include <shadow.h> | 53 | #include <shadow.h> |
53 | #endif | 54 | #endif |
54 | 55 | ||
55 | const int block_size = 51200; | 56 | const int block_size = 51200; |
56 | 57 | ||
57 | QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent, | 58 | QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent, |
58 | const char* name ) | 59 | const char* name ) |
59 | : QServerSocket( port, 1, parent, name ), | 60 | : QServerSocket( port, 1, parent, name ), |
60 | desktopChannel( 0 ), | 61 | desktopChannel( 0 ), |
61 | cardChannel( 0 ) | 62 | cardChannel( 0 ) |
62 | { | 63 | { |
63 | if ( !ok() ) | 64 | if ( !ok() ) |
64 | owarn << "Failed to bind to port " << port << "" << oendl; | 65 | owarn << "Failed to bind to port " << port << "" << oendl; |
65 | else { | 66 | else { |
67 | ::fcntl( socket(), F_SETFD, FD_CLOEXEC ); | ||
66 | #ifndef QT_NO_COP | 68 | #ifndef QT_NO_COP |
67 | desktopChannel = new QCopChannel( "QPE/Desktop", this ); | 69 | desktopChannel = new QCopChannel( "QPE/Desktop", this ); |
68 | connect( desktopChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 70 | connect( desktopChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
69 | this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); | 71 | this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); |
70 | cardChannel = new QCopChannel( "QPE/Card", this ); | 72 | cardChannel = new QCopChannel( "QPE/Card", this ); |
71 | connect( cardChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 73 | connect( cardChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
72 | this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); | 74 | this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); |
73 | #endif | 75 | #endif |
74 | } | 76 | } |
75 | sendSync = FALSE; | 77 | sendSync = FALSE; |
76 | openConnections.setAutoDelete( TRUE ); | 78 | openConnections.setAutoDelete( TRUE ); |
77 | authorizeConnections(); | 79 | authorizeConnections(); |
78 | } | 80 | } |
79 | 81 | ||
80 | QCopBridge::~QCopBridge() | 82 | QCopBridge::~QCopBridge() |
81 | { | 83 | { |
82 | #ifndef QT_NO_COP | 84 | #ifndef QT_NO_COP |
83 | delete desktopChannel; | 85 | delete desktopChannel; |
84 | #endif | 86 | #endif |
85 | } | 87 | } |
86 | 88 | ||
87 | void QCopBridge::authorizeConnections() | 89 | void QCopBridge::authorizeConnections() |
88 | { | 90 | { |
89 | Config cfg("Security"); | 91 | Config cfg("Security"); |
diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp index 2b2e435..a219c0f 100644 --- a/core/launcher/transferserver.cpp +++ b/core/launcher/transferserver.cpp | |||
@@ -18,65 +18,68 @@ | |||
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "transferserver.h" | 20 | #include "transferserver.h" |
21 | 21 | ||
22 | /* OPIE */ | 22 | /* OPIE */ |
23 | #include <opie2/odebug.h> | 23 | #include <opie2/odebug.h> |
24 | #include <opie2/oglobal.h> | 24 | #include <opie2/oglobal.h> |
25 | #include <qtopia/qprocess.h> | 25 | #include <qtopia/qprocess.h> |
26 | #include <qtopia/process.h> | 26 | #include <qtopia/process.h> |
27 | #include <qtopia/private/contact.h> | 27 | #include <qtopia/private/contact.h> |
28 | #include <qtopia/version.h> | 28 | #include <qtopia/version.h> |
29 | #ifdef Q_WS_QWS | 29 | #ifdef Q_WS_QWS |
30 | #include <qtopia/qcopenvelope_qws.h> | 30 | #include <qtopia/qcopenvelope_qws.h> |
31 | #endif | 31 | #endif |
32 | using namespace Opie::Core; | 32 | using namespace Opie::Core; |
33 | 33 | ||
34 | /* QT */ | 34 | /* QT */ |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
37 | 37 | ||
38 | /* STD */ | 38 | /* STD */ |
39 | #include <pwd.h> | 39 | #include <pwd.h> |
40 | #include <sys/types.h> | 40 | #include <sys/types.h> |
41 | #include <unistd.h> | 41 | #include <unistd.h> |
42 | #include <fcntl.h> | ||
42 | #include <stdlib.h> | 43 | #include <stdlib.h> |
43 | #include <time.h> | 44 | #include <time.h> |
44 | 45 | ||
45 | #ifndef Q_OS_MACX | 46 | #ifndef Q_OS_MACX |
46 | #include <shadow.h> | 47 | #include <shadow.h> |
47 | #include <crypt.h> | 48 | #include <crypt.h> |
48 | #endif /* Q_OS_MACX */ | 49 | #endif /* Q_OS_MACX */ |
49 | 50 | ||
50 | const int block_size = 51200; | 51 | const int block_size = 51200; |
51 | 52 | ||
52 | TransferServer::TransferServer( Q_UINT16 port, QObject *parent, | 53 | TransferServer::TransferServer( Q_UINT16 port, QObject *parent, |
53 | const char* name) | 54 | const char* name) |
54 | : QServerSocket( port, 1, parent, name ) | 55 | : QServerSocket( port, 1, parent, name ) |
55 | { | 56 | { |
56 | connections.setAutoDelete( TRUE ); | 57 | connections.setAutoDelete( TRUE ); |
57 | if ( !ok() ) | 58 | if ( !ok() ) |
58 | owarn << "Failed to bind to port " << port << "" << oendl; | 59 | owarn << "Failed to bind to port " << port << "" << oendl; |
60 | else | ||
61 | ::fcntl( socket(), F_SETFD, FD_CLOEXEC ); | ||
59 | } | 62 | } |
60 | 63 | ||
61 | void TransferServer::authorizeConnections() | 64 | void TransferServer::authorizeConnections() |
62 | { | 65 | { |
63 | QListIterator<ServerPI> it(connections); | 66 | QListIterator<ServerPI> it(connections); |
64 | while ( it.current() ) { | 67 | while ( it.current() ) { |
65 | if ( !it.current()->verifyAuthorised() ) { | 68 | if ( !it.current()->verifyAuthorised() ) { |
66 | disconnect( it.current(), SIGNAL(connectionClosed(ServerPI*)), this, SLOT( closed(ServerPI*)) ); | 69 | disconnect( it.current(), SIGNAL(connectionClosed(ServerPI*)), this, SLOT( closed(ServerPI*)) ); |
67 | connections.removeRef( it.current() ); | 70 | connections.removeRef( it.current() ); |
68 | } else | 71 | } else |
69 | ++it; | 72 | ++it; |
70 | } | 73 | } |
71 | } | 74 | } |
72 | 75 | ||
73 | void TransferServer::closed(ServerPI *item) | 76 | void TransferServer::closed(ServerPI *item) |
74 | { | 77 | { |
75 | connections.removeRef(item); | 78 | connections.removeRef(item); |
76 | } | 79 | } |
77 | 80 | ||
78 | TransferServer::~TransferServer() | 81 | TransferServer::~TransferServer() |
79 | { | 82 | { |
80 | } | 83 | } |
81 | 84 | ||
82 | void TransferServer::newConnection( int socket ) | 85 | void TransferServer::newConnection( int socket ) |