source: trunk/src/kernel/qeventloop_p.h@ 154

Last change on this file since 154 was 116, checked in by dmik, 19 years ago

Kernel/Network: Changed the socket notifier activation logic so that sockets pending for activation are removed from select() until activation is processed by the main thread. This prevents deadlocks on blocking sockets (as a result of late socket notifications due to a race condition) and avoids repeated select() calls returning the same set of sockets when the event queue is not processed fast enough to handle activation. Note: this improvement is experimental. In case if it is rolled back for some reason, QServerSocket needs to be patched (by setting a non-blocking mode for sockets) to avoid GUI thread deadlocks.

  • Property svn:keywords set to Id
File size: 3.5 KB
Line 
1/****************************************************************************
2** $Id: qeventloop_p.h 116 2006-08-11 13:01:59Z dmik $
3**
4** Definition of QEventLoop class
5**
6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
7**
8** This file is part of the kernel module of the Qt GUI Toolkit.
9**
10** This file may be distributed and/or modified under the terms of the
11** GNU General Public License version 2 as published by the Free Software
12** Foundation and appearing in the file LICENSE.GPL included in the
13** packaging of this file.
14**
15** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
16** licenses for Qt/Embedded may use this file in accordance with the
17** Qt Embedded Commercial License Agreement provided with the Software.
18**
19** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21**
22** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
23** information about Qt Commercial License Agreements.
24** See http://www.trolltech.com/gpl/ for GPL licensing information.
25**
26** Contact info@trolltech.com if any conditions of this licensing are
27** not clear to you.
28**
29**********************************************************************/
30
31#ifndef QEVENTLOOP_P_H
32#define QEVENTLOOP_P_H
33
34//
35// W A R N I N G
36// -------------
37//
38// This file is not part of the Qt API. This header file may
39// change from version to version without notice, or even be
40// removed.
41//
42// We mean it.
43//
44//
45
46#ifndef QT_H
47#include "qplatformdefs.h"
48#endif // QT_H
49
50// SCO OpenServer redefines raise -> kill
51#if defined(raise)
52# undef raise
53#endif
54
55#include "qwindowdefs.h"
56
57class QSocketNotifier;
58#ifdef Q_OS_MAC
59class QMacSockNotPrivate;
60#endif
61
62#if defined(Q_OS_UNIX) || defined(Q_WS_WIN) || defined(Q_WS_PM)
63#include "qptrlist.h"
64#endif // Q_OS_UNIX || Q_WS_WIN || Q_WS_PM
65
66#if defined(Q_OS_UNIX) || defined(Q_WS_PM)
67struct QSockNot
68{
69 QSocketNotifier *obj;
70 int fd;
71 fd_set *queue;
72#if defined(Q_WS_PM)
73 fd_set *active;
74#endif
75};
76
77class QSockNotType
78{
79public:
80 QSockNotType();
81 ~QSockNotType();
82
83 QPtrList<QSockNot> *list;
84 fd_set select_fds;
85 fd_set enabled_fds;
86 fd_set pending_fds;
87
88};
89#endif // Q_OS_UNIX
90
91#if defined(Q_WS_WIN)
92struct QSockNot {
93 QSocketNotifier *obj;
94 int fd;
95};
96#endif // Q_WS_WIN
97
98class QEventLoopPrivate
99{
100public:
101 QEventLoopPrivate()
102 {
103 reset();
104 }
105
106 void reset() {
107 looplevel = 0;
108 quitcode = 0;
109 quitnow = FALSE;
110 exitloop = FALSE;
111 shortcut = FALSE;
112 }
113
114 int looplevel;
115 int quitcode;
116 unsigned int quitnow : 1;
117 unsigned int exitloop : 1;
118 unsigned int shortcut : 1;
119
120#if defined(Q_WS_MAC)
121 uchar next_select_timer;
122 EventLoopTimerRef select_timer;
123#endif
124
125#if defined(Q_WS_X11)
126 int xfd;
127#endif // Q_WS_X11
128
129#if defined(Q_OS_UNIX)
130 int thread_pipe[2];
131#endif
132#if defined(Q_OS_UNIX) || defined(Q_WS_PM)
133 // pending socket notifiers list
134 QPtrList<QSockNot> sn_pending_list;
135 // highest fd for all socket notifiers
136 int sn_highest;
137#if defined(Q_WS_PM)
138 // fd for cancelling select()
139 int sn_cancel;
140#endif
141 // 3 socket notifier types - read, write and exception
142 QSockNotType sn_vec[3];
143#endif
144
145#if defined(Q_WS_WIN)
146 // pending socket notifiers list
147 QPtrList<QSockNot> sn_pending_list;
148#endif // Q_WS_WIN
149
150#if defined(Q_WS_PM)
151 HAB hab;
152 HMQ hmq;
153#endif
154
155};
156
157#endif // QEVENTLOOP_P_H
Note: See TracBrowser for help on using the repository browser.