~ubuntu-branches/ubuntu/utopic/pacemaker/utopic-proposed

« back to all changes in this revision

Viewing changes to cib/common.c

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2013-07-16 16:40:24 UTC
  • mfrom: (1.1.11) (2.2.3 experimental)
  • Revision ID: package-import@ubuntu.com-20130716164024-lvwrf4xivk1wdr3c
Tags: 1.1.9+git20130321-1ubuntu1
* Resync from debian expiremental.
* debian/control:
  - Use lower version for Build-Depends on libcorosync-dev
    and libqb-dev.
  - Build-Depends on libcfg-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include <crm/cib.h>
32
32
#include <crm/msg_xml.h>
33
33
#include <crm/common/ipc.h>
34
 
#include <crm/common/cluster.h>
 
34
#include <crm/cluster.h>
35
35
 
36
36
#include <crm/common/xml.h>
37
 
#include <crm/common/msg.h>
38
37
 
39
38
#include <cibio.h>
40
39
#include <callbacks.h>
44
43
extern gboolean cib_is_master;
45
44
extern const char *cib_root;
46
45
gboolean stand_alone = FALSE;
47
 
extern enum cib_errors cib_status;
 
46
extern int cib_status;
48
47
extern gboolean can_write(int flags);
49
 
extern enum cib_errors cib_perform_command(xmlNode * request, xmlNode ** reply, xmlNode ** cib_diff,
50
 
                                           gboolean privileged);
 
48
extern int cib_perform_command(xmlNode * request, xmlNode ** reply, xmlNode ** cib_diff,
 
49
                               gboolean privileged);
51
50
 
52
51
static xmlNode *
53
52
cib_prepare_common(xmlNode * root, const char *section)
76
75
    return data;
77
76
}
78
77
 
79
 
static enum cib_errors
 
78
static int
80
79
cib_prepare_none(xmlNode * request, xmlNode ** data, const char **section)
81
80
{
82
81
    *data = NULL;
83
82
    *section = crm_element_value(request, F_CIB_SECTION);
84
 
    return cib_ok;
 
83
    return pcmk_ok;
85
84
}
86
85
 
87
 
static enum cib_errors
 
86
static int
88
87
cib_prepare_data(xmlNode * request, xmlNode ** data, const char **section)
89
88
{
90
89
    xmlNode *input_fragment = get_message_xml(request, F_CIB_CALLDATA);
92
91
    *section = crm_element_value(request, F_CIB_SECTION);
93
92
    *data = cib_prepare_common(input_fragment, *section);
94
93
    /* crm_log_xml_debug(*data, "data"); */
95
 
    return cib_ok;
 
94
    return pcmk_ok;
96
95
}
97
96
 
98
 
static enum cib_errors
 
97
static int
99
98
cib_prepare_sync(xmlNode * request, xmlNode ** data, const char **section)
100
99
{
101
100
    *data = NULL;
102
101
    *section = crm_element_value(request, F_CIB_SECTION);
103
 
    return cib_ok;
 
102
    return pcmk_ok;
104
103
}
105
104
 
106
 
static enum cib_errors
 
105
static int
107
106
cib_prepare_diff(xmlNode * request, xmlNode ** data, const char **section)
108
107
{
109
108
    xmlNode *input_fragment = NULL;
121
120
 
122
121
    CRM_CHECK(input_fragment != NULL, crm_log_xml_warn(request, "no input"));
123
122
    *data = cib_prepare_common(input_fragment, NULL);
124
 
    return cib_ok;
 
123
    return pcmk_ok;
125
124
}
126
125
 
127
 
static enum cib_errors
 
126
static int
128
127
cib_cleanup_query(int options, xmlNode ** data, xmlNode ** output)
129
128
{
130
129
    CRM_LOG_ASSERT(*data == NULL);
132
131
        || safe_str_eq(crm_element_name(*output), "xpath-query")) {
133
132
        free_xml(*output);
134
133
    }
135
 
    return cib_ok;
 
134
    return pcmk_ok;
136
135
}
137
136
 
138
 
static enum cib_errors
 
137
static int
139
138
cib_cleanup_data(int options, xmlNode ** data, xmlNode ** output)
140
139
{
141
140
    free_xml(*output);
142
141
    *data = NULL;
143
 
    return cib_ok;
 
142
    return pcmk_ok;
144
143
}
145
144
 
146
 
static enum cib_errors
 
