Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sessionPool使用的时候,session会一直增长? #274

Closed
songlong opened this issue Apr 25, 2023 · 4 comments
Closed

sessionPool使用的时候,session会一直增长? #274

songlong opened this issue Apr 25, 2023 · 4 comments

Comments

@songlong
Copy link

getIdleSession,这个地方判断,
} else if pool.activeSessions.Len() < pool.conf.maxSize {

这个地方感觉是准确的,这个时候,如果session满了,还会继续创建新的session出来的

@songlong
Copy link
Author

不准确的

@songlong
Copy link
Author

当设的最大的session个数大于host个数的时候,idleSessions会一直为0么?
那这个时候,岂不是会一直创建新的session出来?

@HarrisChu
Copy link
Contributor

func (pool *SessionPool) getSessionFromIdle() (*pureSession, error) {
	pool.rwLock.Lock()
	defer pool.rwLock.Unlock()
	// Get a session from the idle queue if possible
	if pool.idleSessions.Len() > 0 {
		session := pool.idleSessions.Front().Value.(*pureSession)
		pool.idleSessions.Remove(pool.idleSessions.Front())
		return session, nil
	} else if pool.activeSessions.Len() < pool.conf.maxSize {
		return nil, nil
	}

else mean pool.idleSessions.Len() == 0

@QingZ11
Copy link

QingZ11 commented Sep 18, 2023

@songlong hi, if your problem is solved, would you like to close the issue? Thanks a lot for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants