~ubuntu-branches/ubuntu/raring/firebird2.5/raring-proposed

« back to all changes in this revision

Viewing changes to src/jrd/event.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov
  • Date: 2011-09-24 14:12:19 UTC
  • mfrom: (15.1.8 sid)
  • Revision ID: james.westby@ubuntu.com-20110924141219-pkxk7486f3d8ut9f
Tags: 2.5.1.26349-0~rc1.ds4-5
* Medium urgency for fixing a serious bug in testing

* Import a patch from upstream SVN fixing problems in poll() usage when
  process receives signals like SIGALRM.
  Closes: #642555 -- segfault in the remote interface when using alarm() in
  the client program

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
#include "../jrd/err_proto.h"
43
43
#include "../jrd/os/isc_i_proto.h"
44
44
#include "../common/utils_proto.h"
45
 
#include "../jrd/Database.h"
 
45
#include "../jrd/jrd.h"
46
46
 
47
47
#ifdef HAVE_SYS_TYPES_H
48
48
#include <sys/types.h>
74
74
Firebird::GlobalPtr<Firebird::Mutex> EventManager::g_mapMutex;
75
75
 
76
76
 
77
 
void EventManager::init(Database* dbb)
 
77
void EventManager::init(Attachment* attachment)
78
78
{
79
 
        if (!dbb->dbb_event_mgr)
 
79
        Database* const dbb = attachment->att_database;
 
80
        EventManager* eventMgr = dbb->dbb_event_mgr;
 
81
        if (!eventMgr)
80
82
        {
81
83
                const Firebird::string id = dbb->getUniqueFileId();
82
84
 
83
85
                Firebird::MutexLockGuard guard(g_mapMutex);
84
86
 
85
 
                EventManager* eventMgr = NULL;
86
87
                if (!g_emMap->get(id, eventMgr))
87
88
                {
88
89
                        eventMgr = new EventManager(id);
 
90
 
 
91
                        if (g_emMap->put(id, eventMgr))
 
92
                        {
 
93
                                fb_assert(false);
 
94
                        }
89
95
                }
90
96
 
91
97
                fb_assert(eventMgr);
92
98
 
 
99
                eventMgr->addRef();
93
100
                dbb->dbb_event_mgr = eventMgr;
94
101
        }
 
102
 
 
103
        if (!attachment->att_event_session)
 
104
        {
 
105
                attachment->att_event_session = eventMgr->create_session();
 
106
        }
 
107
}
 
108
 
 
109
 
 
110
void EventManager::destroy(EventManager* eventMgr)
 
111
{
 
112
        if (eventMgr)
 
113
        {
 
114
                const Firebird::string id = eventMgr->m_dbId;
 
115
 
 
116
                Firebird::MutexLockGuard guard(g_mapMutex);
 
117
 
 
118
                if (!eventMgr->release())
 
119
                {
 
120
                        if (!g_emMap->remove(id))
 
121
                        {
 
122
                                fb_assert(false);
 
123
                        }
 
124
                }
 
125
        }
95
126
}
96
127
 
97
128
 
105
136
          m_exiting(false)
106
137
{
107
138
        attach_shared_file();
108
 
 
109
 
        Firebird::MutexLockGuard guard(g_mapMutex);
110
 
 
111
 
        if (g_emMap->put(m_dbId, this))
112
 
        {
113
 
                fb_assert(false);
114
 
        }
115
139
}
116
140
 
117
141
 
151
175
        release_shmem();
152
176
 
153
177
        detach_shared_file();
154
 
 
155
 
        Firebird::MutexLockGuard guard(g_mapMutex);
156
 
 
157
 
        if (!g_emMap->remove(m_dbId))
158
 
        {
159
 
                fb_assert(false);
160
 
        }
161
178
}
162
179
 
163
180
 
198
215
}
199
216
 
200
217
 
201
 
SLONG EventManager::createSession()
 
218
SLONG EventManager::create_session()
202
219
{
203
220
/**************************************
204
221
 *
266
283
 
267
284
        // Sanity check
268
285
 
269
 
        if (events[0] != EPB_version1)
 
286
        if (events_length && (!events || events[0] != EPB_version1))
270
287
        {
271
288
                Firebird::Arg::Gds(isc_bad_epb_form).raise();
272
289
        }