[Phonehome-commits] r97 - trunk/client/src

pamadio at garage.maemo.org pamadio at garage.maemo.org
Mon Oct 20 20:17:49 EEST 2008


Author: pamadio
Date: 2008-10-20 20:17:48 +0300 (Mon, 20 Oct 2008)
New Revision: 97

Modified:
   trunk/client/src/dsk_mgr.c
Log:
soup session leak fix

Modified: trunk/client/src/dsk_mgr.c
===================================================================
--- trunk/client/src/dsk_mgr.c	2008-10-20 17:13:53 UTC (rev 96)
+++ trunk/client/src/dsk_mgr.c	2008-10-20 17:17:48 UTC (rev 97)
@@ -118,6 +118,7 @@
     soup_session=soup_session_sync_new_with_options(SOUP_SESSION_PROXY_URI,soup_proxy_uri,NULL);
   } else {
     g_print("Automatic proxy mode not supported\n");
+    g_object_unref(soup_session);
     return FALSE;
   }
 
@@ -148,6 +149,7 @@
       g_error_free(error);
       gdk_pixbuf_unref(pixbuf);
       g_free(buffer_size);
+      g_object_unref(soup_session);
       return FALSE;
     }
   
@@ -164,6 +166,7 @@
     g_object_unref (rpc_response);
     g_free(b_encoded);
     g_object_unref(msg);
+    g_object_unref(soup_session);
     return FALSE;
   }
 
@@ -195,6 +198,7 @@
     g_object_unref (rpc_response);
     g_free(b_encoded);
     g_object_unref(msg);
+    g_object_unref(soup_session);
     return FALSE;
   }
   g_print("b\n");
@@ -207,6 +211,7 @@
     g_object_unref (rpc_response);
     g_free(b_encoded);
     g_object_unref(msg);
+    g_object_unref(soup_session);
     return FALSE;
   }
 
@@ -220,6 +225,7 @@
     g_object_unref (rpc_response);
     g_free(b_encoded);
     g_object_unref(msg);
+    g_object_unref(soup_session);
     return FALSE;
   }
 
@@ -237,18 +243,20 @@
   } else {
     g_print("Sending pic: FAILED\n");
   }
-  g_free(bo);
 
   g_print("e\n");
 
   /* Free allocated resources and return TRUE which means
    * that the operation was succesful */
+
   gdk_pixbuf_unref(pixbuf);
   g_free(buffer);
   g_free(buffer_size);
   g_object_unref (rpc_response);
   g_free(b_encoded);
   g_object_unref(msg);
+  g_free(bo);
+  g_object_unref(soup_session);
   return TRUE;
 }
 
@@ -432,6 +440,28 @@
 }
 
 
+int free_stuff_and_die(){
+  g_print("free_stuff_and_die\n");
+  save_positions_to_file();
+  g_free(xmlrpc_id);
+  g_free(xmlrpc_password);
+  g_free(xmlrpc_server);
+
+  if(http_proxy_host!=NULL){
+    g_free(http_proxy_host);
+  }
+
+  if(https_proxy_host!=NULL){
+    g_free(https_proxy_host);
+  }
+
+  if(soup_proxy_uri_string!=NULL){
+    g_free(soup_proxy_uri_string);
+    soup_uri_free (soup_proxy_uri);
+  }
+  syslog(LOG_INFO, "%s daemon exiting", DAEMON_NAME);
+  exit(EXIT_SUCCESS);
+}
  
 void signal_handler(int sig) {
  
@@ -441,12 +471,10 @@
     break;
   case SIGTERM:
     syslog(LOG_WARNING, "Received SIGTERM signal.");
-    save_positions_to_file();
-    exit(EXIT_SUCCESS);
+    free_stuff_and_die();
     
   case SIGINT:
-    save_positions_to_file();
-    exit(EXIT_SUCCESS);
+    free_stuff_and_die();
   default:
     syslog(LOG_WARNING, "Unhandled signal: %d", sig);
     break;
@@ -743,8 +771,8 @@
       //g_slist_foreach(gps_positions, show_locations, NULL);
       //g_print("___\n");
       new_head=next_head;
-
       g_object_unref(msg);
+      g_object_unref(soup_session);
     }
 
 }
@@ -791,6 +819,7 @@
   g_print("rpc_status=%i\n",rpc_status);
   if(rpc_status!=200){
     g_print("Problem with XMLRPC communication\n");
+    g_object_unref(soup_session);
     return FALSE;
   }
 
@@ -798,6 +827,7 @@
   if (!rpc_response) {
     g_print("Could not parse XMLRPC response\n");
     g_object_unref(msg);
+    g_object_unref(soup_session);
     return FALSE;
   }
 
@@ -805,6 +835,7 @@
   if (!value) {
     g_print("No response value in XMLRPC response\n");
     g_object_unref(msg);
+    g_object_unref(soup_session);
     return FALSE;
   }
   
@@ -815,10 +846,12 @@
 
   if(*b==TRUE){
     g_print("OK\n");
+    g_object_unref(soup_session);
     g_free(b);
     return TRUE;
   } else {
     g_print("NOPE\n");
+    g_object_unref(soup_session);
     g_free(b);
     return FALSE;
   }
@@ -954,10 +987,17 @@
   //static double cnt=1;
   g_print("my timeout\n");
   g_print("id=%s password=%s server=%s\n",xmlrpc_id,xmlrpc_password,xmlrpc_server);
+  
   //GMainLoop *mloop=(GMainLoop *) loop;
 
-  //g_main_loop_quit (mloop);
 
+  if(test_xmlrpc_login()==TRUE) {
+    g_print("login ok\n");
+  }else{
+    g_print("login not ok\n");
+  }
+  g_print("goodbye\n");
+  g_main_loop_quit (loop);
   //return FALSE;
   return TRUE;
 }
@@ -1131,11 +1171,8 @@
 
   gst_object_unref(GST_OBJECT(pipeline));
   free(system_dbus);
-  g_free(xmlrpc_id);
-  g_free(xmlrpc_password);
-  g_free(xmlrpc_server);
-  syslog(LOG_INFO, "%s daemon exiting", DAEMON_NAME);
-  exit(EXIT_SUCCESS);
+  exit(free_stuff_and_die());
+
 }
 
 



More information about the Phonehome-commits mailing list