~ubuntu-branches/ubuntu/precise/gconf/precise

« back to all changes in this revision

Viewing changes to .pc/01_defaults_path.patch/gconf/gconfd.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2012-03-08 21:38:45 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20120308213845-p1fy2zco3swr9vd9
Tags: 3.2.4-0ubuntu1
New upstream version

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
 
66
66
#include <dbus/dbus-glib-lowlevel.h>
67
67
 
 
68
static void logfile_remove (void);
 
69
 
68
70
#ifdef G_OS_WIN32
69
71
#include <io.h>
70
72
#include <conio.h>
174
176
 */
175
177
static gboolean need_db_reload = FALSE;
176
178
 
 
179
/*
 
180
 * Flag indicating whether to prepare for respawn or logout
 
181
 * when exiting
 
182
 */
 
183
static gboolean clean_shutdown_requested = FALSE;
 
184
 
177
185
#ifdef HAVE_CORBA
178
186
/* 
179
187
 * CORBA goo
346
354
  
347
355
  gconf_log(GCL_DEBUG, _("Shutdown request received"));
348
356
 
 
357
  clean_shutdown_requested = TRUE;
349
358
  gconfd_main_quit();
350
359
}
351
360
#endif /* HAVE_CORBA */
488
497
     */
489
498
    enter_shutdown ();
490
499
 
 
500
    clean_shutdown_requested = FALSE;
 
501
 
491
502
    /* let the fatal signals interrupt us */
492
503
    --in_fatal;
493
504
    
499
510
  case SIGTERM:
500
511
    enter_shutdown ();
501
512
 
 
513
    clean_shutdown_requested = TRUE;
 
514
 
502
515
    /* let the fatal signals interrupt us */
503
516
    --in_fatal;
504
517
    
525
538
#endif
526
539
    
527
540
  default:
 
541
    clean_shutdown_requested = FALSE;
528
542
#ifndef HAVE_SIGACTION
529
543
    signal (signo, signal_handler);
530
544
#endif
573
587
                              DBUS_INTERFACE_LOCAL,
574
588
                              "Disconnected"))
575
589
    {
 
590
      /* Since the log file is per-session, we should make sure it's
 
591
       * removed when the session is over.
 
592
       */
 
593
      clean_shutdown_requested = TRUE;
576
594
      gconfd_main_quit ();
577
595
      return DBUS_HANDLER_RESULT_HANDLED;
578
596
    }
991
1009
 
992
1010
#ifdef HAVE_CORBA
993
1011
  /* Save current state in logfile (may compress the logfile a good
994
 
   * bit)
 
1012
   * bit) if we're exiting but may respawn.  Clean up the logfile, if
 
1013
   * the session is going away.
995
1014
   */
996
 
  logfile_save ();
 
1015
  if (clean_shutdown_requested)
 
1016
    logfile_remove ();
 
1017
  else
 
1018
    logfile_save ();
997
1019
#endif
998
1020
  
999
1021
  shutdown_databases ();
1637
1659
 * Logging
1638
1660
 */
1639
1661
 
 
1662
static const char *
 
1663
get_session_guid (void)
 
1664
{
 
1665
  const char *session_bus_address;
 
1666
  const char *guid;
 
1667
 
 
1668
  /* FIXME: we may want to use dbus-address.h functions here
 
1669
   */
 
1670
  session_bus_address = g_getenv ("DBUS_SESSION_BUS_ADDRESS");
 
1671
 
 
1672
  if (session_bus_address == NULL)
 
1673
    return NULL;
 
1674
 
 
1675
  guid = g_strrstr (session_bus_address, "guid=");
 
1676
 
 
1677
  if (guid == NULL)
 
1678
    return NULL;
 
1679
 
 
1680
  if (guid[0] == '\0')
 
1681
    return NULL;
 
1682
 
 
1683
  return guid + strlen ("guid=");
 
1684
}
 
1685
 
1640
1686
/*
1641
1687
   The log file records the current listeners we have registered,
1642
1688
   so we can restore them if we exit and restart.
1665
1711
static void
1666
1712
get_log_names (gchar **logdir, gchar **logfile)
1667
1713
{
1668
 
#ifndef G_OS_WIN32
1669
 
      const char *home = g_get_home_dir ();
1670
 
#else
1671
 
      const char *home = _gconf_win32_get_home_dir ();
1672
 
#endif
1673
 
 
1674
 
  *logdir = g_build_filename (home, ".gconfd", NULL);
1675
 
  *logfile = g_build_filename (*logdir, "saved_state", NULL);
 
1714
  const char *session_guid;
 
1715
  char *state_file;
 
1716
 
 
1717
  *logdir = gconf_get_daemon_dir ();
 
1718
 
 
1719
  /* We make the state file per-session so multiple gconfds
 
1720
   * don't stomp over each other.
 
1721
   */
 
1722
  session_guid = get_session_guid ();
 
1723
 
 
1724
  if (session_guid != NULL)
 
1725
    state_file = g_strdup_printf ("saved_state_%s", session_guid);
 
1726
  else
 
1727
    state_file = g_strdup ("saved_state");
 
1728
 
 
1729
  *logfile = g_build_filename (*logdir, state_file, NULL);
 
1730
  g_free (state_file);
1676
1731
}
1677
1732
 
1678
1733
static void close_append_handle (void);
1895
1950
    close (fd);
1896
1951
}
1897
1952
 
 
1953
static void
 
1954
logfile_remove (void)
 
1955
{
 
1956
  gchar *logdir = NULL;
 
1957
  gchar *logfile = NULL;
 
1958
 
 
1959
  get_log_names (&logdir, &logfile);
 
1960
 
 
1961
  g_unlink (logfile);
 
1962
 
 
1963
  g_free (logdir);
 
1964
  g_free (logfile);
 
1965
}
 
1966
 
 
1967
 
1898
1968
typedef struct _ListenerLogEntry ListenerLogEntry;
1899
1969
 
1900
1970
struct _ListenerLogEntry