session.c : session_alloc
If backend connection can't be created, backend_dcb is not create, router client session is not created and what already is created in session_alloc, is freed. mysql_client.c : gw_read_client_event If session creation failed, then - instead of sending ok to client, "failed to create new session" is sent and client dcb is closed. : gw_MySQLAccept removed loop where accept was called again and again. With single thread looping forever is not possible because there's no one to free previously allocated resources. If accept fails ten times in a row, then return without new client dcb.
This commit is contained in:
@ -422,7 +422,7 @@ bool succp = false;
|
||||
dcb->fd,
|
||||
dcb);
|
||||
conn_open[dcb->fd] = false;
|
||||
ss_debug(dcb->fd = 0;)
|
||||
ss_debug(dcb->fd = -1;)
|
||||
}
|
||||
#endif
|
||||
succp = dcb_set_state(dcb, DCB_STATE_DISCONNECTED, NULL);
|
||||
@ -494,7 +494,18 @@ int fd;
|
||||
dcb_set_state(dcb, DCB_STATE_DISCONNECTED, NULL);
|
||||
dcb_final_free(dcb);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_TRACE,
|
||||
"%lu [dcb_connect] Connected to server %s:%d, "
|
||||
"from backend dcb %p, client dcp %p fd %d\n",
|
||||
pthread_self(),
|
||||
server->name,
|
||||
server->port,
|
||||
dcb,
|
||||
session->client,
|
||||
session->client->fd);
|
||||
}
|
||||
ss_dassert(dcb->fd = -1);
|
||||
/**
|
||||
* Successfully connected to backend. Assign file descriptor to dcb
|
||||
|
||||
@ -75,7 +75,7 @@ session_alloc(SERVICE *service, DCB *client)
|
||||
pthread_self(),
|
||||
eno,
|
||||
strerror(eno));
|
||||
return NULL;
|
||||
goto return_session;
|
||||
}
|
||||
#if defined(SS_DEBUG)
|
||||
session->ses_chk_top = CHK_NUM_SESSION;
|
||||
@ -121,7 +121,19 @@ session_alloc(SERVICE *service, DCB *client)
|
||||
{
|
||||
session->router_session =
|
||||
service->router->newSession(service->router_instance, session);
|
||||
}
|
||||
|
||||
if (session->router_session == NULL) {
|
||||
client->session = NULL;
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"%lu [session_alloc] Creating router client session "
|
||||
"failed. Freeing session.",
|
||||
pthread_self());
|
||||
free(session);
|
||||
session = NULL;
|
||||
goto return_session;
|
||||
}
|
||||
}
|
||||
spinlock_acquire(&session_spin);
|
||||
session->next = allSessions;
|
||||
allSessions = session;
|
||||
@ -129,6 +141,8 @@ session_alloc(SERVICE *service, DCB *client)
|
||||
atomic_add(&service->stats.n_sessions, 1);
|
||||
atomic_add(&service->stats.n_current, 1);
|
||||
CHK_SESSION(session);
|
||||
|
||||
return_session:
|
||||
return session;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user