~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

Merge Stewart - Update innobase plugin to be based on innodb 1.1.4 from MySQL 5.5.8 

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
 
79
97
/*******************************************************************//**
80
98
Returns the local storage struct for a thread.
81
99
@return local storage */
96
114
        local = NULL;
97
115
 
98
116
        HASH_SEARCH(hash, thr_local_hash, os_thread_pf(id),
99
 
                    thr_local_t*, local,, os_thread_eq(local->id, id));
 
117
                    thr_local_t*, local, ut_ad(thr_local_validate(local)),
 
118
                    os_thread_eq(local->id, id));
100
119
        if (local == NULL) {
101
120
                mutex_exit(&thr_local_mutex);
102
121
 
107
126
                goto try_again;
108
127
        }
109
128
 
110
 
        ut_ad(local->magic_n == THR_LOCAL_MAGIC_N);
 
129
        ut_ad(thr_local_validate(local));
111
130
 
112
131
        return(local);
113
132
}
193
212
        local->id = os_thread_get_curr_id();
194
213
        local->handle = os_thread_get_curr();
195
214
        local->magic_n = THR_LOCAL_MAGIC_N;
196
 
 
 
215
        local->slot_no = ULINT_UNDEFINED;
197
216
        local->in_ibuf = FALSE;
198
217
 
199
218
        mutex_enter(&thr_local_mutex);
220
239
        /* Look for the local struct in the hash table */
221
240
 
222
241
        HASH_SEARCH(hash, thr_local_hash, os_thread_pf(id),
223
 
                    thr_local_t*, local,, os_thread_eq(local->id, id));
 
242
                    thr_local_t*, local, ut_ad(thr_local_validate(local)),
 
243
                    os_thread_eq(local->id, id));
224
244
        if (local == NULL) {
225
245
                mutex_exit(&thr_local_mutex);
226
246
 
233
253
        mutex_exit(&thr_local_mutex);
234
254
 
235
255
        ut_a(local->magic_n == THR_LOCAL_MAGIC_N);
 
256
        ut_ad(thr_local_validate(local));
236
257
 
237
258
        mem_free(local);
238
259
}
276
297
 
277
298
                        local = HASH_GET_NEXT(hash, prev_local);
278
299
                        ut_a(prev_local->magic_n == THR_LOCAL_MAGIC_N);
 
300
                        ut_ad(thr_local_validate(prev_local));
279
301
                        mem_free(prev_local);
280
302
                }
281
303
        }