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
TCP connection not closed when undef'ing variable (Cyrus::IMAP::Admin) #9
Comments
For what it's worth (maybe not much), perl/imap/IMAP/Admin.pm didn't change in the repository between 2.4.17 and 2.4.18. Did FreeBSD/Ubuntu apply any patches of their own?
Could you clarify please: do you mean "cyradm on Ubuntu works the same as it did on FreeBSD", or do you mean "cyradm on Ubuntu breaks in the same way our script does on Ubuntu"? |
cyradm on our FreeBSD system drops the connection when I issue the disconnect command. In the source code, the scalar containing the object reference is set to undef. cyradm on the Ubuntu system does the same thing in source code but the connection stays around until cyradm is terminated. I guess it relies on garbage collection and/or some chain of destructors to break down everything. This seems to work on our FreeBSD system but not on our Ubuntu system. I need a way to close the connection properly in a long running process - without resorting to terminating the whole process. |
We recently moved from Cyrus 2.4.17 running on a FreeBSD system to Cyrus 2.4.18 on an Ubuntu 16.04 64bit system. We have a long running Perl script (basically a TCP server accepting administrative commands) that interfaces with
Cyrus::IMAP::Admin
. It does things similar tocyradm
. When it wants to disconnect from the IMAP server, it undef's the variable holding the object reference - in the same way ascyradm
. This works fine in the previous setup but on the new system the TCP connection doesn't close when the variable is undef'ed. Eventually, the connection moves from ESTABLISHED to CLOSE_WAIT (when the corresponding imapd process hangs up) but since theCyrus::IMAP:Admin
script never closes the connection, a lot of filehandles gets created over time. Eventually, all available FDs will be consumed and strange things will happen. The only solution is to restart the process.I have verified (using
sockstat
on FreeBSD andlsof
on Ubuntu) that the connection is closed when the variable is undef'ed on the FreeBSD system - but not on the Ubuntu system. I have also verified thatcyradm
exhibits the same behaviour on the Ubuntu system when issuing thedisconnect
command.I've been pondering different reasons for this, including how garbage collection is done in Perl and so on, but I can't find a reason.
FreeBSD:
This is perl 5, version 16, subversion 3 (v5.16.3) built for amd64-freebsd-thread-multi
Ubuntu:
This is perl 5, version 22, subversion 1 (v5.22.1) built for x86_64-linux-gnu-thread-multi
The text was updated successfully, but these errors were encountered: