Support for stop watchdog

Add interface to stop the currently running watchdog if any.
diff --git a/bin/ipmi_example.py b/bin/ipmi_example.py
index ba13b60..f8b921e 100755
--- a/bin/ipmi_example.py
+++ b/bin/ipmi_example.py
@@ -120,8 +120,12 @@
 	elif (cmd == "statewatchdog"):
 		intf = getWatchdog()
 		intf.start()
+	elif (cmd == "stopwatchdog"):
+		intf = getWatchdog()
+		intf.stop()
 	elif (cmd == "setwatchdog"):
 		count = int(sys.argv[2])
+		intf = getWatchdog()
 		intf.set(count)
 	else:
 		print "Unsupported command"
diff --git a/objects/host_watchdog_obj.c b/objects/host_watchdog_obj.c
index e4e4bab..b1c8f2b 100644
--- a/objects/host_watchdog_obj.c
+++ b/objects/host_watchdog_obj.c
@@ -8,7 +8,7 @@
 static const gchar* dbus_name        = "org.openbmc.watchdog.Host";

 

 static GDBusObjectManagerServer *manager = NULL;

-

+static guint watchdogid = 0;

 

 static gboolean

 poll_watchdog(gpointer user_data)

@@ -21,6 +21,7 @@
 	if (count == 0)

 	{

 		//watchdog error, emit error and stop watchdog

+		watchdogid = 0;

 		watchdog_emit_watchdog_error(watchdog);

 		return FALSE;

 	}

@@ -49,7 +50,7 @@
   	watchdog_set_watchdog(wd,1);

 	guint poll_interval = watchdog_get_poll_interval(wd);

     g_print("Starting watchdog with poll interval: %d\n", poll_interval);

-  	g_timeout_add(poll_interval, poll_watchdog, user_data);

+  	watchdogid = g_timeout_add(poll_interval, poll_watchdog, user_data);

 	watchdog_complete_start(wd,invocation);

 	return TRUE;

 }

@@ -64,7 +65,22 @@
 	return TRUE;

 }

 

+static gboolean

+on_stop         (Watchdog  *wd,

+                GDBusMethodInvocation  *invocation,

+                gpointer                user_data)

+{

+    g_print("Stopping watchdog\n");

 

+    if (watchdogid)

+    {

+        g_source_remove(watchdogid);

+        watchdogid = 0;

+    }

+

+    watchdog_complete_stop(wd,invocation);

+    return TRUE;

+}

 

 static void 

 on_bus_acquired (GDBusConnection *connection,

@@ -107,6 +123,11 @@
                     object); /* user_data */

 

         g_signal_connect (wd,

+                    "handle-stop",

+                    G_CALLBACK (on_stop),

+                    object); /* user_data */

+

+        g_signal_connect (wd,

                     "handle-set",

                     G_CALLBACK (set_poll_interval),

                     object); /* user_data */