~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.cc

Merge Joe

Show diffs side-by-side

added added

removed removed

Lines of Context:
224
224
  query_id= 0;
225
225
  warn_query_id= 0;
226
226
  mysys_var= 0;
 
227
  scoreboard_index= -1;
227
228
  dbug_sentry=Session_SENTRY_MAGIC;
228
229
  cleanup_done= abort_on_warning= no_warnings_for_error= false;
229
230
  pthread_mutex_init(&LOCK_delete, MY_MUTEX_INIT_FAST);
344
345
Session::~Session()
345
346
{
346
347
  this->checkSentry();
347
 
  add_to_status(&global_status_var, &status_var);
348
348
 
349
349
  if (client->isConnected())
350
350
  {
381
381
  pthread_mutex_destroy(&LOCK_delete);
382
382
}
383
383
 
384
 
/*
385
 
  Add all status variables to another status variable array
386
 
 
387
 
  SYNOPSIS
388
 
   add_to_status()
389
 
   to_var       add to this array
390
 
   from_var     from this array
391
 
 
392
 
  NOTES
393
 
    This function assumes that all variables are long/ulong.
394
 
    If this assumption will change, then we have to explictely add
395
 
    the other variables after the while loop
396
 
*/
397
 
void add_to_status(system_status_var *to_var, system_status_var *from_var)
398
 
{
399
 
  ulong *end= (ulong*) ((unsigned char*) to_var +
400
 
                        offsetof(system_status_var, last_system_status_var) +
401
 
                        sizeof(ulong));
402
 
  ulong *to= (ulong*) to_var, *from= (ulong*) from_var;
403
 
 
404
 
  while (to != end)
405
 
    *(to++)+= *(from++);
406
 
}
407
 
 
408
 
/*
409
 
  Add the difference between two status variable arrays to another one.
410
 
 
411
 
  SYNOPSIS
412
 
    add_diff_to_status
413
 
    to_var       add to this array
414
 
    from_var     from this array
415
 
    dec_var      minus this array
416
 
 
417
 
  NOTE
418
 
    This function assumes that all variables are long/ulong.
419
 
*/
420
 
void add_diff_to_status(system_status_var *to_var, system_status_var *from_var,
421
 
                        system_status_var *dec_var)
422
 
{
423
 
  ulong *end= (ulong*) ((unsigned char*) to_var + offsetof(system_status_var,
424
 
                                                  last_system_status_var) +
425
 
                        sizeof(ulong));
426
 
  ulong *to= (ulong*) to_var, *from= (ulong*) from_var, *dec= (ulong*) dec_var;
427
 
 
428
 
  while (to != end)
429
 
    *(to++)+= *(from++) - *(dec++);
430
 
}
431
 
 
432
384
void Session::awake(Session::killed_state state_to_set)
433
385
{
434
386
  this->checkSentry();
1753
1705
{
1754
1706
  pthread_mutex_lock(&LOCK_status);
1755
1707
 
1756
 
  /* Add thread's status variabes to global status */
1757
 
  add_to_status(&global_status_var, &status_var);
1758
 
 
1759
1708
  /* Reset thread's status variables */
1760
1709
  memset(&status_var, 0, sizeof(status_var));
1761
1710
 
1762
 
  /* Reset some global variables */
1763
 
  reset_status_vars();
1764
 
 
1765
1711
  /* Reset the counters of all key caches (default and named). */
1766
1712
  reset_key_cache_counters();
1767
1713
  flush_status_time= time((time_t*) 0);