Merge branch 'develop' into MAX-324

Conflicts:
	server/core/modutil.c
This commit is contained in:
Markus Makela
2015-01-20 04:25:40 +02:00
133 changed files with 1119 additions and 4527 deletions

View File

@ -1,91 +0,0 @@
# This file is distributed as part of the MariaDB Corporation MaxScale. It is free
# software: you can redistribute it and/or modify it under the terms of the
# GNU General Public License as published by the Free Software Foundation,
# version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Copyright MariaDB Corporation Ab 2013
#
# Revision History
# Date Who Description
# 13/06/2013 Mark Riddoch Initial protocol module development
# 17/06/2013 Massimiliano Pinto Added mysql_common top both libraries
# 27/06/2013 Vilho Raatikka Added logmanager-related libs and
# headers so that liblog_manager.so can
# be linked in.
# 09/07/2013 Massimiliano Pinto Added the HTTPD protocol module
# 13/06/2014 Mark Riddoch Added thr MaxScale protocol module
#
include ../../../build_gateway.inc
LOGPATH := $(ROOT_PATH)/log_manager
UTILSPATH := $(ROOT_PATH)/utils
CC=cc
CFLAGS=-c -fPIC -I/usr/include -I../include -I../../include -I$(LOGPATH) \
-I$(UTILSPATH) -Wall -g
include ../../../makefile.inc
LDFLAGS=-shared -L$(LOGPATH) -Wl,-rpath,$(DEST)/lib \
-Wl,-rpath,$(LOGPATH) -Wl,-rpath,$(UTILSPATH)
MYSQLCLIENTSRCS=mysql_client.c mysql_common.c
MYSQLCLIENTOBJ=$(MYSQLCLIENTSRCS:.c=.o)
MYSQLBACKENDSRCS=mysql_backend.c mysql_common.c
MYSQLBACKENDOBJ=$(MYSQLBACKENDSRCS:.c=.o)
TELNETDSRCS=telnetd.c
TELNETDOBJ=$(TELNETDSRCS:.c=.o)
HTTPDSRCS=httpd.c
HTTPDOBJ=$(HTTPDSRCS:.c=.o)
MAXSCALEDSRCS=maxscaled.c
MAXSCALEDOBJ=$(MAXSCALEDSRCS:.c=.o)
SRCS=$(MYSQLCLIENTSRCS) $(MYSQLBACKENDSRCS) $(TELNETDSRCS) $(HTTPDSRCS) \
$(MAXSCALEDSRCS)
OBJ=$(SRCS:.c=.o)
LIBS=$(UTILSPATH)/skygw_utils.o
MODULES=libMySQLClient.so libMySQLBackend.so libtelnetd.so libHTTPD.so \
libmaxscaled.so
all: $(MODULES)
libMySQLClient.so: $(MYSQLCLIENTOBJ)
$(CC) $(LDFLAGS) $(MYSQLCLIENTOBJ) $(LIBS) -o $@
libMySQLBackend.so: $(MYSQLBACKENDOBJ)
$(CC) $(LDFLAGS) $(MYSQLBACKENDOBJ) $(LIBS) -o $@
libtelnetd.so: $(TELNETDOBJ)
$(CC) $(LDFLAGS) $(TELNETDOBJ) $(LIBS) -lcrypt -o $@
libHTTPD.so: $(HTTPDOBJ)
$(CC) $(LDFLAGS) $(HTTPDOBJ) $(LIBS) -o $@
libmaxscaled.so: $(MAXSCALEDOBJ)
$(CC) $(LDFLAGS) $(MAXSCALEDOBJ) $(LIBS) -lcrypt -o $@
.c.o:
$(CC) $(CFLAGS) $< -o $@
clean:
$(DEL) $(OBJ) $(MODULES)
tags:
ctags $(SRCS) $(HDRS)
install: $(MODULES)
install -D $(MODULES) $(DEST)/modules
depend:
@$(DEL) depend.mk
cc -M $(CFLAGS) $(SRCS) > depend.mk
include depend.mk

View File

@ -357,8 +357,7 @@ static int gw_read_backend_event(DCB *dcb) {
dcb->delayq,
GWBUF_LENGTH(dcb->delayq))) != NULL);
}
spinlock_release(&dcb->delayqlock);
spinlock_release(&dcb->delayqlock);
{
GWBUF* errbuf;
bool succp;
@ -1452,25 +1451,13 @@ static int gw_change_user(
rv = 0;
goto retblock;
}
/** TODO: Add custom message indicating that retry would probably help */
buf = modutil_create_mysql_err_msg(1, 0, 1045, "28000", message);
free(message);
if (buf == NULL)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Creating buffer for error message failed.")));
rv = 0;
goto retblock;
}
/** Set flags that help router to identify session commans reply */
gwbuf_set_type(buf, GWBUF_TYPE_MYSQL);
gwbuf_set_type(buf, GWBUF_TYPE_SESCMD_RESPONSE);
gwbuf_set_type(buf, GWBUF_TYPE_RESPONSE_END);
/** Create an incoming event for backend DCB */
poll_add_epollin_event_to_dcb(backend, gwbuf_clone(buf));
gwbuf_free(buf);
/**
* Add command to backend's protocol, create artificial reply
* packet and add it to client's read buffer.
*/
protocol_add_srv_command((MySQLProtocol*)backend->protocol,
MYSQL_COM_CHANGE_USER);
modutil_reply_auth_error(backend, message, 0);
rv = 1;
} else {
rv = gw_send_change_user_to_backend(database, username, client_sha1, backend_protocol);

View File

@ -759,7 +759,7 @@ int gw_read_client_event(
* else : write custom error to client dcb.
*/
if(rsession == NULL)
{
{
/** COM_QUIT */
if (MYSQL_IS_COM_QUIT(payload))
{
@ -776,7 +776,7 @@ int gw_read_client_event(
*/
dcb_close(dcb);
}
else
else
{
#if defined(SS_DEBUG)
LOGIF(LE, (skygw_log_write_flush(
@ -843,6 +843,8 @@ int gw_read_client_event(
}
else
{
router->handleError(NULL, NULL, NULL, dcb, ERRACT_RESET, NULL);
if (stmt_input)
{
/**
@ -863,25 +865,48 @@ int gw_read_client_event(
rc = SESSION_ROUTE_QUERY(session, read_buffer);
}
/** succeed */
/** Routing succeed */
if (rc)
{
rc = 0; /**< here '0' means success */
}
else
{
modutil_send_mysql_err_packet(dcb,
1,
0,
2003,
"HY000",
"Write to backend failed. Session closed.");
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Routing the query failed. "
"Session will be closed.")));
bool succp;
GWBUF* errbuf;
/**
* Create error to be sent to client if session
* can't be continued.
*/
errbuf = mysql_create_custom_error(
1,
0,
"Routing failed. Session is closed.");
/**
* Ensure that there are enough backends
* available.
*/
router->handleError(
router_instance,
session->router_session,
errbuf,
dcb,
ERRACT_NEW_CONNECTION,
&succp);
free(errbuf);
/**
* If there are not enough backends close
* session
*/
if (!succp)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Routing the query failed. "
"Session will be closed.")));
dcb_close(dcb);
dcb_close(dcb);
}
}
}
goto return_rc;
@ -1553,7 +1578,7 @@ static int route_by_statement(
goto return_rc;
}
}
while (*p_readbuf != NULL);
while (rc == 1 && *p_readbuf != NULL);
return_rc:
return rc;