log_manager.cc:

State update for filewriter was missing and that caused Maxscale to fail if opening of any log file failed.
dcb.c:
	Added EAGAIN and EWOULDBLOCK handling to dcb_read. If dcb_close is called for freshly created dcb, dcb is only freed.
gateway.c:
	Added file_write_footer and write_footer of which the latter is called at exit time. It simply draws a line to screen.
gw_utils.c:
	Some macros for helping comparison between gw_read_gwbuff and dcb_read, which overlap.
poll.c:
	Some macros to help enable/disable mutexing in poll_waitevents
service.c:
	Check return value of listen and session_alloc and behave accordingly.

mysql_client.c:
	If ioctl returned successfully with b==0 it earlier caused closing the client and backend dcbs. Since that doesn't reliably indicate that client has closed socket on its side, Maxscale doesn't close its sockets either.
mysql_common.c:
	In gw_receive_backend_auth, if dcb_read returns n==0, it is not considered as an error anymore. The implemented behavior is not yet complete and correct. Result should be successful but the protocol state shouldn't change to MYSQL_IDLE before backend return is received.
	In gw_send_authentication_to_backend protocol state was always set to MYSQL_AUTH_RECV even if gw_rwite had failed. Now, return value is read and state is set in caller's context basen on the return value.
skygw_utils.cc:
	Removed ss_dassert from skyge_file_init because it prevented from returning meaningful error meassage to the client.:
This commit is contained in:
vraatikka
2013-10-06 22:31:32 +03:00
parent e3a4be8b9d
commit 80b67d1083
11 changed files with 318 additions and 186 deletions

View File

@ -295,7 +295,7 @@ return_succp:
if (err != 0) { if (err != 0) {
/** This releases memory of all created objects */ /** This releases memory of all created objects */
logmanager_done_nomutex(); logmanager_done_nomutex();
fprintf(stderr, "Initializing logmanager failed.\n"); fprintf(stderr, "* Initializing logmanager failed.\n");
} }
return succp; return succp;
} }
@ -896,7 +896,7 @@ int skygw_log_enable(
bool err = 0; bool err = 0;
if (!logmanager_register(true)) { if (!logmanager_register(true)) {
fprintf(stderr, "ERROR: Can't register to logmanager\n"); //fprintf(stderr, "ERROR: Can't register to logmanager\n");
err = -1; err = -1;
goto return_err; goto return_err;
} }
@ -918,7 +918,7 @@ int skygw_log_disable(
bool err = 0; bool err = 0;
if (!logmanager_register(true)) { if (!logmanager_register(true)) {
fprintf(stderr, "ERROR: Can't register to logmanager\n"); //fprintf(stderr, "ERROR: Can't register to logmanager\n");
err = -1; err = -1;
goto return_err; goto return_err;
} }
@ -961,7 +961,7 @@ static bool logfile_set_enabled(
notused); notused);
if (err != 0) { if (err != 0) {
fprintf(stderr, fprintf(stderr,
"Writing to logfile %s failed.\n", "* Writing to logfile %s failed.\n",
STRLOGID(LOGFILE_ERROR)); STRLOGID(LOGFILE_ERROR));
} }
ss_dassert(false); ss_dassert(false);
@ -1010,7 +1010,7 @@ int skygw_log_write_flush(
size_t len; size_t len;
if (!logmanager_register(true)) { if (!logmanager_register(true)) {
fprintf(stderr, "ERROR: Can't register to logmanager\n"); //fprintf(stderr, "ERROR: Can't register to logmanager\n");
err = -1; err = -1;
goto return_err; goto return_err;
} }
@ -1063,7 +1063,7 @@ int skygw_log_write(
size_t len; size_t len;
if (!logmanager_register(true)) { if (!logmanager_register(true)) {
fprintf(stderr, "ERROR: Can't register to logmanager\n"); //fprintf(stderr, "ERROR: Can't register to logmanager\n");
err = -1; err = -1;
goto return_err; goto return_err;
} }
@ -1629,6 +1629,7 @@ static void filewriter_done(
id = (logfile_id_t)i; id = (logfile_id_t)i;
skygw_file_done(fw->fwr_file[id]); skygw_file_done(fw->fwr_file[id]);
} }
fw->fwr_state = DONE;
case DONE: case DONE:
case UNINIT: case UNINIT:
default: default:

View File

@ -210,6 +210,7 @@ dcb_add_to_zombieslist(DCB *dcb)
} }
/** /**
* Free a DCB and remove it from the chain of all DCBs * Free a DCB and remove it from the chain of all DCBs
* *
@ -221,8 +222,6 @@ dcb_add_to_zombieslist(DCB *dcb)
static void static void
dcb_final_free(DCB *dcb) dcb_final_free(DCB *dcb)
{ {
SERVICE *service;
void* rsession = NULL;
CHK_DCB(dcb); CHK_DCB(dcb);
ss_info_dassert(dcb->state == DCB_STATE_DISCONNECTED, ss_info_dassert(dcb->state == DCB_STATE_DISCONNECTED,
"dcb not in DCB_STATE_DISCONNECTED state."); "dcb not in DCB_STATE_DISCONNECTED state.");
@ -594,19 +593,20 @@ int eno = 0;
int eno = errno; int eno = errno;
errno = 0; errno = 0;
if (eno != EAGAIN && eno != EWOULDBLOCK) {
skygw_log_write_flush( skygw_log_write_flush(
LOGFILE_ERROR, LOGFILE_ERROR,
"Error : Read failed, dcb %p in state %s " "Error : Read failed, dcb %p in state "
"fd %d, due %d, %s.", "%s fd %d, due %d, %s.",
dcb, dcb,
STRDCBSTATE(dcb->state), STRDCBSTATE(dcb->state),
dcb->fd, dcb->fd,
eno, eno,
strerror(eno)); strerror(eno));
}
gwbuf_free(buffer); gwbuf_free(buffer);
goto return_n; goto return_n;
} }
skygw_log_write( skygw_log_write(
LOGFILE_TRACE, LOGFILE_TRACE,
"%lu [dcb_read] Read %d bytes from dcb %p in state %s " "%lu [dcb_read] Read %d bytes from dcb %p in state %s "
@ -638,7 +638,7 @@ int w, saved_errno = 0;
ss_dassert(queue != NULL); ss_dassert(queue != NULL);
spinlock_acquire(&dcb->writeqlock); spinlock_acquire(&dcb->writeqlock);
if (dcb->writeq) if (dcb->writeq != NULL)
{ {
/* /*
* We have some queued data, so add our data to * We have some queued data, so add our data to
@ -677,26 +677,24 @@ int w, saved_errno = 0;
if (dcb->dcb_role == DCB_ROLE_REQUEST_HANDLER && if (dcb->dcb_role == DCB_ROLE_REQUEST_HANDLER &&
dcb->session != NULL) dcb->session != NULL)
{ {
if (dcb_isclient(dcb)) { if (dcb_isclient(dcb) && fail_next_client_fd) {
if (fail_next_client_fd) {
dcb_fake_write_errno[dcb->fd] = 32; dcb_fake_write_errno[dcb->fd] = 32;
dcb_fake_write_ev[dcb->fd] = 29; dcb_fake_write_ev[dcb->fd] = 29;
fail_next_client_fd = false; fail_next_client_fd = false;
} } else if (!dcb_isclient(dcb) &&
} else { fail_next_backend_fd)
if (fail_next_backend_fd) { {
dcb_fake_write_errno[dcb->fd] = 32; dcb_fake_write_errno[dcb->fd] = 32;
dcb_fake_write_ev[dcb->fd] = 29; dcb_fake_write_ev[dcb->fd] = 29;
fail_next_backend_fd = false; fail_next_backend_fd = false;
} }
} }
}
#endif /* SS_DEBUG */ #endif /* SS_DEBUG */
len = GWBUF_LENGTH(queue); len = GWBUF_LENGTH(queue);
GW_NOINTR_CALL(w = gw_write(dcb->fd, GW_NOINTR_CALL(
GWBUF_DATA(queue), w = gw_write(dcb->fd, GWBUF_DATA(queue), len);
len); dcb->stats.n_writes++;
dcb->stats.n_writes++); );
saved_errno = errno; saved_errno = errno;
errno = 0; errno = 0;
@ -728,7 +726,6 @@ int w, saved_errno = 0;
} }
break; break;
} }
/* /*
* Pull the number of bytes we have written from * Pull the number of bytes we have written from
* queue with have. * queue with have.
@ -757,12 +754,10 @@ int w, saved_errno = 0;
{ {
skygw_log_write_flush( skygw_log_write_flush(
LOGFILE_ERROR, LOGFILE_ERROR,
"Error : Writing to dcb %p in state %s fd %d " "Error : Writing to %s socket failed due %d, %s.",
"failed.", dcb_isclient(dcb) ? "client" : "backend server",
dcb, saved_errno,
STRDCBSTATE(dcb->state), strerror(saved_errno));
dcb->fd);
/* We had a real write failure that we must deal with */
return 0; return 0;
} }
return 1; return 1;
@ -859,6 +854,16 @@ dcb_close(DCB *dcb)
int rc; int rc;
CHK_DCB(dcb); CHK_DCB(dcb);
/**
* dcb_close may be called for freshly created dcb, in which case
* it only needs to be freed.
*/
if (dcb->state == DCB_STATE_ALLOC) {
dcb_set_state(dcb, DCB_STATE_DISCONNECTED, NULL);
dcb_final_free(dcb);
return;
}
ss_dassert(dcb->state == DCB_STATE_POLLING || ss_dassert(dcb->state == DCB_STATE_POLLING ||
dcb->state == DCB_STATE_NOPOLLING || dcb->state == DCB_STATE_NOPOLLING ||
dcb->state == DCB_STATE_ZOMBIE); dcb->state == DCB_STATE_ZOMBIE);

