Commit graph

36 commits

Author SHA1 Message Date
Lubomir Rintel
9e6a02d7a1 build: use compat version of g_clear_pointer()
Ubuntu 12.04 has an ancient version of glib, which we nevertheless support.

(cherry picked from commit eb2b8c2798)
2015-06-18 12:11:37 +02:00
Thomas Haller
928494af2b connectivity: use default on missing connectivity.interval config
Manual page claims that a missing configuration option for connectivity
interval means "300". That was not the case for a long time (never?).

https://bugzilla.gnome.org/show_bug.cgi?id=723350

Based-on-patch-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>
(cherry picked from commit 652853e0d0)

Conflicts:
	src/nm-config-data.c
2015-05-19 15:37:14 +02:00
Thomas Haller
b18de2309a connectivity: make NMConnectivity independent of NMConfig
(cherry picked from commit ac9dd4c832)
2015-05-05 16:50:10 +02:00
Thomas Haller
a56fe5ae0c config: use NMConfigData in NMConfig
(cherry picked from commit 50fce5a860)
2015-05-05 16:49:51 +02:00
Thomas Haller
9d5b4baf36 connectivity: add logging macros to nm-connectivity.c
They add a common prefix to all logging lines.

(cherry picked from commit 3ed4aa271a)
2015-05-05 16:49:18 +02:00
Thomas Haller
b4d7ac70f2 connectivity: refactor handling parameters of NMConnectivity
Currently the three parameters for the connectivity check (uri, interval, response)
don't get reset. Soon they might be modified at any time when reloading the
configuration.

When calling the asynchronous HTTP connectivity check, we want to
preserve the original parameters so that the result callback still can
access them later. Pass the uri and response parameter on as
ConCheckCbData.

(cherry picked from commit 5ee18c124b)
2015-05-05 16:49:11 +02:00
Thomas Haller
fc6f45e42a connectivity: refactor converting connectivity states to string
(cherry picked from commit 78e3b4866a)
2015-05-05 16:49:01 +02:00
Thomas Haller
6f4bf2818a connectivity: add missing G_PARAM_CONSTRUCT for NM_CONNECTIVITY_URI property
(cherry picked from commit a79e9fdbb0)
2015-05-05 16:48:49 +02:00
Thomas Haller
da87866882 connectivity/trivial: fix white space and line-break in nm-connectivity.c
(cherry picked from commit 7aab5bc81c)
2015-05-05 16:48:40 +02:00
Thomas Haller
5929a4cbec connectivity: make NMConnectivity:dispose() reentrant
(cherry picked from commit 3dce101f6b)
2015-05-05 16:48:35 +02:00
Thomas Haller
72d06eb9c8 connectivity: add code comment to nm_connectivity_check_cb()
(cherry picked from commit 6cb5db60de)
2015-05-05 16:48:22 +02:00
Dan Williams
46c836e5cd connectivity: disable HTTP keepalive for connectivity checks
There won't be any further requests, so there's no point in keeping
the connection alive.  Even if the HTTP server doesn't care, proxy
servers in-between might keep the connection open for a couple seconds
for keepalive, and we might as well be nice to them and tell them we
don't need to keep it alive.

(cherry picked from commit 90692e3eff)
2015-03-16 10:49:36 -05:00
Lubomir Rintel
755c52758b connectivity: memleak: drop async result reference on complete
==5177== 104 (+104) bytes in 1 (+1) blocks are definitely lost in loss record 5,502 of 6,581
==5177==    at 0x4C29BCF: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==5177==    by 0x7F4A6F5: g_malloc (gmem.c:97)
==5177==    by 0x7F6159F: g_slice_alloc (gslice.c:1007)
==5177==    by 0x7F61B6D: g_slice_alloc0 (gslice.c:1032)
==5177==    by 0x7CDB9A3: g_type_create_instance (gtype.c:1847)
==5177==    by 0x7CBF356: g_object_new_internal (gobject.c:1774)
==5177==    by 0x7CC0D4C: g_object_newv (gobject.c:1922)
==5177==    by 0x7CC14E3: g_object_new (gobject.c:1614)
==5177==    by 0x79A4C57: g_simple_async_result_new (gsimpleasyncresult.c:319)
==5177==    by 0x515B34: nm_connectivity_check_async (nm-connectivity.c:289)
==5177==    by 0x515D74: run_check (nm-connectivity.c:217)
==5177==    by 0x515DBF: idle_start_periodic_checks (nm-connectivity.c:229)

(cherry picked from commit e5499c558f)

Conflicts:
	src/nm-connectivity.c
2015-02-18 18:16:27 +01:00
Thomas Haller
c6b99ef941 connectivity: fix memory leak in nm-connectivity.c
(cherry picked from commit cc12f5128c)
2015-01-29 15:04:23 +01:00
Thomas Haller
ecd7227d45 connectivity: fix compile error no WITH_CONCHECK
Fixes: 53f2642c73
(cherry picked from commit 07be0f511d)
2015-01-16 14:18:44 +01:00
Dan Winship
3d49585b37 connectivity: avoid redundant connectivity checks
Don't start an automatic connectivity check right when NMManager tells
us we're online; only do it if the manager doesn't request an explicit
connectivity check immediately afterward.

(cherry picked from commit 66b8f2b7a0)
2015-01-15 10:25:57 -05:00
Dan Winship
57249a2d05 connectivity: simplify redundant code
Merge the two nm_connectivity_set_online() calls into one, after
tweaking NMConnectivity to always update its internal state before
alerting callers to the new state.

(cherry picked from commit 0997c4b245)
2015-01-15 10:25:49 -05:00
Dan Winship
0a22ce64a6 connectivity: improve debug logging
nm-connectivity was logging both "started" and "finished" for periodic
connectivity checks, but was only logging "finished" for manual ones,
which made the logs look weird. Fix it to log both periodic and manual
starts, and differentiate them.

Also add some additional logging to indicate when set_online() is
called, and when :state changes.

(cherry picked from commit 53f2642c73)
2015-01-15 10:25:29 -05:00
Dan Winship
3bfb163a74 all: consistently include config.h
config.h should be included from every .c file, and it should be
included before any other include. Fix that.

(As a side effect of how I did this, this also changes us to
consistently use "config.h" rather than <config.h>. To the extent that
it matters [which is not much], quotes are more correct anyway, since
we're talking about a file in our own build tree, not a system
include.)
2014-11-13 17:18:42 -05:00
Dan Winship
aa1dce6da2 all: remove remaining GParamSpec name/blurb strings
Remove all remaining GParamSpec name and blurb strings (and fix
indentation while we're there), and add G_PARAM_STATIC_STRINGS to all
paramspecs that were lacking it.
2014-06-19 17:45:03 -04:00
Jiří Klimeš
f56d0c2baf trivial: nm_connectivity_check_async() returns void -> use g_return_if_fail() 2013-08-29 10:22:22 +02:00
Thomas Haller
5b449631de core: fix warning about unused variable
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-28 17:41:28 +02:00
Dan Winship
07521da591 core: provide additional network connectivity information
NM_STATE_CONNECTED_SITE doesn't distinguish between "behind a captive
portal" and "limited network connectivity" (ie, connected to a router
that has lost its upstream connection). Add a new NMManager
:connectivity property to provide this information.

Also add a CheckConnectivity method, which can be used to force NM to
re-check the connectivity state, which could be called by a client
after it completed a portal login, or fixed a network problem.
2013-08-28 10:54:08 -04:00
Dan Winship
8732914815 core: improve NMManager:state transitions with connectivity checking
The connectivity-checking code would generally result in
NMManager:state going CONNECTING -> CONNECTED_GLOBAL -> CONNECTED_SITE
in the case where the connectivity check failed. The brief incorrect
CONNECTED_GLOBAL is bad, because clients might see it and do the wrong
thing.

Instead, when we are ready to switch from CONNECTING to CONNECTED_*,
do a connectivity check first, and switch to either CONNECTED_SITE or
CONNECTED_GLOBAL based on the result of that.
2013-08-28 10:54:08 -04:00
Dan Winship
52813b48c1 core: add LOGD_CONCHECK, log unexpected concheck responses at LOGL_INFO 2013-08-28 10:54:08 -04:00
Dan Winship
91f810abfe core: build NMConnectivity unconditionally, possibly as a no-op
Build and use NMConnectivity regardless of build options; if you build
without libsoup, NMConnectivity will just always report that you have
full connectivity (like it does when you build with libsoup but don't
enable connectivity checking).
2013-08-28 10:54:08 -04:00
Dan Winship
6885da2648 core: clean up connectivity code a bit
Remove some unnecessary comments and some unnecessary code. Fix
indentation.
2013-08-28 10:54:08 -04:00
Dan Winship
4a7727d93a config: make NMConfig non-refcounted
It's a singleton that always exists. Callers shouldn't have to
refcount it.

Also, move its cleanup code from dispose() to finalize(), and remove
some unnecessary checks in it.
2013-04-03 10:23:47 -04:00
Dan Williams
875c1af2fd core: use Config object for connectivity checking parameters 2013-03-11 14:45:12 -05:00
Dan Williams
330eb2f74b core: additional connectivity checking debug messages 2012-02-27 10:56:51 -06:00
Dan Williams
5937861ca7 core: fix up connectivity state checks
We want to start the connectivity checks when any device gets
activated, and stop them when all devices get deactivated.  We
also want to make sure it's running if a device gets deactivated
but other devices are still active.  If multiple devices are
activated and if the default device gets deactivated, the other
device may become the default device and we'll need a connectivity
check for that device since we can't do per-device checks yet.

Also, if connectivity checking is enabled at compile-time but
not enabled at runtime, the connectivity bits should always
report "connected" to preserve previous behavior, and this code
makes it clearer how that is handled.
2012-02-27 10:56:51 -06:00
Dan Williams
d47072a1a1 core: clean up and simplify connectivity check
We can just use property notifications instead of having
a separate connected signal.  Also clean up some formatting
and make some private variable names shorter.
2012-02-27 10:56:51 -06:00
Dan Williams
d62f712d6e core: bound connectivity check operations with a socket timeout 2012-02-27 10:56:51 -06:00
Dan Williams
7703170673 core: connectivity check cleanups; check response headers too
Clean up some memleaks and fix some possible lifecycle issues
for strings.  Also add a short-circuit check using the HTTP
headers.
2012-02-27 10:56:51 -06:00
Dan Williams
854c2894c4 trivial: whitespace and formatting cleanups 2012-02-27 10:56:51 -06:00
Thomas Bechtold
267bc993a7 core: add internet connectivity check
* use libsoup to compare a http response from a given
  uri with a given response (use g_str_has_prefix () to compare)
* do periodically check the connectivity. Check interval is configurable
* check connectivity when device state change
  from/to NM_DEVICE_STATE_ACTIVATED
2012-02-27 10:56:51 -06:00