Skip to content

Commit f31a7a4

Browse files
committed
Remove old version 1 of the NdbWaitGroup API
This simplifies code reading & understanding for bug#20351656
1 parent 3964987 commit f31a7a4

File tree

2 files changed

+4
-94
lines changed

2 files changed

+4
-94
lines changed

storage/ndb/src/ndbapi/NdbWaitGroup.cpp

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -37,17 +37,13 @@ NdbWaitGroup::NdbWaitGroup(Ndb_cluster_connection *_conn, int ndbs) :
3737
m_multiWaitHandler(0),
3838
m_pos_overflow(0),
3939
m_nodeId(0),
40-
m_active_version(0),
4140
m_conn(_conn)
4241
{
4342
const int pointers_per_cache_line = NDB_CL / sizeof(Ndb *);
4443

4544
/* round array size up to a whole cache line */
4645
m_array_size = round_up(ndbs, pointers_per_cache_line);
4746

48-
/* m_pos is used in the version 1 api */
49-
m_pos = m_array_size;
50-
5147
/* overflow list is 1/8 of array, also rounded up */
5248
m_overflow_size = m_array_size / 8;
5349
m_overflow_size = round_up(m_overflow_size, pointers_per_cache_line);
@@ -90,52 +86,6 @@ void NdbWaitGroup::wakeup()
9086
}
9187

9288

93-
/* Old-API addNdb()
94-
*/
95-
bool NdbWaitGroup::addNdb(Ndb *ndb)
96-
{
97-
if(unlikely(ndb->theNode != Uint32(m_nodeId)))
98-
{
99-
return false; // Ndb belongs to wrong ndb_cluster_connection
100-
}
101-
102-
if(unlikely(m_pos == 0))
103-
{
104-
return false; // array is full
105-
}
106-
107-
m_array[--m_pos] = ndb;
108-
return true;
109-
}
110-
111-
112-
/* Old-API version of wait().
113-
It is single-threaded without any concurrent push().
114-
*/
115-
int NdbWaitGroup::wait(Ndb ** & arrayHead /* out */,
116-
Uint32 timeout_millis,
117-
int min_ndbs)
118-
{
119-
int nready;
120-
int nwait = m_array_size - m_pos;
121-
Ndb ** ndblist = m_array + m_pos;
122-
arrayHead = NULL;
123-
m_active_version = 1;
124-
int wait_rc = m_multiWaitHandler->waitForInput(ndblist,
125-
nwait,
126-
min_ndbs,
127-
timeout_millis,
128-
&nready);
129-
if(wait_rc == 0)
130-
{
131-
arrayHead = ndblist;
132-
m_pos += nready;
133-
return nready;
134-
}
135-
return wait_rc ? -1 : nready;
136-
}
137-
138-
13989
/* Version 2 API */
14090

14191
/*
@@ -198,14 +148,10 @@ int NdbWaitGroup::push(Ndb *ndb)
198148

199149

200150
/* wait() takes the lock before and after wait (not during).
201-
In 7.2, shifting or resizing the list requires a PollGuard,
202-
but in 7.3, the underlying wakeupHandler will only touch the
203-
array during wait() so no lock is needed.
204151
*/
205152
int NdbWaitGroup::wait(Uint32 timeout_millis, int pct_ready)
206153
{
207154
int nready, nwait;
208-
m_active_version = 2;
209155
assert(pct_ready >=0 && pct_ready <= 100);
210156

211157
lock();

storage/ndb/src/ndbapi/NdbWaitGroup.hpp

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -53,9 +53,7 @@ friend class Ndb_cluster_connection_impl;
5353

5454
/** The private constructor is used only by ndb_cluster_connection.
5555
It allocates and initializes an NdbWaitGroup with an initial array
56-
of Ndb objects.
57-
In the version 1 API, the initial size is the fixed maximum size.
58-
In the version 2 API, the array will grow as needed.
56+
of Ndb objects. The array will grow beyond the initial size as needed.
5957
*/
6058
NdbWaitGroup(Ndb_cluster_connection *conn, int initial_size);
6159

@@ -64,8 +62,6 @@ friend class Ndb_cluster_connection_impl;
6462

6563
public:
6664

67-
/****** VERSION 2 API *******/
68-
6965
/** Push an Ndb object onto the wait queue.
7066
This is thread-safe: multiple threads can call push().
7167
Returns 0 on success, non-zero on error.
@@ -99,55 +95,23 @@ friend class Ndb_cluster_connection_impl;
9995
*/
10096
Ndb * pop();
10197

102-
103-
104-
/****** COMMON API *********/
105-
10698
/** Wake up the thread that is currently waiting on this group.
10799
This can be used by other threads to signal a condition to the
108100
waiting thread.
109101
If no thread is currently waiting, then delivery is not guaranteed.
110102
*/
111103
void wakeup();
112104

113-
114-
/****** VERSION 1 API *********/
115-
116-
/** Add an Ndb object to the group.
117-
118-
Returns true on success, false on error. Error could be that the Ndb
119-
is created from the wrong Ndb_cluster_connection, or is already in the
120-
group, or that the group is full.
121-
*/
122-
bool addNdb(Ndb *);
123-
124-
/** wait for Ndbs to be ready.
125-
arrayhead (OUT): on return will hold the list of ready Ndbs.
126-
The call will return when:
127-
(a) at least min_ready Ndbs are ready for polling, or
128-
(b) timeout milliseconds have elapsed, or
129-
(c) another thread has called NdbWaitGroup::wakeup()
130-
131-
The return value is the number of Ndb objects ready for polling, or -1
132-
if a timeout occured.
133-
134-
On return, arrayHead is set to point to the first element of
135-
the array of Ndb object pointers that are ready for polling, and those
136-
objects are implicitly no longer in the group. These Ndb *'s must be
137-
read from arrayHead before before any further calls to addNdb().
138-
*/
139-
int wait(Ndb ** & arrayHead, Uint32 timeout_millis, int min_ready = 1 );
140105

141106
private: /* private instance variables */
142107
Ndb **m_array;
143-
Int32 m_pos;
144108
Uint32 m_array_size, m_pos_return;
145109
Uint32 m_pos_new, m_pos_wait, m_pos_ready;
146110

147111
MultiNdbWakeupHandler *m_multiWaitHandler;
148112
Ndb **m_overflow;
149113
Int32 m_overflow_size, m_pos_overflow;
150-
Int32 m_nodeId, m_active_version;
114+
Int32 m_nodeId;
151115

152116
Ndb_cluster_connection *m_conn;
153117
Ndb *m_wakeNdb;

0 commit comments

Comments
 (0)