"Maximum number of clients reached" when running DisplayInfo::all() multiple times
mdacach opened this issue · comments
Hello, hope this message finds you well! First of all, thank you for your work. The screenshots
crate is great.
I am running into an issue on screenshots crate which I've tracked up to here. There's a link to a video showing the issue at the bottom.
The Issue
When calling DisplayInfo::all()
multiple times, the error "Maximum number of clients reached" shows up.
Possible Explanation
Each call to DisplayInfo::all()
is creating a connection to X that is not being closed. This leads to too many connections, and X refuses a new one.
Example
This is a simple script which calls DisplayInfo::all()
in a loop:
Eventually, this happens. Calls up to 178 were fine, but starting there, we have "Maximum number of clients reached".
This is a 3-minute video walking through the issue.
Unfortunately, I could not get it working. I tried adding some XCloseDisplay
calls throughout the code, but it didn't work (segfaults and whatnot). I hope the video helps, and thank you once again for your work.
Resources
Script's source code:
https://github.com/mdacach/display_info_test/tree/main
Video explaining the issue:
https://www.dropbox.com/s/qseowr2pnetre4y/display_info_issue.mp4?dl=0
Function where I think the problem is:
Line 11 in 067a7ad
Works perfectly! Thank you very much.
May I ask, out of curiosity:
1 - What was exactly the problem? I could not solve it by just adding a XCloseDisplay call (the code double-freed, I think).
2 - Where do I find documentation regarding XRR functions such as XRRFreeScreenResources
? I did not find anything on the web.
Works perfectly! Thank you very much. May I ask, out of curiosity: 1 - What was exactly the problem? I could not solve it by just adding a XCloseDisplay call (the code double-freed, I think). 2 - Where do I find documentation regarding XRR functions such as
XRRFreeScreenResources
? I did not find anything on the web.
- The problem caused by this commit, I found it would be released twice,So remove XCloseDisplay,the possible reason is that the following code releases XDisplay first.
Lines 27 to 37 in d66c699
- Official documentation: https://www.x.org/releases/X11R7.5/doc/index.html.
Thank you!