145
static int
147
146
cib_cleanup_output(int options, xmlNode ** data, xmlNode ** output)
148
147
{
149
148
    free_xml(*output);
150
 
    return cib_ok;
 
149
    return pcmk_ok;
151
150
}
152
151
 
153
 
static enum cib_errors
 
152
static int
154
153
cib_cleanup_none(int options, xmlNode ** data, xmlNode ** output)
155
154
{
156
155
    CRM_LOG_ASSERT(*data == NULL);
157
156
    CRM_LOG_ASSERT(*output == NULL);
158
 
    return cib_ok;
 
157
    return pcmk_ok;
159
158
}
160
159
 
161
 
static enum cib_errors
 
160
static int
162
161
cib_cleanup_sync(int options, xmlNode ** data, xmlNode ** output)
163
162
{
164
163
    /* data is non-NULL but doesnt need to be free'd */
165
164
    CRM_LOG_ASSERT(*data == NULL);
166
165
    CRM_LOG_ASSERT(*output == NULL);
167
 
    return cib_ok;
 
166
    return pcmk_ok;
168
167
}
169
168
 
170
169
/*
174
173
  gboolean      modifies_cib;
175
174
  gboolean      needs_privileges;
176
175
  gboolean      needs_quorum;
177
 
  enum cib_errors (*prepare)(xmlNode *, xmlNode**, const char **);
178
 
  enum cib_errors (*cleanup)(xmlNode**, xmlNode**);
179
 
  enum cib_errors (*fn)(
 
176
  int (*prepare)(xmlNode *, xmlNode**, const char **);
 
177
  int (*cleanup)(xmlNode**, xmlNode**);
 
178
  int (*fn)(
180
179
  const char *, int, const char *,
181
180
  xmlNode*, xmlNode*, xmlNode**, xmlNode**);
182
181
  } cib_operation_t;
205
204
    {CIB_OP_MASTER,    TRUE,  TRUE,  FALSE, cib_prepare_data, cib_cleanup_data,   cib_process_readwrite},
206
205
    {CIB_OP_ISMASTER,  FALSE, TRUE,  FALSE, cib_prepare_none, cib_cleanup_none,   cib_process_readwrite},
207
206
    {"cib_shutdown_req",FALSE, TRUE, FALSE, cib_prepare_sync, cib_cleanup_sync,   cib_process_shutdown_req},
208
 
    {CRM_OP_QUIT,      FALSE, TRUE,  FALSE, cib_prepare_none, cib_cleanup_none,   cib_process_quit},
209
207
    {CRM_OP_PING,      FALSE, FALSE, FALSE, cib_prepare_none, cib_cleanup_output, cib_process_ping},
210
208
};
211
209
/* *INDENT-ON* */
212
210
 
213
 
enum cib_errors
 
211
int
214
212
cib_get_operation_id(const char *op, int *operation)
215
213
{
216
214
    static GHashTable *operation_hash = NULL;
221
219
 
222
220
        operation_hash = g_hash_table_new_full(crm_str_hash, g_str_equal, NULL, g_hash_destroy_str);
223
221
        for (lpc = 1; lpc < max_msg_types; lpc++) {
 
222
            /* coverity[returned_null] Ignore */
224
223
            int *value = malloc(sizeof(int));
225
224
 
226
225
            *value = lpc;
233
232
 
234
233
        if (value) {
235
234
            *operation = *value;
236
 
            return cib_ok;
 
235
            return pcmk_ok;
237
236
        }
238
237
    }
239
238
    crm_err("Operation %s is not valid", op);
240
239
    *operation = -1;
241
 
    return cib_operation;
 
240
    return -EINVAL;
242
241
}
243
242
 
244
243
xmlNode *
321
320
{
322
321
    if (privileged == FALSE && cib_server_ops[call_type].needs_privileges) {
323
322
        /* abort */
324
 
        return cib_not_authorized;
 
323
        return -EACCES;
325
324
    }
326
325
#if 0
327
 
    if (rc == cib_ok
 
326
    if (rc == pcmk_ok
328
327
        && stand_alone == FALSE
329
328
        && global_update == FALSE
330
329
        && (call_options & cib_quorum_override) == 0 && cib_server_ops[call_type].needs_quorum) {
331
 
        return cib_no_quorum;
 
330
        return -pcmk_err_no_quorum;
332
331
    }
333
332
#endif
334
 
    return cib_ok;
 
333
    return pcmk_ok;
335
334
}
336
335
 
337
336
int