~xnox/upstart/shrink-notifications

« back to all changes in this revision

Viewing changes to init/job.c

  • Committer: Dimitri John Ledkov
  • Date: 2014-06-05 22:35:01 UTC
  • mfrom: (1620.2.44 upstart-async)
  • Revision ID: dimitri.ledkov@canonical.com-20140605223501-z4hj7xddug95y59u
Merge cgroups work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
#include "state.h"
59
59
#include "apparmor.h"
60
60
 
 
61
#ifdef ENABLE_CGROUPS
 
62
#include "cgroup.h"
 
63
#endif /* ENABLE_CGROUPS */
 
64
 
61
65
#include "com.ubuntu.Upstart.Job.h"
62
66
#include "com.ubuntu.Upstart.Instance.h"
63
67
 
1361
1365
                return -1;
1362
1366
        }
1363
1367
 
 
1368
#ifdef ENABLE_CGROUPS
 
1369
        /* Job has specified a cgroup stanza but since the cgroup
 
1370
         * manager has not yet been contacted, the job cannot be started.
 
1371
         */
 
1372
        if (job_class_cgroups (job->class) && ! cgroup_manager_available ()) {
 
1373
                nih_dbus_error_raise_printf (
 
1374
                        DBUS_INTERFACE_UPSTART ".Error.CGroupManagerNotAvailable",
 
1375
                        _("Job cannot be started as cgroup manager not available: %s"),
 
1376
                        job_name (job));
 
1377
                return -1;
 
1378
        }
 
1379
#endif /* ENABLE_CGROUPS */
 
1380
 
1364
1381
        if (wait) {
1365
1382
                blocked = blocked_new (job, BLOCKED_INSTANCE_START_METHOD,
1366
1383
                                       message);
2578
2595
}
2579
2596
 
2580
2597
/**
 
2598
 * job_needs_cgroups:
 
2599
 *
 
2600
 * @job: job.
 
2601
 *
 
2602
 * Determine if specified job requires cgroups.
 
2603
 *
 
2604
 * Returns: TRUE if @job needs atleast 1 cgroup, else FALSE.
 
2605
 **/
 
2606
int
 
2607
job_needs_cgroups (const Job *job)
 
2608
{
 
2609
        nih_assert (job);
 
2610
 
 
2611
#ifdef ENABLE_CGROUPS
 
2612
        return job_class_cgroups (job->class);
 
2613
#else 
 
2614
        /* No cgroup support */
 
2615
        return FALSE;
 
2616
 
 
2617
#endif /* ENABLE_CGROUPS */
 
2618
 
 
2619
}
 
2620
 
 
2621
/**
2581
2622
 * job_child_error_handler:
2582
2623
 *
2583
2624
 * @job: job,