vmime icon indicating copy to clipboard operation
vmime copied to clipboard

Handler timeout not called

Open 7i77an opened this issue 10 years ago • 7 comments

Hi Vincent,

When I check account office 365, in some cases the execution never returns, i need to restart the service. I have defined a custom handler timeout and this is never called on this stack and if it is called in other circumstances correctly.

I assume that the recvfrom is a blocking action on the socket and that's why timeout handler is not called.

This is the stack of dump: #0 0x00007f472ad9c503 in recvfrom () from /lib/libpthread.so.0 #1 0x00007f4724a88b1b in ?? () from /lib/libresolv.so.2 #2 0x00007f4724a86a95 in __libc_res_nquery () from /lib/libresolv.so.2 #3 0x00007f4724a87031 in ?? () from /lib/libresolv.so.2 #4 0x00007f4724a87468 in __libc_res_nsearch () from /lib/libresolv.so.2 #5 0x00007f47163cfc27 in _nss_dns_gethostbyname4_r () from /lib/libnss_dns.so.2 #6 0x00007f4728197d9c in ?? () from /lib/libc.so.6 #7 0x00007f472819a092 in getaddrinfo () from /lib/libc.so.6 #8 0x00000000004ecccb in vmime::platforms::posix::posixSocket::connect (this=0x7f46e8e21400, address=..., port=995)

at /var/lib/jenkins/workspace/integration-build-mcwarren/sources/emailproxy/src/libvmime-master/src/vmime/platforms/posix/posixSocket.cpp:112

#9 0x000000000060c455 in vmime::net::tls::TLSSocket_OpenSSL::connect (this=0x7f46e8d78b00, address=..., port=995)

at /var/lib/jenkins/workspace/integration-build-mcwarren/sources/emailproxy/src/libvmime-master/src/vmime/net/tls/openssl/TLSSocket_OpenSSL.cpp:129

#10 0x00000000006011a1 in vmime::net::pop3::POP3Connection::connect (this=0x7f46e8cffe80)

at /var/lib/jenkins/workspace/integration-build-mcwarren/sources/emailproxy/src/libvmime-master/src/vmime/net/pop3/POP3Connection.cpp:132

#11 0x00000000005fb5b9 in vmime::net::pop3::POP3Store::connect (this=0x7f46e8d75c80)

at /var/lib/jenkins/workspace/integration-build-mcwarren/sources/emailproxy/src/libvmime-master/src/vmime/net/pop3/POP3Store.cpp:116

#12 0x0000000000443e8e in CAccount::GetStore (this=0x7f471c252d30) at ../src/Account.cpp:314 #13 0x0000000000449c6c in CAccount::CheckNewMail (this=0x7f471c252d30) at ../src/Account.cpp:729

Thanks.

7i77an avatar Jan 05 '16 19:01 7i77an

Hello!

getaddrinfo() is a blocking call, and there is no way to set a timeout or something like that. There exists a getaddrinfo_a() function which can work asynchronously, but this is GNU (glibc) specific. I think I can implement it when it is available on the system, I will keep you informed!

vincent-richard avatar Feb 28 '16 19:02 vincent-richard

Thanks Vincent!

7i77an avatar Feb 29 '16 18:02 7i77an

Hi!

The commit 194a797 implements asynchronous resolving using getaddrinfo_a() when available on the system (GNU libc). Please let me know whether it works in your case.

vincent-richard avatar Mar 02 '16 19:03 vincent-richard

Check this and inform you. Thanks a lot Vincent!

7i77an avatar Mar 02 '16 19:03 7i77an

Hi Vincent, I found a couple of issues:

  • In this commit 7d2ef73, needed change this: if (::getaddrinfo(address.c_str(), portStr, &hints, addrInfo) != 0)

portStr is a buffer, not a string object.

  • When compile static library I need add this check line:

IF(VMIME_HAVE_GETADDRINFO_A) IF(VMIME_BUILD_SHARED_LIBRARY) <= this line => TARGET_LINK_LIBRARIES( ${VMIME_LIBRARY_NAME} ${TARGET_LINK_LIBRARIES} anl ) ENDIF() ENDIF()

7i77an avatar Apr 06 '16 20:04 7i77an

Hello!

portStr is a buffer, not a string object.

Thanks, this is fixed with ac8543ac5773038b64397b1dc7c0a316936a18d8.

When compile static library I need add this check line [...] [link with anl]

On which platform did you get this issue?

vincent-richard avatar Apr 10 '16 13:04 vincent-richard

Hmmm... OK, I understood for the 'anl' lib, it's the same for all libs (pthread, iconv...), it should be linked with only when building shared lib. I fixed that in 87b052588bdd40803778f5a775a09ad7b505501a, thanks!

vincent-richard avatar Apr 10 '16 17:04 vincent-richard