View File

@ -98,6 +98,9 @@ static void log_flush_shutdown(void);
static void log_flush_cb(void* arg); static void log_flush_cb(void* arg);
static void libmysqld_done(void); static void libmysqld_done(void);
static bool file_write_header(FILE* outfile); static bool file_write_header(FILE* outfile);
static bool file_write_footer(FILE* outfile);
static void write_footer(void);
/** /**
* Handler for SIGHUP signal. Reload the configuration for the * Handler for SIGHUP signal. Reload the configuration for the
* gateway. * gateway.
@ -211,7 +214,28 @@ return_home:
} }
#endif #endif
static void write_footer(void)
{
file_write_footer(stdout);
}
static bool file_write_footer(
FILE* outfile)
{
bool succp = false;
size_t wbytes1;
size_t len1;
const char* header_buf1;
header_buf1 = "------------------------------------------------------"
"\n\n";
len1 = strlen(header_buf1);
wbytes1=fwrite((void*)header_buf1, len1, 1, outfile);
succp = true;
return succp;
}
static bool file_write_header( static bool file_write_header(
FILE* outfile) FILE* outfile)
{ {
@ -303,9 +327,10 @@ main(int argc, char **argv)
l = atexit(skygw_logmanager_exit); l = atexit(skygw_logmanager_exit);
if (l != 0) { if (l != 0) {
fprintf(stderr, "Couldn't register exit function.\n"); fprintf(stderr, "* Couldn't register exit function.\n");
} }
atexit(datadir_cleanup); atexit(datadir_cleanup);
atexit(write_footer);
for (n = 0; n < argc; n++) for (n = 0; n < argc; n++)
{ {
@ -327,8 +352,8 @@ main(int argc, char **argv)
skygw_log_write_flush( skygw_log_write_flush(
LOGFILE_ERROR, LOGFILE_ERROR,
"Fatal : Unable to find a MaxScale " "Fatal : Unable to find a MaxScale "
"configuration file, either install one in " "configuration file, either install one "
"/etc/MaxScale.cnf, " "in /etc/MaxScale.cnf, "
"$MAXSCALE_HOME/etc/MaxScale.cnf " "$MAXSCALE_HOME/etc/MaxScale.cnf "
"or use the -c option. Exiting."); "or use the -c option. Exiting.");
} }
@ -469,7 +494,7 @@ main(int argc, char **argv)
"file, either install one in /etc/MaxScale.cnf, " "file, either install one in /etc/MaxScale.cnf, "
"$MAXSCALE_HOME/etc/MaxScale.cnf " "$MAXSCALE_HOME/etc/MaxScale.cnf "
"or use the -c option. Exiting."); "or use the -c option. Exiting.");
fprintf(stderr, "Unable to find MaxScale configuration file. " fprintf(stderr, "* Unable to find MaxScale configuration file. "
"Exiting.\n"); "Exiting.\n");
exit(1); exit(1);
} }
@ -504,11 +529,11 @@ main(int argc, char **argv)
{ {
skygw_log_write_flush( skygw_log_write_flush(
LOGFILE_ERROR, LOGFILE_ERROR,
"Fatal : Failed to load MaxScale configuration file %s. " "Error : Failed to load MaxScale configuration file %s. "
"Exiting.", "Exiting.",
cnf_file); cnf_file);
fprintf(stderr, fprintf(stderr,
"Failed to load MaxScale configuration file. " "* Failed to load MaxScale configuration file. "
"Exiting.\n"); "Exiting.\n");
exit(1); exit(1);
} }
@ -534,7 +559,7 @@ main(int argc, char **argv)
"Fatal : Failed to start any MaxScale services. " "Fatal : Failed to start any MaxScale services. "
"Exiting."); "Exiting.");
fprintf(stderr, fprintf(stderr,
"Failed to start any MaxScale services. Exiting.\n"); "* Failed to start any MaxScale services. Exiting.\n");
exit(1); exit(1);
} }
skygw_log_write( skygw_log_write(

View File

@ -135,7 +135,9 @@ int gw_read_gwbuff(DCB *dcb, GWBUF **head, int b) {
if (b <= 0) { if (b <= 0) {
//fprintf(stderr, "||| read_gwbuff called with 0 bytes for %i, closing\n", dcb->fd); //fprintf(stderr, "||| read_gwbuff called with 0 bytes for %i, closing\n", dcb->fd);
#if 0
dcb->func.close(dcb); dcb->func.close(dcb);
#endif
return 1; return 1;
} }
@ -152,11 +154,11 @@ int gw_read_gwbuff(DCB *dcb, GWBUF **head, int b) {
if (n < 0) { if (n < 0) {
if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) { if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) {
fprintf(stderr, "Client connection %i: continue for %i, %s\n", dcb->fd, errno, strerror(errno)); /* fprintf(stderr, "Client connection %i: continue for %i, %s\n", dcb->fd, errno, strerror(errno)); */
gwbuf_free(buffer); gwbuf_free(buffer);
return 1; return 1;
} else { } else {
fprintf(stderr, "Client connection %i error: %i, %s\n", dcb->fd, errno, strerror(errno));; /* fprintf(stderr, "Client connection %i error: %i, %s\n", dcb->fd, errno, strerror(errno)); */
gwbuf_free(buffer); gwbuf_free(buffer);
(dcb->func).close(dcb); (dcb->func).close(dcb);
return 1; return 1;
@ -165,9 +167,11 @@ int gw_read_gwbuff(DCB *dcb, GWBUF **head, int b) {
if (n == 0) { if (n == 0) {
// socket closed // socket closed
fprintf(stderr, "Client connection %i closed: %i, %s\n", dcb->fd, errno, strerror(errno)); /* fprintf(stderr, "Client connection %i closed: %i, %s\n", dcb->fd, errno, strerror(errno)); */
gwbuf_free(buffer); gwbuf_free(buffer);
#if 1
(dcb->func).close(dcb); (dcb->func).close(dcb);
#endif
return 1; return 1;
} }

View File

@ -397,6 +397,7 @@ poll_waitevents(void *arg)
eno = gw_getsockerrno(dcb->fd); eno = gw_getsockerrno(dcb->fd);
if (eno == 0) { if (eno == 0) {
#if 1
simple_mutex_lock( simple_mutex_lock(
&dcb->dcb_write_lock, &dcb->dcb_write_lock,
true); true);
@ -404,11 +405,14 @@ poll_waitevents(void *arg)
!dcb->dcb_write_active, !dcb->dcb_write_active,
"Write already active"); "Write already active");
dcb->dcb_write_active = TRUE; dcb->dcb_write_active = TRUE;
#endif
atomic_add(&pollStats.n_write, 1); atomic_add(&pollStats.n_write, 1);
dcb->func.write_ready(dcb); dcb->func.write_ready(dcb);
#if 1
dcb->dcb_write_active = FALSE; dcb->dcb_write_active = FALSE;
simple_mutex_unlock( simple_mutex_unlock(
&dcb->dcb_write_lock); &dcb->dcb_write_lock);
#endif
} else { } else {
skygw_log_write( skygw_log_write(
LOGFILE_TRACE, LOGFILE_TRACE,
@ -424,12 +428,13 @@ poll_waitevents(void *arg)
} }
if (ev & EPOLLIN) if (ev & EPOLLIN)
{ {
#if 1
simple_mutex_lock(&dcb->dcb_read_lock, simple_mutex_lock(&dcb->dcb_read_lock,
true); true);
ss_info_dassert(!dcb->dcb_read_active, ss_info_dassert(!dcb->dcb_read_active,
"Read already active"); "Read already active");
dcb->dcb_read_active = TRUE; dcb->dcb_read_active = TRUE;
#endif
if (dcb->state == DCB_STATE_LISTENING) if (dcb->state == DCB_STATE_LISTENING)
{ {
skygw_log_write( skygw_log_write(
@ -454,9 +459,11 @@ poll_waitevents(void *arg)
atomic_add(&pollStats.n_read, 1); atomic_add(&pollStats.n_read, 1);
dcb->func.read(dcb); dcb->func.read(dcb);
} }
#if 1
dcb->dcb_read_active = FALSE; dcb->dcb_read_active = FALSE;
simple_mutex_unlock( simple_mutex_unlock(
&dcb->dcb_read_lock); &dcb->dcb_read_lock);
#endif
} }
} /**< for */ } /**< for */
no_op = FALSE; no_op = FALSE;

View File

@ -112,7 +112,7 @@ GWPROTOCOL *funcs;
int loaded = load_mysql_users(service); int loaded = load_mysql_users(service);
skygw_log_write( skygw_log_write(
LOGFILE_MESSAGE, LOGFILE_MESSAGE,
"MySQL Users loaded: %i.", "Loaded %d MySQL Users.",
loaded); loaded);
} }
@ -132,11 +132,26 @@ GWPROTOCOL *funcs;
memcpy(&(port->listener->func), funcs, sizeof(GWPROTOCOL)); memcpy(&(port->listener->func), funcs, sizeof(GWPROTOCOL));
port->listener->session = NULL; port->listener->session = NULL;
sprintf(config_bind, "0.0.0.0:%d", port->port); sprintf(config_bind, "0.0.0.0:%d", port->port);
if (port->listener->func.listen(port->listener, config_bind))
listeners++;
port->listener->session = session_alloc(service, port->listener);
port->listener->session->state = SESSION_STATE_LISTENER;
if (port->listener->func.listen(port->listener, config_bind)) {
port->listener->session = session_alloc(service, port->listener);
if (port->listener->session != NULL) {
port->listener->session->state = SESSION_STATE_LISTENER;
listeners += 1;
} else {
dcb_close(port->listener);
}
} else {
dcb_close(port->listener);
skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Unable to start to listen port %d for %s %s.",
port->port,
port->protocol,
service->name);
}
return listeners; return listeners;
} }

