~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/client/concurrent.h

[patch 106/129] Merge patch for revision 1915 from InnoDB SVN:
revno: 1915
revision-id: svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6130
parent: svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6126
committer: marko
timestamp: Mon 2009-11-02 09:42:56 +0000
message:
  branches/zip: Free all resources at shutdown. Set pointers to NULL, so
  that Valgrind will not complain about freed data structures that are
  reachable via pointers.  This addresses Bug #45992 and Bug #46656.
  
  This patch is mostly based on changes copied from branches/embedded-1.0,
  mainly c5432, c3439, c3134, c2994, c2978, but also some other code was
  copied.  Some added cleanup code is specific to MySQL/InnoDB.
  
  rb://199 approved by Sunny Bains
modified:
  ChangeLog                      2425@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2FChangeLog
  btr/btr0sea.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fbtr%2Fbtr0sea.c
  buf/buf0buf.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fbuf%2Fbuf0buf.c
  dict/dict0dict.c               2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fdict%2Fdict0dict.c
  fil/fil0fil.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Ffil%2Ffil0fil.c
  ibuf/ibuf0ibuf.c               2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fibuf%2Fibuf0ibuf.c
  include/btr0sea.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fbtr0sea.h
  include/dict0dict.h            2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fdict0dict.h
  include/fil0fil.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Ffil0fil.h
  include/ibuf0ibuf.h            2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fibuf0ibuf.h
  include/lock0lock.h            2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Flock0lock.h
  include/log0log.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Flog0log.h
  include/log0recv.h             2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Flog0recv.h
  include/mem0mem.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fmem0mem.h
  include/mem0pool.h             2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fmem0pool.h
  include/os0file.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fos0file.h
  include/pars0pars.h            2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fpars0pars.h
  include/srv0srv.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fsrv0srv.h
  include/thr0loc.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fthr0loc.h
  include/trx0i_s.h              1864@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Finclude%2Ftrx0i_s.h
  include/trx0purge.h            2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Ftrx0purge.h
  include/trx0rseg.h             2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Ftrx0rseg.h
  include/trx0sys.h              2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Ftrx0sys.h
  include/trx0undo.h             2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Ftrx0undo.h
  include/usr0sess.h             2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Finclude%2Fusr0sess.h
  lock/lock0lock.c               2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Flock%2Flock0lock.c
  log/log0log.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Flog%2Flog0log.c
  log/log0recv.c                 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Flog%2Flog0recv.c
  mem/mem0dbg.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fmem%2Fmem0dbg.c
  mem/mem0pool.c                 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fmem%2Fmem0pool.c
  os/os0file.c                   2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fos%2Fos0file.c
  os/os0sync.c                   2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fos%2Fos0sync.c
  os/os0thread.c                 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fos%2Fos0thread.c
  pars/lexyy.c                   2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fpars%2Flexyy.c
  pars/pars0lex.l                2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fpars%2Fpars0lex.l
  que/que0que.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fque%2Fque0que.c
  srv/srv0srv.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fsrv%2Fsrv0srv.c
  srv/srv0start.c                2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fsrv%2Fsrv0start.c
  sync/sync0arr.c                2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fsync%2Fsync0arr.c
  sync/sync0sync.c               2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fsync%2Fsync0sync.c
  thr/thr0loc.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fthr%2Fthr0loc.c
  trx/trx0i_s.c                  1864@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Ftrx%2Ftrx0i_s.c
  trx/trx0purge.c                2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Ftrx%2Ftrx0purge.c
  trx/trx0rseg.c                 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Ftrx%2Ftrx0rseg.c
  trx/trx0sys.c                  2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Ftrx%2Ftrx0sys.c
  trx/trx0undo.c                 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Ftrx%2Ftrx0undo.c
  usr/usr0sess.c                 2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fusr%2Fusr0sess.c
  ut/ut0mem.c                    2@16c675df-0fcb-4bc9-8058-dcc011a37293:trunk%2Fut%2Fut0mem.c
diff:
=== modified file 'ChangeLog'

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
19
 
 
20
 
#ifndef DRIZZLED_PLUGIN_CLIENT_CONCURRENT_H
21
 
#define DRIZZLED_PLUGIN_CLIENT_CONCURRENT_H
22
 
 
23
 
#include <drizzled/plugin/client.h>
24
 
#include <boost/tokenizer.hpp>
25
 
#include <vector>
26
 
#include <queue>
27
 
#include <string>
28
 
 
29
 
namespace drizzled
30
 
