Skip to content

Commit

Permalink
modify code
Browse files Browse the repository at this point in the history
  • Loading branch information
TCeason committed May 19, 2022
1 parent 53ff418 commit 2139a16
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions query/src/sessions/session_mgr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,22 +158,16 @@ impl SessionManager {
));
}
}
let id = uuid::Uuid::new_v4().to_string();
let session_typ = typ.clone();
let session = Session::try_create(
config.clone(),
uuid::Uuid::new_v4().to_string(),
typ,
self.clone(),
)
.await?;

match session_typ {
SessionType::MySQL => {
let mut conn_id_session_id = self.mysql_conn_map.write();
if conn_id_session_id.len() < self.max_sessions {
conn_id_session_id.insert(session.get_mysql_conn_id(), session.get_id());
self.mysql_basic_conn_id.fetch_add(1, Ordering::Relaxed);
self.mysql_basic_conn_id.load(Ordering::Relaxed);
conn_id_session_id.insert(
Some(self.mysql_basic_conn_id.fetch_add(1, Ordering::Relaxed)),
id.clone(),
);
} else {
return Err(ErrorCode::TooManyUserConnections(
"The current accept connection has exceeded max_active_sessions config",
Expand All @@ -187,6 +181,7 @@ impl SessionManager {
);
}
}
let session = Session::try_create(config.clone(), id, typ, self.clone()).await?;

let mut sessions = self.active_sessions.write();
if sessions.len() < self.max_sessions {
Expand Down

0 comments on commit 2139a16

Please sign in to comment.