~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table/concurrent.cc

  • Committer: Brian Aker
  • Date: 2010-11-08 17:40:41 UTC
  • mto: (1921.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 1916.
  • Revision ID: brian@tangent.org-20101108174041-owap774v8l5vvnl4
Push some functions behind classes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include "plugin/myisam/myisam.h"
29
29
#include "drizzled/plugin/transactional_storage_engine.h"
30
30
 
31
 
#include <drizzled/table/instance.h>
32
 
 
33
31
#include "drizzled/table.h"
34
32
 
35
33
namespace drizzled
54
52
  pointer.
55
53
 
56
54
  NOTE
57
 
  This function assumes that its caller already acquired table::Cache::singleton().mutex() mutex.
 
55
  This function assumes that its caller already acquired LOCK_open mutex.
58
56
 
59
57
  RETURN VALUE
60
58
  false - Success
63
61
 
64
62
bool Concurrent::reopen_name_locked_table(TableList* table_list, Session *session)
65
63
{
66
 
  safe_mutex_assert_owner(table::Cache::singleton().mutex().native_handle());
 
64
  safe_mutex_assert_owner(LOCK_open.native_handle());
67
65
 
68
 
  if (session->getKilled())
 
66
  if (session->killed)
69
67
    return true;
70
68
 
71
 
  identifier::Table identifier(table_list->getSchemaName(), table_list->getTableName());
 
69
  TableIdentifier identifier(table_list->getSchemaName(), table_list->getTableName());
72
70
  if (open_unireg_entry(session, table_list->getTableName(), identifier))
73
71
  {
74
72
    intern_close_table();
112
110
 
113
111
  NOTES
114
112
  Extra argument for open is taken from session->open_options
115
 
  One must have a lock on table::Cache::singleton().mutex() when calling this function
 
113
  One must have a lock on LOCK_open when calling this function
116
114
 
117
115
  RETURN
118
116
  0     ok
121
119
 
122
120
int table::Concurrent::open_unireg_entry(Session *session,
123
121
                                         const char *alias,
124
 
                                         identifier::Table &identifier)
 
122
                                         TableIdentifier &identifier)
125
123
{
126
124
  int error;
127
 
  TableShare::shared_ptr share;
 
125
  TableSharePtr share;
128
126
  uint32_t discover_retry_count= 0;
129
127
 
130
 
  safe_mutex_assert_owner(table::Cache::singleton().mutex().native_handle());
 
128
  safe_mutex_assert_owner(LOCK_open.native_handle());
131
129
retry:
132
 
  if (not (share= table::instance::Shared::make_shared(session,
133
 
                                                       identifier,
134
 
                                                       error)))
135
 
  {
 
130
  if (not (share= TableShare::getShareCreate(session,
 
131
                                             identifier,
 
132
                                             &error)))
136
133
    return 1;
137
 
  }
138
134
 
139
135
  while ((error= share->open_table_from_share(session,
140
136
                                              identifier,
150
146
      share->resetVersion();                        // Mark share as old
151
147
      if (discover_retry_count++)               // Retry once
152
148
      {
153
 
        table::instance::release(share);
 
149
        TableShare::release(share);
154
150
        return 1;
155
151
      }
156
152
 
175
171
      */
176
172
      if (share->getTableCount() != 1)
177
173
      {
178
 
        table::instance::release(share);
 
174
        TableShare::release(share);
179
175
        return 1;
180
176
      }
181
 
 
182
177
      /* Free share and wait until it's released by all threads */
183
 
      table::instance::release(share);
 
178
      TableShare::release(share);
184
179
 
185
 
      if (not session->getKilled())
 
180
      if (!session->killed)
186
181
      {
187
182
        drizzle_reset_errors(session, 1);         // Clear warnings
188
183
        session->clear_error();                 // Clear error message
189
184
        goto retry;
190
185
      }
191
 
 
192
186
      return 1;
193
187
    }
194
188
 
195
 
    table::instance::release(share);
 
189
    TableShare::release(share);
196
190
 
197
191
    return 1;
198
192
  }
208
202
  // delete if this happens.
209
203
  if (getShare()->getType() == message::Table::STANDARD)
210
204
  {
211
 
    table::instance::release(getMutableShare());
 
205
    TableShare::release(getMutableShare());
212
206
  }
213
207
  else
214
208
  {