{
31
 
namespace plugin
32
 
{
33
 
namespace client
34
 
{
35
 
 
36
 
/**
37
 
 * This class is an empty client implementation for internal used.
38
 
 */
39
 
class Concurrent: public Client
40
 
{
41
 
  typedef std::vector<char> Bytes;
42
 
  typedef std::queue <Bytes> Queue;
43
 
  Queue to_execute;
44
 
  bool is_dead;
45
 
  Bytes packet_buffer;
46
 
 
47
 
public:
48
 
 
49
 
  Concurrent() :
50
 
    is_dead(false)
51
 
  {
52
 
  }
53
 
 
54
 
  virtual int getFileDescriptor(void) { return -1; }
55
 
  virtual bool isConnected(void) { return true; }
56
 
  virtual bool isReading(void) { return false; }
57
 
  virtual bool isWriting(void) { return false; }
58
 
  virtual bool flush(void) { return false; }
59
 
  virtual void close(void) {}
60
 
  virtual bool authenticate(void) { return true; }
61
 
 
62
 
  virtual bool readCommand(char **packet, uint32_t *packet_length)
63
 
  {
64
 
    while(not to_execute.empty())
65
 
    {
66
 
      Queue::value_type next= to_execute.front();
67
 
      packet_buffer.resize(next.size());
68
 
      memcpy(&packet_buffer[0], &next[0], next.size());
69
 
 
70
 
      *packet= &packet_buffer[0];
71
 
 
72
 
      *packet_length= next.size();
73
 
 
74
 
      to_execute.pop();
75
 
 
76
 
      return true;
77
 
    }
78
 
 
79
 
    if (not is_dead)
80
 
    {
81
 
      packet_buffer.resize(1);
82
 
      *packet_length= 1;
83
 
      *packet= &packet_buffer[0];
84
 
      is_dead= true;
85
 
 
86
 
      return true;
87
 
    }
88
 
 
89
 
    *packet_length= 0;
90
 
    return false;
91
 
  }
92
 
 
93
 
  virtual void sendOK(void) {}
94
 
  virtual void sendEOF(void) {}
95
 
  virtual void sendError(uint32_t, const char*) {}
96
 
  virtual bool sendFields(List<Item>*) { return false; }
97
 
  virtual bool store(Field *) { return false; }
98
 
  virtual bool store(void) { return false; }
99
 
  virtual bool store(int32_t) { return false; }
100
 
  virtual bool store(uint32_t) { return false; }
101
 
  virtual bool store(int64_t) { return false; }
102
 
  virtual bool store(uint64_t) { return false; }
103
 
  virtual bool store(double, uint32_t, String*) { return false; }
104
 
  virtual bool store(const DRIZZLE_TIME*) { return false; }
105
 
  virtual bool store(const char*) { return false; }
106
 
  virtual bool store(const char*, size_t) { return false; }
107
 
  virtual bool store(const std::string &) { return false; }
108
 
  virtual bool haveMoreData(void) { return false;}
109
 
  virtual bool haveError(void) { return false; }
110
 
  virtual bool wasAborted(void) { return false; }
111
 
 
112
 
  void pushSQL(const std::string &arg)
113
 
  {
114
 
    Bytes byte;
115
 
    typedef boost::tokenizer<boost::escaped_list_separator<char> > Tokenizer;
116
 
    Tokenizer tok(arg, boost::escaped_list_separator<char>("\\", ";", "\""));
117
 
 
118
 
    {
119
 
      byte.resize(sizeof("START TRANSACTION")); // +1 for the COM_QUERY, provided by null count from sizeof()
120
 
      byte[0]= COM_QUERY;
121
 
      memcpy(&byte[1], "START TRANSACTION", sizeof("START TRANSACTION") -1);
122
 
      to_execute.push(byte);
123
 
    }
124
 
 
125
 
    for (Tokenizer::iterator iter= tok.begin(); iter != tok.end(); ++iter)
126
 
    {
127
 
      byte.resize((*iter).size() +1); // +1 for the COM_QUERY
128
 
      byte[0]= COM_QUERY;
129
 
      memcpy(&byte[1], (*iter).c_str(), (*iter).size());
130
 
      to_execute.push(byte);
131
 
    }
132
 
 
133
 
    {
134
 
      byte.resize(sizeof("COMMIT")); // +1 for the COM_QUERY, provided by null count from sizeof()
135
 
      byte[0]= COM_QUERY;
136
 
      memcpy(&byte[1], "COMMIT", sizeof("COMMIT") -1);
137
 
      to_execute.push(byte);
138
 
    }
139
 
  }
140
 
};
141
 
 
142
 
} /* namespace client */
143
 
} /* namespace plugin */
144
 
} /* namespace drizzled */
145
 
 
146
 
#endif /* DRIZZLED_PLUGIN_CLIENT_CONCURRENT_H */