Skip to content

Commit 9e3d5f1

Browse files
committed
Bug#22841977 X PLUGIN BREAKS BUILD ON ARM64 (AARCH64)
Description: On arm64 there are multiple definitions for syscalls deprecated Solution: Application instead using deprecated __NR_epoll_wait will use __NR_epoll_pwait (if its defined in unistd.h). Reviewed-by: Andrzej Religa <[email protected]> Reviewed-by: Tor Didriksen <[email protected]> RB: 11970
1 parent c90f31e commit 9e3d5f1

File tree

11 files changed

+56
-43
lines changed

11 files changed

+56
-43
lines changed

libevent/epoll_sub.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright 2003 Niels Provos <[email protected]>
3-
* All rights reserved.
2+
* Copyright 2003-2009 Niels Provos <[email protected]>
3+
* Copyright 2009-2012 Niels Provos and Nick Mathewson
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions
@@ -31,11 +31,20 @@
3131
#include <sys/syscall.h>
3232
#include <sys/epoll.h>
3333
#include <unistd.h>
34+
#include <errno.h>
3435

3536
int
3637
epoll_create(int size)
3738
{
39+
#if !defined(__NR_epoll_create) && defined(__NR_epoll_create1)
40+
if (size <= 0) {
41+
errno = EINVAL;
42+
return -1;
43+
}
44+
return (syscall(__NR_epoll_create1, 0));
45+
#else
3846
return (syscall(__NR_epoll_create, size));
47+
#endif
3948
}
4049

4150
int
@@ -48,5 +57,9 @@ epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
4857
int
4958
epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout)
5059
{
60+
#if !defined(__NR_epoll_wait) && defined(__NR_epoll_pwait)
61+
return (syscall(__NR_epoll_pwait, epfd, events, maxevents, timeout, NULL, 0));
62+
#else
5163
return (syscall(__NR_epoll_wait, epfd, events, maxevents, timeout));
52-
}
64+
#endif
65+
}

rapid/plugin/x/ngs/include/ngs/client.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ namespace ngs
146146

147147
void remove_client_from_server();
148148

149-
void handle_message(Request_unique_ptr &message);
149+
void handle_message(Request &message);
150150
virtual bool is_localhost(const char *) = 0;
151151

152152
private:

rapid/plugin/x/ngs/include/ngs/client_session.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@ namespace ngs
5858
virtual void on_auth_failure(const Authentication_handler::Response &response);
5959

6060
// handle a single message, returns true if message was handled false if not
61-
virtual bool handle_message(Request_unique_ptr &command);
61+
virtual bool handle_message(ngs::Request &command);
6262

6363
Client &client() const { return m_client; }
6464

6565
Protocol_encoder &proto() { return *m_encoder; }
6666
virtual Error_code init() = 0;
6767

6868
protected:
69-
virtual bool handle_auth_message(Request_unique_ptr &command);
70-
virtual bool handle_ready_message(Request_unique_ptr &command);
69+
virtual bool handle_auth_message(ngs::Request &command);
70+
virtual bool handle_ready_message(ngs::Request &command);
7171

7272
void stop_auth();
7373

rapid/plugin/x/ngs/include/ngs/protocol_encoder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ namespace ngs
107107

108108
virtual IProtocol_monitor &get_protocol_monitor();
109109

110-
static void log_protobuf(const char *direction_name, Request_unique_ptr &request);
110+
static void log_protobuf(const char *direction_name, Request &request);
111111
static void log_protobuf(const char *direction_name, const Message *request);
112112
static void log_protobuf(int8_t type);
113113

rapid/plugin/x/ngs/src/client.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,16 @@ void Client::set_capabilities(const Mysqlx::Connection::CapabilitiesSet &setcap)
149149
}
150150

151151

