~ubuntu-branches/ubuntu/quantal/mountall/quantal

« back to all changes in this revision

Viewing changes to src/mountall.c

  • Committer: Steve Langasek
  • Date: 2012-09-09 07:03:15 UTC
  • Revision ID: steve.langasek@canonical.com-20120909070315-ybtf9w8ekf91ufqq
Even if the mounting/mounted event failed (due perhaps to a failure of a job
depending on it), we still want to proceed with the mount and not just
error out.

Show diffs side-by-side

added added

removed removed

Lines of Context:
160
160
        void (*handler) (Mount *mnt, pid_t pid, int status);
161
161
} Process;
162
162
 
 
163
typedef struct event_reply_data {
 
164
        Mount *          mnt;
 
165
        void (*handler) (void *data, NihDBusMessage *message);
 
166
} EventReplyData;
163
167
 
164
168
Mount *new_mount             (const char *mountpoint, const char *device,
165
169
                              int check, const char *type, const char *opts);
1874
1878
mounting_event_handled (void *data,
1875
1879
                        NihDBusMessage *message)
1876
1880
{
1877
 
        Mount *mnt = (Mount *)data;
 
1881
        Mount *mnt = ((EventReplyData *)data)->mnt;
 
1882
 
 
1883
        nih_free (data);
1878
1884
 
1879
1885
        /* We may generate new pending events below; make sure to clear
1880
1886
         * the current one before we do. */
1894
1900
mounted_event_handled (void *data,
1895
1901
                       NihDBusMessage *message)
1896
1902
{
1897
 
        Mount *mnt = (Mount *)data;
 
1903
        Mount *mnt = ((EventReplyData *)data)->mnt;
 
1904
 
 
1905
        nih_free (data);
1898
1906
 
1899
1907
        /* We may generate new pending events below; make sure to clear
1900
1908
         * the current one before we do. */
2661
2669
        DBusPendingCall *pending_call;
2662
2670
        nih_local char **env = NULL;
2663
2671
        size_t           env_len = 0;
2664
 
        void            *reply_data = NULL;
 
2672
        EventReplyData  *reply_data = NULL;
2665
2673
 
2666
2674
        nih_assert (name != NULL);
2667
2675
 
2701
2709
        }
2702
2710
 
2703
2711
        if (mnt && cb)
2704
 
                reply_data = mnt;
 
2712
                reply_data = NIH_MUST (nih_alloc (NULL, sizeof (EventReplyData)));
2705
2713
        
2706
2714
        pending_call = NIH_SHOULD (upstart_emit_event (upstart,
2707
2715
                                                       name, env, reply_data ? TRUE : FALSE,
2713
2721
        
2714
2722
                if (reply_data) {
2715
2723
 
 
2724
                        reply_data->mnt = mnt;
 
2725
                        reply_data->handler = cb;
 
2726
 
2716
2727
                        /* If previous event is still pending, wait for it. */
2717
2728
                        if (mnt->pending_call) {
2718
2729
                                DBusPendingCall *pending = mnt->pending_call;
2737
2748
                nih_warn ("%s", err->message);
2738
2749
                nih_free (err);
2739
2750
 
 
2751
                nih_free (reply_data);
2740
2752
        }
2741
2753
}
2742
2754
 
2744
2756
emit_event_error (void *          data,
2745
2757
                  NihDBusMessage *message)
2746
2758
{
 
2759
        EventReplyData *reply_data = (EventReplyData *)data;
2747
2760
        NihError *err;
2748
2761
 
2749
2762
        err = nih_error_get ();
2750
2763
        nih_warn ("%s", err->message);
2751
2764
        nih_free (err);
 
2765
 
 
2766
        /* Even if the event returned an error, we still want to do the mount */
 
2767
        if (reply_data)
 
2768
                reply_data->handler (data, message);
2752
2769
}
2753
2770
 
2754
2771