View File

@ -76,7 +76,9 @@ version()
void void
ModuleInit() ModuleInit()
{ {
skygw_log_write( LOGFILE_MESSAGE, "Initialise the MySQL Monitor module %s.\n", skygw_log_write(
LOGFILE_MESSAGE,
"Initialise the MySQL Monitor module %s.",
version_str); version_str);
} }
@ -260,7 +262,11 @@ char *sep;
sep = ""; sep = "";
while (db) while (db)
{ {
dcb_printf(dcb, "%s%s:%d", sep, db->server->name, db->server->port); dcb_printf(dcb,
"%s%s:%d",
sep,
db->server->name,
db->server->port);
sep = ", "; sep = ", ";
db = db->next; db = db->next;
} }
@ -294,8 +300,14 @@ char *uname = defaultUser, *passwd = defaultPasswd;
{ {
char *dpwd = decryptPassword(passwd); char *dpwd = decryptPassword(passwd);
database->con = mysql_init(NULL); database->con = mysql_init(NULL);
if (mysql_real_connect(database->con, database->server->name, if (mysql_real_connect(database->con,
uname, dpwd, NULL, database->server->port, NULL, 0) == NULL) database->server->name,
uname,
dpwd,
NULL,
database->server->port,
NULL,
0) == NULL)
{ {
free(dpwd); free(dpwd);
server_clear_status(database->server, SERVER_RUNNING); server_clear_status(database->server, SERVER_RUNNING);

View File

@ -181,16 +181,10 @@ static int gw_read_backend_event(DCB *dcb) {
current_session->client_sha1, current_session->client_sha1,
backend_protocol) != 0) backend_protocol) != 0)
{ {
ss_dassert(backend_protocol->state == backend_protocol->state = MYSQL_AUTH_FAILED;
MYSQL_AUTH_FAILED);
rc = 1; rc = 1;
} else { } else {
/** backend_protocol->state = MYSQL_AUTH_RECV;
* next step is to wait server's response with
* a new EPOLLIN event
*/
ss_dassert(backend_protocol->state ==
MYSQL_AUTH_RECV);
rc = 0; rc = 0;
goto return_rc; goto return_rc;
} }
@ -219,23 +213,24 @@ static int gw_read_backend_event(DCB *dcb) {
/** /**
* Read backed auth reply * Read backed auth reply
*/ */
if (!gw_receive_backend_auth(backend_protocol)) { if (gw_receive_backend_auth(backend_protocol)) {
backend_protocol->state = MYSQL_IDLE;
} else {
backend_protocol->state = MYSQL_AUTH_FAILED; backend_protocol->state = MYSQL_AUTH_FAILED;
}
}
if (backend_protocol->state == MYSQL_AUTH_FAILED) {
skygw_log_write_flush( skygw_log_write_flush(
LOGFILE_ERROR, LOGFILE_ERROR,
"%lu [gw_read_backend_event] " "%lu [gw_read_backend_event] "
"gw_receive_backend_auth failed. dcb %p fd %d, " "gw_receive_backend_auth failed. dcb "
"user %s.", "%p fd %d, user %s.",
pthread_self(), pthread_self(),
dcb, dcb,
dcb->fd, dcb->fd,
current_session->user); current_session->user);
}
}
if (backend_protocol->state == MYSQL_AUTH_FAILED) {
/* check the delayq before the reply */ /* check the delayq before the reply */
if (dcb->delayq) { if (dcb->delayq) {
/* send an error to the client */ /* send an error to the client */
@ -243,7 +238,7 @@ static int gw_read_backend_event(DCB *dcb) {
dcb->session->client, dcb->session->client,
1, 1,
0, 0,
"Connection to backend lost right now"); "Connection to backend lost.");
} }
/** /**
* Protect call of closeSession. * Protect call of closeSession.
@ -273,7 +268,7 @@ static int gw_read_backend_event(DCB *dcb) {
rc = 1; rc = 1;
goto return_rc; goto return_rc;
} else { } else {
ss_dassert(backend_protocol->state == MYSQL_AUTH_RECV); ss_dassert(backend_protocol->state == MYSQL_IDLE);
skygw_log_write_flush( skygw_log_write_flush(
LOGFILE_DEBUG, LOGFILE_DEBUG,
"%lu [gw_read_backend_event] " "%lu [gw_read_backend_event] "
@ -284,7 +279,6 @@ static int gw_read_backend_event(DCB *dcb) {
current_session->user); current_session->user);
spinlock_acquire(&dcb->authlock); spinlock_acquire(&dcb->authlock);
backend_protocol->state = MYSQL_IDLE;
/* check the delay queue and flush the data */ /* check the delay queue and flush the data */
if(dcb->delayq) { if(dcb->delayq) {
backend_write_delayqueue(dcb); backend_write_delayqueue(dcb);
@ -312,8 +306,9 @@ static int gw_read_backend_event(DCB *dcb) {
if (rc < 0) { if (rc < 0) {
/** /**
* Backend generated EPOLLIN event and if backend has failed, connection * Backend generated EPOLLIN event and if backend has
* must be closed to avoid backend dcb from getting hanged. * failed, connection must be closed to avoid backend
* dcb from getting hanged.
*/ */
(dcb->func).close(dcb); (dcb->func).close(dcb);
rc = 0; rc = 0;
@ -335,7 +330,8 @@ static int gw_read_backend_event(DCB *dcb) {
* If dcb->session->client is freed already it may be NULL. * If dcb->session->client is freed already it may be NULL.
*/ */
if (dcb->session->client != NULL) { if (dcb->session->client != NULL) {
client_protocol = SESSION_PROTOCOL(dcb->session, MySQLProtocol); client_protocol = SESSION_PROTOCOL(dcb->session,
MySQLProtocol);
} }
if (client_protocol != NULL) { if (client_protocol != NULL) {
@ -448,26 +444,28 @@ gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue)
skygw_log_write_flush( skygw_log_write_flush(
LOGFILE_ERROR, LOGFILE_ERROR,
"%lu [gw_MySQLWrite_backend] Write to backend failed. " "%lu [gw_MySQLWrite_backend] Write to backend failed. "
"Backend dcb is %s.", "Backend dcb %p fd %d is %s.",
pthread_self(), pthread_self(),
dcb,
dcb->fd,
STRDCBSTATE(dcb->state)); STRDCBSTATE(dcb->state));
return 0; return 0;
} }
spinlock_acquire(&dcb->authlock); spinlock_acquire(&dcb->authlock);
/** /**
* Now put the incoming data to the delay queue unless backend is connected with auth ok * Now put the incoming data to the delay queue unless backend is
* connected with auth ok
*/ */
if (backend_protocol->state != MYSQL_IDLE) { if (backend_protocol->state != MYSQL_IDLE) {
skygw_log_write( skygw_log_write(
LOGFILE_DEBUG, LOGFILE_DEBUG,
"%lu [gw_MySQLWrite_backend] dcb %p fd %d protocol state %s.", "%lu [gw_MySQLWrite_backend] dcb %p fd %d protocol "
"state %s.",
pthread_self(), pthread_self(),
dcb, dcb,
dcb->fd, dcb->fd,
STRPROTOCOLSTATE(backend_protocol->state)); STRPROTOCOLSTATE(backend_protocol->state));
//fprintf(stderr, ">>> Writing in the backend %i delay queue: last dcb command %i, queue command %i, protocol state [%s]\n", dcb->fd, dcb->command, queue->command, gw_mysql_protocol_state2string(dcb->state));
backend_set_delayqueue(dcb, queue); backend_set_delayqueue(dcb, queue);
spinlock_release(&dcb->authlock); spinlock_release(&dcb->authlock);
return 1; return 1;
@ -640,7 +638,7 @@ return_fd:
/** /**
* Hangup routine the backend dcb: it does nothing right now * Hangup routine the backend dcb: it does nothing
* *
* @param dcb The current Backend DCB * @param dcb The current Backend DCB
* @return 1 always * @return 1 always
@ -726,7 +724,8 @@ static int backend_write_delayqueue(DCB *dcb)
dcb->session->client, dcb->session->client,
1, 1,
0, 0,
"Closed backend connection."); "Unable to write to backend server. Connection was "
"closed.");
dcb_close(dcb); dcb_close(dcb);
} }
return rc; return rc;

View File

@ -521,7 +521,7 @@ int gw_read_client_event(DCB* dcb) {
/** /**
* Check how many bytes are readable in dcb->fd. * Check how many bytes are readable in dcb->fd.
*/ */
if (ioctl(dcb->fd, FIONREAD, &b)) { if (ioctl(dcb->fd, FIONREAD, &b) != 0) {
int eno = errno; int eno = errno;
errno = 0; errno = 0;
skygw_log_write( skygw_log_write(
@ -538,8 +538,12 @@ int gw_read_client_event(DCB* dcb) {
} }
/** /**
* The client socket was closed. * Note that earlier b==0 was translated to closed client socket.
* It may, however, happen in other cases too. Besides, if socket
* was closed, next write will tell, thus, with b==0 routine can
* simply return.
*/ */
#if 0
if (b == 0) { if (b == 0) {
skygw_log_write( skygw_log_write(
LOGFILE_TRACE, LOGFILE_TRACE,
@ -568,7 +572,12 @@ int gw_read_client_event(DCB* dcb) {
goto return_rc; goto return_rc;
} }
#else
if (b == 0) {
rc = 0;
goto return_rc;
}
#endif
switch (protocol->state) { switch (protocol->state) {
case MYSQL_AUTH_SENT: case MYSQL_AUTH_SENT:
/* /*
@ -594,7 +603,6 @@ int gw_read_client_event(DCB* dcb) {
// example with consume, assuming one buffer only ... // example with consume, assuming one buffer only ...
queue = gw_buffer; queue = gw_buffer;
len = GWBUF_LENGTH(queue); len = GWBUF_LENGTH(queue);
//fprintf(stderr, "<<< Reading from Client %i bytes: [%s]\n", len, GWBUF_DATA(queue));
auth_val = gw_mysql_do_authentication(dcb, queue); auth_val = gw_mysql_do_authentication(dcb, queue);
// Data handled withot the dcb->func.write // Data handled withot the dcb->func.write
// so consume it now // so consume it now
@ -690,7 +698,6 @@ int gw_read_client_event(DCB* dcb) {
"client dcb %p.", "client dcb %p.",
pthread_self(), pthread_self(),
dcb); dcb);
(dcb->func).close(dcb); (dcb->func).close(dcb);
} else { } else {
/* Send a custom error as MySQL command reply */ /* Send a custom error as MySQL command reply */
@ -724,7 +731,9 @@ int gw_read_client_event(DCB* dcb) {
else else
{ {
/** Route other commands to backend */ /** Route other commands to backend */
rc = router->routeQuery(router_instance, rsession, queue); rc = router->routeQuery(router_instance,
rsession,
queue);
/** succeed */ /** succeed */
if (rc == 1) { if (rc == 1) {
rc = 0; /**< here '0' means success */ rc = 0; /**< here '0' means success */
@ -1068,7 +1077,6 @@ int gw_MySQLAccept(DCB *listener)
if (protocol == NULL) { if (protocol == NULL) {
/** delete client_dcb */ /** delete client_dcb */
dcb_close(client_dcb); dcb_close(client_dcb);
skygw_log_write_flush( skygw_log_write_flush(
LOGFILE_ERROR, LOGFILE_ERROR,
"%lu [gw_MySQLAccept] Failed to create " "%lu [gw_MySQLAccept] Failed to create "
@ -1093,6 +1101,13 @@ int gw_MySQLAccept(DCB *listener)
*/ */
if (poll_add_dcb(client_dcb) == -1) if (poll_add_dcb(client_dcb) == -1)
{ {
/* Send a custom error as MySQL command reply */
mysql_send_custom_error(
client_dcb,
1,
0,
"MaxScale internal error.");
/** delete client_dcb */ /** delete client_dcb */
dcb_close(client_dcb); dcb_close(client_dcb);
@ -1161,7 +1176,6 @@ gw_client_close(DCB *dcb)
CHK_PROTOCOL(protocol); CHK_PROTOCOL(protocol);
} }
#endif #endif
dcb_close(dcb); dcb_close(dcb);
return 1; return 1;
} }

View File

@ -166,8 +166,8 @@ int gw_read_backend_handshake(MySQLProtocol *conn) {
if (h_len < (packet_len + 4)) { if (h_len < (packet_len + 4)) {
/* /*
* data in buffer less than expected in the packet * data in buffer less than expected in the
* log error this exit point * packet. Log error this exit point
*/ */
conn->state = MYSQL_AUTH_FAILED; conn->state = MYSQL_AUTH_FAILED;
return 1; return 1;
@ -177,7 +177,8 @@ int gw_read_backend_handshake(MySQLProtocol *conn) {
payload += 4; payload += 4;
//Now decode mysql handshake //Now decode mysql handshake
success = gw_decode_mysql_server_handshake(conn, payload); success = gw_decode_mysql_server_handshake(conn,
payload);
if (success < 0) { if (success < 0) {
/* MySQL handshake has not been properly decoded /* MySQL handshake has not been properly decoded
@ -308,6 +309,9 @@ bool gw_receive_backend_auth(
n = dcb_read(dcb, &head); n = dcb_read(dcb, &head);
/**
* Read didn't fail and there is enough data for mysql packet.
*/
if (n != -1 && if (n != -1 &&
head != NULL && head != NULL &&
GWBUF_LENGTH(head) >= 5) GWBUF_LENGTH(head) >= 5)
@ -318,11 +322,52 @@ bool gw_receive_backend_auth(
*/ */
if (ptr[4] == '\x00') { if (ptr[4] == '\x00') {
succp = true; succp = true;
} else {
uint8_t* tmpbuf =
(uint8_t *)calloc(1, GWBUF_LENGTH(head)+1);
memcpy(tmpbuf, ptr, GWBUF_LENGTH(head));
skygw_log_write(
LOGFILE_TRACE,
"%lu [gw_receive_backend_auth] Invalid "
"authentication message from backend dcb %p "
"fd %d, ptr[4] = %p, msg %s.",
pthread_self(),
dcb,
dcb->fd,
tmpbuf[4],
tmpbuf);
skygw_log_write_flush(
LOGFILE_ERROR,
"Error : Invalid authentication message from "
"backend server. Authentication failed.");
free(tmpbuf);
} }
/** /**
* Remove data from buffer. * Remove data from buffer.
*/ */
head = gwbuf_consume(head, gwbuf_length(head)); head = gwbuf_consume(head, gwbuf_length(head));
} else {
#if 1
/**
* This is considered as success because call didn't fail,
* although no bytes was read.
*/
if (n == 0) {
succp = true;
}
#endif
skygw_log_write(
LOGFILE_TRACE,
"%lu [gw_receive_backend_auth] Reading from backend dcb "
"%p fd %d in state %s failed. n %d, head %p, len %d",
pthread_self(),
dcb,
dcb->fd,
STRDCBSTATE(dcb->state),
n,
head,
(head == NULL) ? 0 : GWBUF_LENGTH(head));
} }
return succp; return succp;
} }
@ -506,28 +551,23 @@ int gw_send_authentication_to_backend(
payload++; payload++;
} }
memcpy(payload, "mysql_native_password", strlen("mysql_native_password")); memcpy(payload,
"mysql_native_password",
strlen("mysql_native_password"));
payload += strlen("mysql_native_password"); payload += strlen("mysql_native_password");
payload++; payload++;
// put here the paylod size: bytes to write - 4 bytes packet header // put here the paylod size: bytes to write - 4 bytes packet header
gw_mysql_set_byte3(payload_start, (bytes-4)); gw_mysql_set_byte3(payload_start, (bytes-4));
// write to backend dcb rv = dcb_write(dcb, buffer);
// ToDO: handle the EAGAIN | EWOULDBLOCK
rv = gw_write(dcb->fd, GWBUF_DATA(buffer), bytes);
gwbuf_consume(buffer, bytes); if (rv < 0) {
/* Set the new state, next would be MYSQL_IDLE or MYSQL_AUTH_FAILED */
conn->state = MYSQL_AUTH_RECV;
if (rv < 0)
return rv; return rv;
else } else {
return 0; return 0;
} }
}
/** /**
* gw_do_connect_to_backend * gw_do_connect_to_backend

View File

@ -159,7 +159,9 @@ int skygw_rwlock_rdlock(
rwlock->srw_rwlock_thr = pthread_self(); rwlock->srw_rwlock_thr = pthread_self();
} else { } else {
rwlock->srw_rwlock_thr = 0; rwlock->srw_rwlock_thr = 0;
ss_dfprintf(stderr, "pthread_rwlock_rdlock : %s\n", strerror(err)); ss_dfprintf(stderr,
"* pthread_rwlock_rdlock : %s\n",
strerror(err));
} }
return err; return err;
} }
@ -173,7 +175,9 @@ int skygw_rwlock_wrlock(
rwlock->srw_rwlock_thr = pthread_self(); rwlock->srw_rwlock_thr = pthread_self();
} else { } else {
rwlock->srw_rwlock_thr = 0; rwlock->srw_rwlock_thr = 0;
ss_dfprintf(stderr, "pthread_rwlock_wrlock : %s\n", strerror(err)); ss_dfprintf(stderr,
"* pthread_rwlock_wrlock : %s\n",
strerror(err));
} }
return err; return err;
} }
@ -186,7 +190,9 @@ int skygw_rwlock_unlock(
if (err == 0) { if (err == 0) {
rwlock->srw_rwlock_thr = 0; rwlock->srw_rwlock_thr = 0;
} else { } else {
ss_dfprintf(stderr, "pthread_rwlock_unlock : %s\n", strerror(err)); ss_dfprintf(stderr,
"* pthread_rwlock_unlock : %s\n",
strerror(err));
} }
return err; return err;
} }
@ -202,7 +208,9 @@ int skygw_rwlock_destroy(
rwlock->srw_rwlock_thr = 0; rwlock->srw_rwlock_thr = 0;
rwlock->srw_rwlock = NULL; rwlock->srw_rwlock = NULL;
} else { } else {
ss_dfprintf(stderr, "pthread_rwlock_destroy : %s\n", strerror(err)); ss_dfprintf(stderr,
"* pthread_rwlock_destroy : %s\n",
strerror(err));
} }
return err; return err;
} }
@ -221,7 +229,7 @@ int skygw_rwlock_init(
if (err != 0) { if (err != 0) {
ss_dfprintf(stderr, ss_dfprintf(stderr,
"Creating pthread_rwlock failed : %s\n", "* Creating pthread_rwlock failed : %s\n",
strerror(err)); strerror(err));
goto return_err; goto return_err;
} }
@ -299,7 +307,7 @@ mlist_t* mlist_init(
ss_dassert(list != NULL); ss_dassert(list != NULL);
if (list == NULL) { if (list == NULL) {
fprintf(stderr, "Allocating memory for mlist failed\n"); fprintf(stderr, "* Allocating memory for mlist failed\n");
mlist_free_memory(list, name); mlist_free_memory(list, name);
goto return_list; goto return_list;
} }
@ -317,7 +325,7 @@ mlist_t* mlist_init(
&list->mlist_mutex, &list->mlist_mutex,
strdup("writebuf mutex")) == NULL) strdup("writebuf mutex")) == NULL)
{ {
ss_dfprintf(stderr, "Creating rwlock for mlist failed\n"); ss_dfprintf(stderr, "* Creating rwlock for mlist failed\n");
mlist_free_memory(list, name); mlist_free_memory(list, name);
list = NULL; list = NULL;
goto return_list; goto return_list;
@ -989,7 +997,7 @@ skygw_thread_t* skygw_thread_init(
(skygw_thread_t *)calloc(1, sizeof(skygw_thread_t)); (skygw_thread_t *)calloc(1, sizeof(skygw_thread_t));
if (th == NULL) { if (th == NULL) {
fprintf(stderr, "FATAL: memory allocation for thread failed\n"); fprintf(stderr, "* Memory allocation for thread failed\n");
goto return_th; goto return_th;
} }
ss_dassert(th != NULL); ss_dassert(th != NULL);
@ -1070,13 +1078,12 @@ int skygw_thread_start(
if (err != 0) { if (err != 0) {
fprintf(stderr, fprintf(stderr,
"FATAL: starting file writer thread failed, " "* Starting file writer thread failed due error, "
"errno %d : %s\n", "%d, %s\n",
err, err,
strerror(errno)); strerror(errno));
goto return_err; goto return_err;
} }
ss_dfprintf(stderr, "Started %s thread\n", thr->sth_name);
return_err: return_err:
return err; return err;
@ -1242,8 +1249,8 @@ simple_mutex_t* simple_mutex_init(
if (err != 0) { if (err != 0) {
fprintf(stderr, fprintf(stderr,
"FATAL : initializing simple mutex %s failed, " "* Initializing simple mutex %s failed due error "
"errno %d : %s\n", "%d, %s\n",
name, name,
err, err,
strerror(errno)); strerror(errno));
@ -1260,7 +1267,6 @@ simple_mutex_t* simple_mutex_init(
} }
sm->sm_enabled = true; sm->sm_enabled = true;
CHK_SIMPLE_MUTEX(sm); CHK_SIMPLE_MUTEX(sm);
ss_dfprintf(stderr, "Initialized simple mutex %s.\n", name);
return_sm: return_sm:
return sm; return sm;
@ -1282,8 +1288,8 @@ int simple_mutex_done(
if (err != 0) { if (err != 0) {
perror("simple_mutex : "); perror("simple_mutex : ");
fprintf(stderr, fprintf(stderr,
"FATAL : destroying simple mutex %s failed, " "* Destroying simple mutex %s failed due "
"errno %d : %s\n", "%d, %s\n",
sm->sm_name, sm->sm_name,
err, err,
strerror(errno)); strerror(errno));
@ -1323,8 +1329,8 @@ int simple_mutex_lock(
if (err != 0) { if (err != 0) {
fprintf(stderr, fprintf(stderr,
"INFO : Locking simple mutex %s failed, " "* Locking simple mutex %s failed due error, "
"errno %d : %s\n", "%d, %s\n",
sm->sm_name, sm->sm_name,
err, err,
strerror(errno)); strerror(errno));
@ -1345,8 +1351,8 @@ int simple_mutex_unlock(
if (err != 0) { if (err != 0) {
fprintf(stderr, fprintf(stderr,
"INFO : locking simple mutex %s failed, " "* Locking simple mutex %s failed due error "
"errno %d : %s\n", "%d, %s\n",
sm->sm_name, sm->sm_name,
err, err,
strerror(errno)); strerror(errno));
@ -1370,8 +1376,8 @@ skygw_message_t* skygw_message_init(void)
if (err != 0) { if (err != 0) {
fprintf(stderr, fprintf(stderr,
"FATAL : initializing pthread mutex failed, " "* Initializing pthread mutex failed due error "
"errno %d : %s\n", "%d, %s\n",
err, err,
strerror(errno)); strerror(errno));
mes = NULL; mes = NULL;
@ -1381,8 +1387,8 @@ skygw_message_t* skygw_message_init(void)
if (err != 0) { if (err != 0) {
fprintf(stderr, fprintf(stderr,
"FATAL : initializing pthread cond var failed, " "* Initializing pthread cond var failed, "
"errno %d : %s\n", "due error %d, %s\n",
err, err,
strerror(errno)); strerror(errno));
mes = NULL; mes = NULL;
@ -1409,8 +1415,7 @@ void skygw_message_done(
if (err != 0) { if (err != 0) {
fprintf(stderr, fprintf(stderr,
"FATAL : destroying cond var failed, " "* Destroying cond var failed due error %d, %s\n",
"errno %d : %s\n",
err, err,
strerror(errno)); strerror(errno));
} }
@ -1419,8 +1424,8 @@ void skygw_message_done(
if (err != 0) { if (err != 0) {
fprintf(stderr, fprintf(stderr,
"FATAL : destroying pthread mutex failed, " "* Destroying pthread mutex failed, "
"errno %d : %s\n", "due error %d, %s\n",
err, err,
strerror(errno)); strerror(errno));
} }
@ -1439,8 +1444,8 @@ skygw_mes_rc_t skygw_message_send(
if (err != 0) { if (err != 0) {
fprintf(stderr, fprintf(stderr,
"INFO : Locking pthread mutex failed, " "* Locking pthread mutex failed, "
"errno %d : %s\n", "due error %d, %s\n",
err, err,
strerror(errno)); strerror(errno));
goto return_mes_rc; goto return_mes_rc;
@ -1450,8 +1455,8 @@ skygw_mes_rc_t skygw_message_send(
if (err != 0) { if (err != 0) {
fprintf(stderr, fprintf(stderr,
"INFO : Signaling pthread cond var failed, " "* Signaling pthread cond var failed, "
"errno %d : %s\n", "due error %d, %s\n",
err, err,
strerror(errno)); strerror(errno));
goto return_mes_rc; goto return_mes_rc;
@ -1460,8 +1465,8 @@ skygw_mes_rc_t skygw_message_send(
if (err != 0) { if (err != 0) {
fprintf(stderr, fprintf(stderr,
"INFO : Unlocking pthread mutex failed, " "* Unlocking pthread mutex failed, "
"errno %d : %s\n", "due error %d, %s\n",
err, err,
strerror(errno)); strerror(errno));
goto return_mes_rc; goto return_mes_rc;
@ -1482,8 +1487,8 @@ void skygw_message_wait(
if (err != 0) { if (err != 0) {
fprintf(stderr, fprintf(stderr,
"INFO : Locking pthread mutex failed, " "* Locking pthread mutex failed, "
"errno %d : %s\n", "due error %d, %s\n",
err, err,
strerror(errno)); strerror(errno));
} }
@ -1494,8 +1499,8 @@ void skygw_message_wait(
if (err != 0) { if (err != 0) {
fprintf(stderr, fprintf(stderr,
"INFO : Locking pthread cond wait failed, " "* Locking pthread cond wait failed, "
"errno %d : %s\n", "due error %d, %s\n",
err, err,
strerror(errno)); strerror(errno));
} }
@ -1505,8 +1510,8 @@ void skygw_message_wait(
if (err != 0) { if (err != 0) {
fprintf(stderr, fprintf(stderr,
"INFO : Unlocking pthread mutex failed, " "* Unlocking pthread mutex failed, "
"errno %d : %s\n", "due error %d, %s\n",
err, err,
strerror(errno)); strerror(errno));
} }
@ -1524,8 +1529,8 @@ void skygw_message_reset(
if (err != 0) { if (err != 0) {
fprintf(stderr, fprintf(stderr,
"INFO : Locking pthread mutex failed, " "* Locking pthread mutex failed, "
"errno %d : %s\n", "due error %d, %s\n",
err, err,
strerror(errno)); strerror(errno));
goto return_mes_rc; goto return_mes_rc;
@ -1536,8 +1541,8 @@ void skygw_message_reset(
if (err != 0) { if (err != 0) {
fprintf(stderr, fprintf(stderr,
"INFO : Unlocking pthread mutex failed, " "* Unlocking pthread mutex failed, "
"errno %d : %s\n", "due error %d, %s\n",
err, err,
strerror(errno)); strerror(errno));
goto return_mes_rc; goto return_mes_rc;
@ -1599,7 +1604,7 @@ static bool file_write_header(
if (wbytes1 != 1 || wbytes2 != 1 || wbytes3 != 1 || wbytes4 != 1) { if (wbytes1 != 1 || wbytes2 != 1 || wbytes3 != 1 || wbytes4 != 1) {
fprintf(stderr, fprintf(stderr,
"Writing header %s %s %s to %s failed.\n", "* Writing header %s %s %s to %s failed.\n",
header_buf1, header_buf1,
header_buf2, header_buf2,
header_buf3, header_buf3,
@ -1659,7 +1664,7 @@ static bool file_write_footer(
if (wbytes1 != 1 || wbytes3 != 1 || wbytes4 != 1) { if (wbytes1 != 1 || wbytes3 != 1 || wbytes4 != 1) {
fprintf(stderr, fprintf(stderr,
"Writing header %s %s to %s failed.\n", "* Writing header %s %s to %s failed.\n",
header_buf1, header_buf1,
header_buf3, header_buf3,
header_buf4); header_buf4);
@ -1701,7 +1706,7 @@ bool skygw_file_write(
if (nwritten != 1) { if (nwritten != 1) {
perror("Logfile write.\n"); perror("Logfile write.\n");
fprintf(stderr, fprintf(stderr,
"Writing %ld bytes, %s to %s failed.\n", "* Writing %ld bytes, %s to %s failed.\n",
nbytes, nbytes,
(char *)data, (char *)data,
file->sf_fname); file->sf_fname);
@ -1731,7 +1736,8 @@ skygw_file_t* skygw_file_init(
file = (skygw_file_t *)calloc(1, sizeof(skygw_file_t)); file = (skygw_file_t *)calloc(1, sizeof(skygw_file_t));
if (file == NULL) { if (file == NULL) {
fprintf(stderr, "Memory allocation for skygw file failed.\n"); fprintf(stderr,
"* Memory allocation for skygw file failed.\n");
perror("SkyGW file allocation\n"); perror("SkyGW file allocation\n");
} }
ss_dassert(file != NULL); ss_dassert(file != NULL);
@ -1742,8 +1748,13 @@ skygw_file_t* skygw_file_init(
file->sf_file = fopen(file->sf_fname, "a"); file->sf_file = fopen(file->sf_fname, "a");
if (file->sf_file == NULL) { if (file->sf_file == NULL) {
fprintf(stderr, "Opening file %s failed.\n", file->sf_fname); int eno = errno;
perror("SkyGW file open\n"); errno = 0;
fprintf(stderr,
"* Opening file %s failed due %d, %s.\n",
file->sf_fname,
eno,
strerror(eno));
free(file); free(file);
file = NULL; file = NULL;
goto return_file; goto return_file;
@ -1752,7 +1763,7 @@ skygw_file_t* skygw_file_init(
if (!file_write_header(file)) { if (!file_write_header(file)) {
fprintf(stderr, fprintf(stderr,
"Writing header of log file %s failed.\n", "* Writing header of log file %s failed.\n",
file->sf_fname); file->sf_fname);
perror("SkyGW file open\n"); perror("SkyGW file open\n");
free(file); free(file);
@ -1761,9 +1772,8 @@ skygw_file_t* skygw_file_init(
} }
CHK_FILE(file); CHK_FILE(file);
ss_dfprintf(stderr, "Opened %s\n", file->sf_fname); ss_dfprintf(stderr, "Opened %s\n", file->sf_fname);
return_file:
ss_dassert(file->sf_file != NULL);
return_file:
return file; return file;
} }
@ -1779,7 +1789,7 @@ void skygw_file_done(
if (!file_write_footer(file)) { if (!file_write_footer(file)) {
fprintf(stderr, fprintf(stderr,
"Writing header of log file %s failed.\n", "* Writing header of log file %s failed.\n",
file->sf_fname); file->sf_fname);
perror("SkyGW file open\n"); perror("SkyGW file open\n");
} }
@ -1790,7 +1800,7 @@ void skygw_file_done(
if (err != 0) { if (err != 0) {
fprintf(stderr, fprintf(stderr,
"Closing file %s failed : %s.\n", "* Closing file %s failed : %s.\n",
file->sf_fname, file->sf_fname,
strerror(err)); strerror(err));
} }