152-
void Client::handle_message(Request_unique_ptr &request)
152+
void Client::handle_message(Request &request)
153153
{
154154
log_message_recv(request);
155155

156156
Client_state expected_state = Client_accepted;
157157

158158
// there is no session before authentication, so we handle the messages ourselves
159-
log_debug("%s: Client got message %i", client_id(), request->get_type());
159+
log_debug("%s: Client got message %i", client_id(), request.get_type());
160160

161-
switch (request->get_type())
161+
switch (request.get_type())
162162
{
163163
case Mysqlx::ClientMessages::CON_CLOSE:
164164
m_encoder->send_ok("bye!");
@@ -171,11 +171,11 @@ void Client::handle_message(Request_unique_ptr &request)
171171
break;
172172

173173
case Mysqlx::ClientMessages::CON_CAPABILITIES_GET:
174-
get_capabilities(static_cast<const Mysqlx::Connection::CapabilitiesGet&>(*request->message()));
174+
get_capabilities(static_cast<const Mysqlx::Connection::CapabilitiesGet&>(*request.message()));
175175
break;
176176

177177
case Mysqlx::ClientMessages::CON_CAPABILITIES_SET:
178-
set_capabilities(static_cast<const Mysqlx::Connection::CapabilitiesSet&>(*request->message()));
178+
set_capabilities(static_cast<const Mysqlx::Connection::CapabilitiesSet&>(*request.message()));
179179
break;
180180

181181
case Mysqlx::ClientMessages::SESS_AUTHENTICATE_START:
@@ -189,15 +189,15 @@ void Client::handle_message(Request_unique_ptr &request)
189189
if (s)
190190
{
191191
// forward the message to the pre-allocated session, rest of auth will be handled by the session
192-
s->handle_message(boost::move(request));
192+
s->handle_message(request);
193193
}
194194
break;
195195
}
196196
/* no break */
197197

198198
default:
199199
// invalid message at this time
200-
log_info("%s: Invalid message %i received during client initialization", client_id(), request->get_type());
200+
log_info("%s: Invalid message %i received during client initialization", client_id(), request.get_type());
201201
m_encoder->send_result(ngs::Fatal(ER_X_BAD_MESSAGE, "Invalid message"));
202202

203203
m_close_reason = Close_error;
@@ -512,10 +512,10 @@ void Client::run(bool skip_name_resolve, struct sockaddr_in client_addr)
512512
if (m_state != Client_accepted && s)
513513
{
514514
// pass the message to the session
515-
s->handle_message(message);
515+
s->handle_message(*message);
516516
}
517517
else
518-
handle_message(message);
518+
handle_message(*message);
519519
}
520520
catch (std::exception &e)
521521
{

rapid/plugin/x/ngs/src/client_session.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void Session::on_kill()
9898

9999
// Return value means true if message was handled, false if not.
100100
// If message is handled, ownership of the object is passed on (and should be deleted by the callee)
101-
bool Session::handle_message(Request_unique_ptr &command)
101+
bool Session::handle_message(ngs::Request &command)
102102
{
103103
log_message_recv(command);
104104

@@ -116,9 +116,9 @@ bool Session::handle_message(Request_unique_ptr &command)
116116
}
117117

118118

119-
bool Session::handle_ready_message(Request_unique_ptr &command)
119+
bool Session::handle_ready_message(ngs::Request &command)
120120
{
121-
switch (command->get_type())
121+
switch (command.get_type())
122122
{
123123
case Mysqlx::ClientMessages::SESS_CLOSE:
124124
m_encoder->send_ok("bye!");
@@ -149,14 +149,14 @@ void Session::stop_auth()
149149
}
150150

151151

152-
bool Session::handle_auth_message(Request_unique_ptr &command)
152+
bool Session::handle_auth_message(ngs::Request &command)
153153
{
154154
Authentication_handler::Response r;
155-
int8_t type = command->get_type();
155+
int8_t type = command.get_type();
156156

157157
if (type == Mysqlx::ClientMessages::SESS_AUTHENTICATE_START && m_auth_handler.get() == NULL)
158158
{
159-
const Mysqlx::Session::AuthenticateStart &authm = static_cast<const Mysqlx::Session::AuthenticateStart&>(*command->message());
159+
const Mysqlx::Session::AuthenticateStart &authm = static_cast<const Mysqlx::Session::AuthenticateStart&>(*command.message());
160160

161161
log_debug("%s.%u: Login attempt: mechanism=%s auth_data=%s",
162162
m_client.client_id(), m_id, authm.mech_name().c_str(),
@@ -179,7 +179,7 @@ bool Session::handle_auth_message(Request_unique_ptr &command)
179179
}
180180
else if (type == Mysqlx::ClientMessages::SESS_AUTHENTICATE_CONTINUE && m_auth_handler.get())
181181
{
182-
const Mysqlx::Session::AuthenticateContinue &authm = static_cast<const Mysqlx::Session::AuthenticateContinue&>(*command->message());
182+
const Mysqlx::Session::AuthenticateContinue &authm = static_cast<const Mysqlx::Session::AuthenticateContinue&>(*command.message());
183183

184184
r = m_auth_handler->handle_continue(authm.auth_data());
185185
}

rapid/plugin/x/ngs/src/protocol_encoder.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,13 @@ void Protocol_encoder::on_error(int error)
237237
}
238238

239239

240-
void Protocol_encoder::log_protobuf(const char *direction_name, Request_unique_ptr &request)
240+
void Protocol_encoder::log_protobuf(const char *direction_name, Request &request)
241241
{
242-
const Message *message = request->message();
242+
const Message *message = request.message();
243243

244244
if (NULL == message)
245245
{
246-
log_protobuf(request->get_type());
246+
log_protobuf(request.get_type());
247247
return;
248248
}
249249

rapid/plugin/x/src/xpl_dispatcher.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -160,30 +160,30 @@ static ngs::Error_code do_dispatch_command(Session &session,
160160
Sql_data_context &da, ngs::Protocol_encoder &proto,
161161
Crud_command_handler &crudh, Expectation_stack &expect,
162162
Session_options &options,
163-
ngs::Request_unique_ptr &command)
163+
ngs::Request &command)
164164
{
165-
switch (command->get_type())
165+
switch (command.get_type())
166166
{
167167
case Mysqlx::ClientMessages::SQL_STMT_EXECUTE:
168-
return on_stmt_execute(session, da, options, proto, static_cast<const Mysqlx::Sql::StmtExecute&>(*command->message()));
168+
return on_stmt_execute(session, da, options, proto, static_cast<const Mysqlx::Sql::StmtExecute&>(*command.message()));
169169

170170
case Mysqlx::ClientMessages::CRUD_FIND:
171-
return crudh.execute_crud_find(proto, static_cast<const Mysqlx::Crud::Find&>(*command->message()));
171+
return crudh.execute_crud_find(proto, static_cast<const Mysqlx::Crud::Find&>(*command.message()));
172172

173173
case Mysqlx::ClientMessages::CRUD_INSERT:
174-
return crudh.execute_crud_insert(proto, static_cast<const Mysqlx::Crud::Insert&>(*command->message()));
174+
return crudh.execute_crud_insert(proto, static_cast<const Mysqlx::Crud::Insert&>(*command.message()));
175175

176176
case Mysqlx::ClientMessages::CRUD_UPDATE:
177-
return crudh.execute_crud_update(proto, static_cast<const Mysqlx::Crud::Update&>(*command->message()));
177+
return crudh.execute_crud_update(proto, static_cast<const Mysqlx::Crud::Update&>(*command.message()));
178178

179179
case Mysqlx::ClientMessages::CRUD_DELETE:
180-
return crudh.execute_crud_delete(proto, static_cast<const Mysqlx::Crud::Delete&>(*command->message()));
180+
return crudh.execute_crud_delete(proto, static_cast<const Mysqlx::Crud::Delete&>(*command.message()));
181181

182182
case Mysqlx::ClientMessages::EXPECT_OPEN:
183-
return on_expect_open(session, proto, expect, options, static_cast<const Mysqlx::Expect::Open&>(*command->message()));
183+
return on_expect_open(session, proto, expect, options, static_cast<const Mysqlx::Expect::Open&>(*command.message()));
184184

185185
case Mysqlx::ClientMessages::EXPECT_CLOSE:
186-
return on_expect_close(session, proto, expect, options, static_cast<const Mysqlx::Expect::Close&>(*command->message()));
186+
return on_expect_close(session, proto, expect, options, static_cast<const Mysqlx::Expect::Close&>(*command.message()));
187187
}
188188
return ngs::Error(ER_UNKNOWN_COM_ERROR, "Unexpected message received");
189189
}
@@ -193,15 +193,15 @@ bool dispatcher::dispatch_command(Session &session,
193193
Sql_data_context &da, ngs::Protocol_encoder &proto,
194194
Crud_command_handler &crudh, Expectation_stack &expect,
195195
Session_options &options,
196-
ngs::Request_unique_ptr command)
196+
ngs::Request &command)
197197
{
198-
ngs::Error_code error = expect.pre_client_stmt(command->get_type());
198+
ngs::Error_code error = expect.pre_client_stmt(command.get_type());
199199
if (!error)
200200
{
201201
error = do_dispatch_command(session, da, proto, crudh, expect, options, command);
202202
if (error)
203203
proto.send_result(error);
204-
expect.post_client_stmt(command->get_type(), error);
204+
expect.post_client_stmt(command.get_type(), error);
205205
}
206206
else
207207
proto.send_result(error);

rapid/plugin/x/src/xpl_dispatcher.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ namespace xpl
4343
Crud_command_handler &crudh,
4444
Expectation_stack &expect,
4545
Session_options &options,
46-
ngs::Request_unique_ptr command);
46+
ngs::Request &command);
4747
};
4848

4949
ngs::Error_code show_warnings_and_send(Sql_data_context &da, ngs::Protocol_encoder &proto);

rapid/plugin/x/src/xpl_session.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ xpl::Session::~Session()
5555

5656

5757
// handle a message while in Ready state
58-
bool xpl::Session::handle_ready_message(ngs::Request_unique_ptr &command)
58+
bool xpl::Session::handle_ready_message(ngs::Request &command)
5959
{
6060
DBUG_ASSERT(m_crud_handler != NULL);
6161

@@ -74,7 +74,7 @@ bool xpl::Session::handle_ready_message(ngs::Request_unique_ptr &command)
7474
try
7575
{
7676
return dispatcher::dispatch_command(*this, *m_sql, *m_encoder, *m_crud_handler, m_expect_stack,
77-
m_options, boost::move(command));
77+
m_options, command);
7878
}
7979
catch (ngs::Error_code &err)
8080
{

0 commit comments

Comments
 (0)