~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

Viewing changes to storage/innodb_plugin/thr/thr0loc.c

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
/** The value of thr_local_struct::magic_n */
72
72
#define THR_LOCAL_MAGIC_N       1231234
73
73
 
 
74
#ifdef UNIV_DEBUG
 
75
/*******************************************************************//**
 
76
Validates thread local data.
 
77
@return TRUE if valid */
 
78
static
 
79
ibool
 
80
thr_local_validate(
 
81
/*===============*/
 
82
        const thr_local_t*      local)  /*!< in: data to validate */
 
83
{
 
84
        ut_ad(local->magic_n == THR_LOCAL_MAGIC_N);
 
85
        ut_ad(local->slot_no == ULINT_UNDEFINED
 
86
              || local->slot_no < OS_THREAD_MAX_N);
 
87
        ut_ad(local->in_ibuf == FALSE || local->in_ibuf == TRUE);
 
88
        return(TRUE);
 
89
}
 
90
#endif /* UNIV_DEBUG */
 
91
 
74
92
/*******************************************************************//**
75
93
Returns the local storage struct for a thread.
76
94
@return local storage */
91
109
        local = NULL;
92
110
 
93
111
        HASH_SEARCH(hash, thr_local_hash, os_thread_pf(id),
94
 
                    thr_local_t*, local,, os_thread_eq(local->id, id));
 
112
                    thr_local_t*, local, ut_ad(thr_local_validate(local)),
 
113
                    os_thread_eq(local->id, id));
95
114
        if (local == NULL) {
96
115
                mutex_exit(&thr_local_mutex);
97
116
 
102
121
                goto try_again;
103
122
        }
104
123
 
105
 
        ut_ad(local->magic_n == THR_LOCAL_MAGIC_N);
 
124
        ut_ad(thr_local_validate(local));
106
125
 
107
126
        return(local);
108
127
}
188
207
        local->id = os_thread_get_curr_id();
189
208
        local->handle = os_thread_get_curr();
190
209
        local->magic_n = THR_LOCAL_MAGIC_N;
191
 
 
 
210
        local->slot_no = ULINT_UNDEFINED;
192
211
        local->in_ibuf = FALSE;
193
212
 
194
213
        mutex_enter(&thr_local_mutex);
215
234
        /* Look for the local struct in the hash table */
216
235
 
217
236
        HASH_SEARCH(hash, thr_local_hash, os_thread_pf(id),
218
 
                    thr_local_t*, local,, os_thread_eq(local->id, id));
 
237
                    thr_local_t*, local, ut_ad(thr_local_validate(local)),
 
238
                    os_thread_eq(local->id, id));
219
239
        if (local == NULL) {
220
240
                mutex_exit(&thr_local_mutex);
221
241
 
228
248
        mutex_exit(&thr_local_mutex);
229
249
 
230
250
        ut_a(local->magic_n == THR_LOCAL_MAGIC_N);
 
251
        ut_ad(thr_local_validate(local));
231
252
 
232
253
        mem_free(local);
233
254
}
270
291
 
271
292
                        local = HASH_GET_NEXT(hash, prev_local);
272
293
                        ut_a(prev_local->magic_n == THR_LOCAL_MAGIC_N);
 
294
                        ut_ad(thr_local_validate(prev_local));
273
295
                        mem_free(prev_local);
274
296
                }
275
297
        }