~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.h

  • Committer: Brian Aker
  • Date: 2010-11-30 00:29:39 UTC
  • mto: (1965.2.2 build)
  • mto: This revision was merged to the branch mainline in revision 1966.
  • Revision ID: brian@tangent.org-20101130002939-8bzz3xpa0aapbq2w
Fix sleep() so that a kill command will kill it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include "drizzled/util/storable.h"
38
38
#include "drizzled/my_hash.h"
39
39
#include "drizzled/pthread_globals.h"
 
40
 
40
41
#include <netdb.h>
41
 
#include <sys/time.h>
42
 
#include <sys/resource.h>
43
 
 
44
 
#include <algorithm>
 
42
#include <map>
 
43
#include <string>
45
44
#include <bitset>
46
45
#include <deque>
47
 
#include <map>
48
 
#include <string>
49
46
 
 
47
#include "drizzled/internal/getrusage.h"
50
48
#include "drizzled/security_context.h"
51
49
#include "drizzled/open_tables_state.h"
52
50
#include "drizzled/internal_error_handler.h"
59
57
#include <boost/thread/mutex.hpp>
60
58
#include <boost/thread/shared_mutex.hpp>
61
59
#include <boost/thread/condition_variable.hpp>
62
 
#include <boost/make_shared.hpp>
63
 
 
64
60
 
65
61
#define MIN_HANDSHAKE_SIZE      6
66
62
 
418
414
 
419
415
  void resetQueryString()
420
416
  {
421
 
    query.reset();
422
 
    _state.reset();
 
417
    return query.reset(new std::string);
423
418
  }
424
419
 
425
420
  /*
431
426
  {
432
427
    QueryString tmp_string(getQueryString());
433
428
 
434
 
    assert(tmp_string);
435
 
    if (not tmp_string)
436
 
    {
437
 
      length= 0;
438
 
      return 0;
439
 
    }
440
 
 
441
429
    length= tmp_string->length();
442
430
    char *to_return= strmake(tmp_string->c_str(), tmp_string->length());
443
431
    return to_return;
444
432
  }
445
433
 
446
 
  class State {
447
 
    std::vector <char> _query;
448
 
 
449
 
  public:
450
 
    typedef boost::shared_ptr<State> const_shared_ptr;
451
 
 
452
 
    State(const char *in_packet, size_t in_packet_length)
453
 
    {
454
 
      if (in_packet_length)
455
 
      {
456
 
        size_t minimum= std::min(in_packet_length, static_cast<size_t>(PROCESS_LIST_WIDTH));
457
 
        _query.resize(minimum + 1);
458
 
        memcpy(&_query[0], in_packet, minimum);
459
 
      }
460
 
      else
461
 
      {
462
 
        _query.resize(0);
463
 
      }
464
 
    }
465
 
 
466
 
    const char *query() const
467
 
    {
468
 
      if (_query.size())
469
 
        return &_query[0];
470
 
 
471
 
      return "";
472
 
    }
473
 
 
474
 
    const char *query(size_t &size) const
475
 
    {
476
 
      if (_query.size())
477
 
      {
478
 
        size= _query.size() -1;
479
 
        return &_query[0];
480
 
      }
481
 
 
482
 
      size= 0;
483
 
      return "";
484
 
    }
485
 
  protected:
486
 
    friend class Session;
487
 
    typedef boost::shared_ptr<State> shared_ptr;
488
 
  };
489
 
private:
490
 
  State::shared_ptr  _state; 
491
 
public:
492
 
 
493
 
  State::const_shared_ptr state()
494
 
  {
495
 
    return _state;
496
 
  }
497
 
 
498
434
  /**
499
435
    Name of the current (default) database.
500
436
 
507
443
    the Session of that thread); that thread is (and must remain, for now) the
508
444
    only responsible for freeing this member.
509
445
  */
510
 
private:
511
 
  util::string::shared_ptr _schema;
512
 
public:
 
446
  std::string db;
513
447
 
514
 
  util::string::const_shared_ptr schema() const
 
448
  const std::string &getSchema() const
515
449
  {
516
 
    if (_schema)
517
 
      return _schema;
518
 
 
519
 
    return util::string::const_shared_ptr(new std::string(""));
 
450
    return db;
520
451
  }
521
452
  std::string catalog;
522
453
  /* current cache key */
931
862
    return &_killed;
932
863
  }
933
864
 
934
 
  bool is_admin_connection;
935
865
  bool some_tables_deleted;
936
866
  bool no_errors;
937
867
  bool password;
1377
1307
    database usually involves other actions, like switching other database
1378
1308
    attributes including security context. In the future, this operation
1379
1309
    will be made private and more convenient interface will be provided.
 
1310
 
 
1311
    @return Operation status
 
1312
      @retval false Success
 
1313
      @retval true  Out-of-memory error
1380
1314
  */
1381
 
  void set_db(const std::string &new_db);
 
1315
  bool set_db(const std::string &new_db);
1382
1316
 
1383
1317
  /*
1384
1318
    Copy the current database to the argument. Use the current arena to