Skip to content

test: make sure that underlying connection is closed #49

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

Merged
merged 1 commit into from
Nov 19, 2020

Conversation

romanhabibov
Copy link
Contributor

Closes #31

Copy link
Contributor

@LeonidVas LeonidVas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HI! Thank you for the patch.

I suggest using in title something like:" test: add test for ...".

Add Closes #31

AFAIU, you save the descriptor, close it and expect the same descriptor will be used for a connection. This is a good hypothesis, but please add a comment to your hypothesis. Also, I'm expecting some links to prove your hypothesis (if possible).
Is this only true for linux or other OS too? Will such test work on MacOS, WSL, WSL2? Maybe run this test on Linux only?

@romanhabibov romanhabibov force-pushed the romanhabibov/test-underlying branch from cedb080 to 4563da5 Compare November 11, 2020 21:42
@romanhabibov
Copy link
Contributor Author

HI! Thank you for the patch.

I suggest using in title something like:" test: add test for ...".

Add Closes #31

AFAIU, you save the descriptor, close it and expect the same descriptor will be used for a connection. This is a good hypothesis, but please add a comment to your hypothesis. Also, I'm expecting some links to prove your hypothesis (if possible).
Is this only true for linux or other OS too? Will such test work on MacOS, WSL, WSL2? Maybe run this test on Linux only?

I couldn't find any directly obvious proof, but let me try. Basing on the statement, that file descriptors are recycled in ascending order. It means, that if we call open() and immediately close(), we get the first vacant index for a new resource in the file descriptor table. It is important not to call any procedures between open() and close() that may affect the file descriptor table. After that, we immediately create connection, which creates a socket. Socket is a resource, which occupies the first vacant index in the file descriptor table.

https://sites.ualberta.ca/dept/chemeng/AIX-43/share/man/info/C/a_doc_lib/aixprggd/genprogc/fdescript.htm

@romanhabibov romanhabibov force-pushed the romanhabibov/test-underlying branch from 4563da5 to cababcf Compare November 12, 2020 10:39
@Totktonada
Copy link
Member

@romanhabibov romanhabibov force-pushed the romanhabibov/test-underlying branch from cababcf to a0fcdf4 Compare November 16, 2020 13:19
@LeonidVas
Copy link
Contributor

HI! Thank you for the patch.
I suggest using in title something like:" test: add test for ...".
Add Closes #31
AFAIU, you save the descriptor, close it and expect the same descriptor will be used for a connection. This is a good hypothesis, but please add a comment to your hypothesis. Also, I'm expecting some links to prove your hypothesis (if possible).
Is this only true for linux or other OS too? Will such test work on MacOS, WSL, WSL2? Maybe run this test on Linux only?

I couldn't find any directly obvious proof, but let me try. Basing on the statement, that file descriptors are recycled in ascending order. It means, that if we call open() and immediately close(), we get the first vacant index for a new resource in the file descriptor table. It is important not to call any procedures between open() and close() that may affect the file descriptor table. After that, we immediately create connection, which creates a socket. Socket is a resource, which occupies the first vacant index in the file descriptor table.

https://sites.ualberta.ca/dept/chemeng/AIX-43/share/man/info/C/a_doc_lib/aixprggd/genprogc/fdescript.htm

Alexander found confirmation. Please add this as a comment to your code with describing how the test works.

@romanhabibov romanhabibov force-pushed the romanhabibov/test-underlying branch from a0fcdf4 to 546c352 Compare November 17, 2020 17:50
@romanhabibov
Copy link
Contributor Author

HI! Thank you for the patch.
I suggest using in title something like:" test: add test for ...".
Add Closes #31
AFAIU, you save the descriptor, close it and expect the same descriptor will be used for a connection. This is a good hypothesis, but please add a comment to your hypothesis. Also, I'm expecting some links to prove your hypothesis (if possible).
Is this only true for linux or other OS too? Will such test work on MacOS, WSL, WSL2? Maybe run this test on Linux only?

I couldn't find any directly obvious proof, but let me try. Basing on the statement, that file descriptors are recycled in ascending order. It means, that if we call open() and immediately close(), we get the first vacant index for a new resource in the file descriptor table. It is important not to call any procedures between open() and close() that may affect the file descriptor table. After that, we immediately create connection, which creates a socket. Socket is a resource, which occupies the first vacant index in the file descriptor table.
https://sites.ualberta.ca/dept/chemeng/AIX-43/share/man/info/C/a_doc_lib/aixprggd/genprogc/fdescript.htm

Alexander found confirmation. Please add this as a comment to your code with describing how the test works.

Done.

@romanhabibov romanhabibov force-pushed the romanhabibov/test-underlying branch from 546c352 to 48753a3 Compare November 18, 2020 23:08
Copy link
Contributor

@LeonidVas LeonidVas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Member

@Totktonada Totktonada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@LeonidVas LeonidVas merged commit 8301898 into master Nov 19, 2020
@LeonidVas LeonidVas deleted the romanhabibov/test-underlying branch November 19, 2020 08:19
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

Successfully merging this pull request may close these issues.

Destroy lost connection objects acquired from mysql.connect()
3 participants