lg->return_value = return_value;
- if (! lm_connection_close (lg->connection, &error))
- g_print ("An error occurred during lm_connection_close: %s\n",
- error->message);
-
- lm_connection_unref (lg->connection);
+ if (lg->connection)
+ {
+ if (! lm_connection_close (lg->connection, &error))
+ {
+ g_print ("An error occurred during lm_connection_close: %s\n",
+ error->message);
+ }
+ lm_connection_unref (lg->connection);
+ lg->connection = NULL;
+ }
g_main_loop_quit (lg->main_loop);
}
loudgame_quit (lg, 1);
}
+ /* It seems to be necessary to explicitly tell the server we're
+ * still here. Let's see if one keep-alive every 60 seconds is
+ * sufficient. */
+ lm_connection_set_keep_alive_rate (lg->connection, 60);
+
/* Return false to not schedule another call. */
return 0;
}
return 0;
}
+static void
+loudgame_fini (loudgame_t *lg)
+{
+ g_main_loop_unref (lg->main_loop);
+}
+
int
loudgame_run (loudgame_t *lg)
{
g_main_loop_run (lg->main_loop);
- g_main_loop_unref (lg->main_loop);
+ loudgame_fini (lg);
return lg->return_value;
}