~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/thr/thr0loc.c

  • Committer: Brian Aker
  • Date: 2010-12-19 06:20:54 UTC
  • mfrom: (2005.1.1 bug673105)
  • Revision ID: brian@tangent.org-20101219062054-1kt0l3dxs4z2z8md
Merge Dave.

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
/** The value of thr_local_struct::magic_n */
77
77
#define THR_LOCAL_MAGIC_N       1231234
78
78
 
79
 
#ifdef UNIV_DEBUG
80
 
/*******************************************************************//**
81
 
Validates thread local data.
82
 
@return TRUE if valid */
83
 
static
84
 
ibool
85
 
thr_local_validate(
86
 
/*===============*/
87
 
        const thr_local_t*      local)  /*!< in: data to validate */
88
 
{
89
 
        ut_ad(local->magic_n == THR_LOCAL_MAGIC_N);
90
 
        ut_ad(local->slot_no == ULINT_UNDEFINED
91
 
              || local->slot_no < OS_THREAD_MAX_N);
92
 
        ut_ad(local->in_ibuf == FALSE || local->in_ibuf == TRUE);
93
 
        return(TRUE);
94
 
}
95
 
#endif /* UNIV_DEBUG */
96
 
 
97
79
/*******************************************************************//**
98
80
Returns the local storage struct for a thread.
99
81
@return local storage */
114
96
        local = NULL;
115
97
 
116
98
        HASH_SEARCH(hash, thr_local_hash, os_thread_pf(id),
117
 
                    thr_local_t*, local, ut_ad(thr_local_validate(local)),
118
 
                    os_thread_eq(local->id, id));
 
99
                    thr_local_t*, local,, os_thread_eq(local->id, id));
119
100
        if (local == NULL) {
120
101
                mutex_exit(&thr_local_mutex);
121
102
 
126
107
                goto try_again;
127
108
        }
128
109
 
129
 
        ut_ad(thr_local_validate(local));
 
110
        ut_ad(local->magic_n == THR_LOCAL_MAGIC_N);
130
111
 
131
112
        return(local);
132
113
}
207
188
                thr_local_init();
208
189
        }
209
190
 
210
 
        local = static_cast<thr_local_t *>(mem_alloc(sizeof(thr_local_t)));
 
191
        local = mem_alloc(sizeof(thr_local_t));
211
192
 
212
193
        local->id = os_thread_get_curr_id();
213
194
        local->handle = os_thread_get_curr();
214
195
        local->magic_n = THR_LOCAL_MAGIC_N;
215
 
        local->slot_no = ULINT_UNDEFINED;
 
196
 
216
197
        local->in_ibuf = FALSE;
217
198
 
218
199
        mutex_enter(&thr_local_mutex);
239
220
        /* Look for the local struct in the hash table */
240
221
 
241
222
        HASH_SEARCH(hash, thr_local_hash, os_thread_pf(id),
242
 
                    thr_local_t*, local, ut_ad(thr_local_validate(local)),
243
 
                    os_thread_eq(local->id, id));
 
223
                    thr_local_t*, local,, os_thread_eq(local->id, id));
244
224
        if (local == NULL) {
245
225
                mutex_exit(&thr_local_mutex);
246
226
 
253
233
        mutex_exit(&thr_local_mutex);
254
234
 
255
235
        ut_a(local->magic_n == THR_LOCAL_MAGIC_N);
256
 
        ut_ad(thr_local_validate(local));
257
236
 
258
237
        mem_free(local);
259
238
}
290
269
        for (i = 0; i < hash_get_n_cells(thr_local_hash); i++) {
291
270
                thr_local_t*    local;
292
271
 
293
 
                local = static_cast<thr_local_t *>(HASH_GET_FIRST(thr_local_hash, i));
 
272
                local = HASH_GET_FIRST(thr_local_hash, i);
294
273
 
295
274
                while (local) {
296
275
                        thr_local_t*    prev_local = local;
297
276
 
298
 
                        local = static_cast<thr_local_t *>(HASH_GET_NEXT(hash, prev_local));
 
277
                        local = HASH_GET_NEXT(hash, prev_local);
299
278
                        ut_a(prev_local->magic_n == THR_LOCAL_MAGIC_N);
300
 
                        ut_ad(thr_local_validate(prev_local));
301
279
                        mem_free(prev_local);
302
280
                }
303
281
        }