Declare timeout for GNetworkMonitor calls
I've defined a lot of accounts in Evolution, which reference servers I cannot always reach (some are under VPN, some are temporarily offline). The thing is that the GTask
thread pool is limited, I've many more accounts, which want to check whether the host name is correct and whether it is reachable, but they block the normal processing (the GTask pool) until the network requests time out, which is great, except the timeout is set to something between 90 seconds to 2 minutes, I guess, which makes the application unusable during that time. It would be good to have a way to define a timeout
property on the GNetworkMonitor
instance, which will be used by the internal I/O calls. It's not that simple, I know, thus this is just a "would it make sense" request at the moment.
Example backtraces of the blocking calls without set timeouts for the network I/O
Thread 8 (Thread 0x7f47827fc6c0 (LWP 41747) "pool-evolution"):
#0 0x00007f47d1722156 in ppoll () at /lib64/libc.so.6
#1 0x00007f47b43e38f5 in fd_wait_for_event () at /lib64/libnss_resolve.so.2
#2 0x00007f47b43ebf2c in varlink_call.constprop () at /lib64/libnss_resolve.so.2
#3 0x00007f47b43ed565 in _nss_resolve_gethostbyname4_r () at /lib64/libnss_resolve.so.2
#4 0x00007f47d17173c9 in getaddrinfo () at /lib64/libc.so.6
#5 0x00007f47d4ee5c1f in do_lookup_by_name (task=0x3a134b0 [GTask], source_object=0x7f47b01c7f40, task_data=0x7f47500080d0, cancellable=0x3a175a0 [GCancellable]) at ../gio/gthreadedresolver.c:115
#6 0x00007f47d4ee0f7b in g_task_thread_pool_thread (thread_data=0x3a134b0, pool_data=0x0) at ../gio/gtask.c:1454
#7 0x00007f47d5dc0615 in g_thread_pool_thread_proxy (data=0x4e5950) at ../glib/gthreadpool.c:352
#8 0x00007f47d5dbfe71 in g_thread_proxy (data=0x7f4784005cc0) at ../glib/gthread.c:831
#9 0x00007f47d5df47aa in linux_pthread_proxy (data=0x7f4784005cc0) at ../glib/gthread-posix.c:1270
#10 0x00007f47d16ae14d in start_thread () at /lib64/libc.so.6
#11 0x00007f47d172fa00 in clone3 () at /lib64/libc.so.6
Thread 7 (Thread 0x7f47a37fe6c0 (LWP 41738) "pool-evolution"):
#0 0x00007f47d172776d in syscall () at /lib64/libc.so.6
#1 0x00007f47d5df4e0d in g_cond_wait (cond=0x7f47ac016ad0, mutex=0x7f47ac016ac8) at ../glib/gthread-posix.c:1590
#2 0x00007f47d4ee13d6 in g_task_run_in_thread_sync (task=0x7f47ac016a50 [GTask], task_func=0x7f47d4ee5b77 <do_lookup_by_name>) at ../gio/gtask.c:1621
#3 0x00007f47d4ee5fa7 in lookup_by_name (resolver=0x7f47b01c7f40 [GThreadedResolver], hostname=0x7f4794001bf0 "server.example.com", cancellable=0x0, error=0x7f47a37fd558) at ../gio/gthreadedresolver.c:195
#4 0x00007f47d4ebd586 in lookup_by_name_real (resolver=0x7f47b01c7f40 [GThreadedResolver], hostname=0x7f4794001bf0 "server.example.com", flags=G_RESOLVER_NAME_LOOKUP_FLAGS_DEFAULT, cancellable=0x0, error=0x7f47a37fd558) at ../gio/gresolver.c:480
#5 0x00007f47d4ebd5e7 in g_resolver_lookup_by_name (resolver=0x7f47b01c7f40 [GThreadedResolver], hostname=0x7f4794001bf0 "server.example.com", cancellable=0x0, error=0x7f47a37fd558) at ../gio/gresolver.c:533
#6 0x00007f47d4eac1e5 in g_network_address_address_enumerator_next (enumerator=0x7f4788002f60 [GNetworkAddressAddressEnumerator], cancellable=0x0, error=0x7f47a37fd558) at ../gio/gnetworkaddress.c:897
#7 0x00007f47d4ed1080 in g_socket_address_enumerator_next (enumerator=0x7f4788002f60 [GNetworkAddressAddressEnumerator], cancellable=0x0, error=0x7f47a37fd558) at ../gio/gsocketaddressenumerator.c:105
#8 0x00007f47d4ebaaa6 in g_proxy_address_enumerator_next (enumerator=0x7f47ac011600 [GProxyAddressEnumerator], cancellable=0x0, error=0x7f47a37fd7d8) at ../gio/gproxyaddressenumerator.c:222
#9 0x00007f47d4ed1080 in g_socket_address_enumerator_next (enumerator=0x7f47ac011600 [GProxyAddressEnumerator], cancellable=0x0, error=0x7f47a37fd7d8) at ../gio/gsocketaddressenumerator.c:105
#10 0x00007f47d4eadbd9 in g_network_monitor_base_can_reach (monitor=0x81dee0, connectable=0x7ff570, cancellable=0x0, error=0x7f47a37fd7d8) at ../gio/gnetworkmonitorbase.c:226
#11 0x00007f47d4ead0d0 in g_network_monitor_can_reach (monitor=0x81dee0, connectable=0x7ff570, cancellable=0x0, error=0x7f47a37fd7d8) at ../gio/gnetworkmonitor.c:229
#12 0x00007f47d524d177 in e_network_monitor_can_reach (monitor=0x8436e0, connectable=0x7ff570, cancellable=0x0, error=0x7f47a37fd7d8) at .../evolution-data-server/src/libedataserver/e-network-monitor.c:367
#13 0x00007f47d4ead0d0 in g_network_monitor_can_reach (monitor=0x8436e0, connectable=0x7ff570, cancellable=0x0, error=0x7f47a37fd7d8) at ../gio/gnetworkmonitor.c:229
#14 0x00007f47d5f70c76 in camel_network_service_can_reach_sync (service=0x16bea10, cancellable=0x0, error=0x0) at .../evolution-data-server/src/camel/camel-network-service.c:1033
.......
The ENetworkMonitor
is only a wrapper, which calls a GNetworkMonitor
of the user's choice (the user can pick which network monitor should be used to detect the online state).