~ubuntu-branches/ubuntu/precise/corosync/precise-proposed

« back to all changes in this revision

Viewing changes to exec/schedwrk.c

  • Committer: Bazaar Package Importer
  • Author(s): Andres Rodriguez
  • Date: 2010-07-02 01:24:53 UTC
  • mfrom: (1.1.4 upstream) (5.1.9 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100702012453-qky79tg6hjly2dmq
Tags: 1.2.1-1ubuntu1
* Merge from debian unstable (LP: #600900). Remaining changes:
  - Raised consensus time out to 5000ms
  - debian/control, debian/rules: Removing now-unnecessary quilt build-dep

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
        int (*schedwrk_fn) (const void *);
47
47
        const void *context;
48
48
        void *callback_handle;
 
49
        int lock;
49
50
};
50
51
 
51
52
union u {
70
71
                goto error_exit;
71
72
        }
72
73
 
73
 
        serialize_lock ();
 
74
        if (instance->lock)
 
75
                serialize_lock ();
 
76
 
74
77
        res = instance->schedwrk_fn (instance->context);
75
 
        serialize_unlock ();
 
78
 
 
79
        if (instance->lock)
 
80
                serialize_unlock ();
76
81
 
77
82
        if (res == 0) {
78
83
                hdb_handle_destroy (&schedwrk_instance_database, hdb_nocheck_convert (handle));
93
98
        serialize_unlock = serialize_unlock_fn;
94
99
}
95
100
 
96
 
int schedwrk_create (
 
101
static int schedwrk_internal_create (
97
102
        hdb_handle_t *handle,
98
103
        int (schedwrk_fn) (const void *),
99
 
        const void *context)
 
104
        const void *context,
 
105
        int lock)
100
106
{
101
107
        struct schedwrk_instance *instance;
102
108
        int res;
121
127
 
122
128
        instance->schedwrk_fn = schedwrk_fn;
123
129
        instance->context = context;
 
130
        instance->lock = lock;
124
131
 
125
132
        hdb_handle_put (&schedwrk_instance_database, *handle);
126
133
 
133
140
        return (-1);
134
141
}
135
142
 
 
143
int schedwrk_create (
 
144
        hdb_handle_t *handle,
 
145
        int (schedwrk_fn) (const void *),
 
146
        const void *context)
 
147
{
 
148
        return schedwrk_internal_create (handle, schedwrk_fn, context, 1);
 
149
}
 
150
 
 
151
int schedwrk_create_nolock (
 
152
        hdb_handle_t *handle,
 
153
        int (schedwrk_fn) (const void *),
 
154
        const void *context)
 
155
{
 
156
        return schedwrk_internal_create (handle, schedwrk_fn, context, 0);
 
157
}
 
158
 
136
159
void schedwrk_destroy (hdb_handle_t handle)
137
160
{
138
161
        hdb_handle_destroy (&schedwrk_instance_database, handle);