Skip to content

Commit 0b9d315

Browse files
committed
WIP
1 parent 859321a commit 0b9d315

2 files changed

Lines changed: 49 additions & 67 deletions

File tree

.vscode/settings.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

lib/services/services_dlopen.c

Lines changed: 49 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -67,48 +67,34 @@ int
6767
services__execute_dlopen_metadata(svc_action_t *op) {
6868
void *lib;
6969
char *lib_error;
70-
char *error;
71-
int (*exec)(char **);
70+
const char *metadata;
7271
char dst[200] = "/usr/lib/dlopen/";
7372
strcat(dst, op->agent);
74-
g_hash_table_replace(op->params, strdup("OCF_RESOURCE_INSTANCE"), strdup(op->rsc));
7573
lib = dlopen(dst, RTLD_NOW | RTLD_LOCAL | RTLD_NODELETE);
7674

7775
if (!lib) {
7876
return pcmk_rc_error;
79-
} else {
80-
exec = dlsym(lib, "metadata");
77+
}
8178

82-
if ((lib_error = dlerror()) != NULL){
83-
free(lib_error);
79+
metadata = dlsym(lib, "metadata");
8480

85-
return pcmk_rc_error;
86-
} else {
87-
op->rc = exec(&op->stdout_data);
88-
op->status = PCMK_EXEC_DONE;
89-
op->pid = 0;
90-
if (op->interval_ms != 0) {
91-
// Recurring operations must be either cancelled or rescheduled
92-
if (op->cancel) {
93-
services__set_cancelled(op);
94-
cancel_recurring_action(op);
95-
} else {
96-
op->opaque->repeat_timer = g_timeout_add(op->interval_ms,
97-
recurring_action_timer,
98-
(void *) op);
99-
}
100-
}
101-
102-
if (op->opaque->callback) {
103-
op->opaque->callback(op);
104-
}
105-
106-
crm_info("Exit code: %d, error: %s", op->rc, error);
107-
108-
dlclose(lib);
109-
return pcmk_rc_ok;
110-
}
81+
if ((lib_error = dlerror()) != NULL){
82+
free(lib_error);
83+
84+
return pcmk_rc_error;
11185
}
86+
87+
op->rc = PCMK_OCF_OK;
88+
op->status = PCMK_EXEC_DONE;
89+
op->pid = 0;
90+
op->stdout_data = strdup(metadata);
91+
92+
if (op->opaque->callback) {
93+
op->opaque->callback(op);
94+
}
95+
96+
dlclose(lib);
97+
return pcmk_rc_ok;
11298
}
11399

114100
int
@@ -119,42 +105,43 @@ services__execute_dlopen_action(svc_action_t *op) {
119105
int (*exec)(GHashTable *, char **);
120106
char dst[200] = "/usr/lib/dlopen/";
121107
strcat(dst, op->agent);
122-
g_hash_table_replace(op->params, strdup("OCF_RESOURCE_INSTANCE"), strdup(op->rsc));
108+
g_hash_table_replace(op->params, strdup("DLOPEN_RESOURCE_INSTANCE"), strdup(op->rsc));
123109
lib = dlopen(dst, RTLD_NOW | RTLD_LOCAL | RTLD_NODELETE);
124110

125111
if (!lib) {
126112
return pcmk_rc_error;
127-
} else {
128-
exec = dlsym(lib, op->action);
113+
}
114+
115+
exec = dlsym(lib, op->action);
116+
117+
if ((lib_error = dlerror()) != NULL){
118+
free(lib_error);
119+
120+
return pcmk_rc_error;
121+
}
129122

130-
if ((lib_error = dlerror()) != NULL){
131-
free(lib_error);
123+
op->rc = exec(op->params, &error);
124+
op->status = PCMK_EXEC_DONE;
125+
op->pid = 0;
132126

133-
return pcmk_rc_error;
127+
if (op->interval_ms != 0) {
128+
// Recurring operations must be either cancelled or rescheduled
129+
if (op->cancel) {
130+
services__set_cancelled(op);
131+
cancel_recurring_action(op);
134132
} else {
135-
op->rc = exec(op->params, &error);
136-
op->status = PCMK_EXEC_DONE;
137-
op->pid = 0;
138-
if (op->interval_ms != 0) {
139-
// Recurring operations must be either cancelled or rescheduled
140-
if (op->cancel) {
141-
services__set_cancelled(op);
142-
cancel_recurring_action(op);
143-
} else {
144-
op->opaque->repeat_timer = g_timeout_add(op->interval_ms,
145-
recurring_action_timer,
146-
(void *) op);
147-
}
148-
}
149-
150-
if (op->opaque->callback) {
151-
op->opaque->callback(op);
152-
}
153-
154-
crm_info("Exit code: %d, error: %s", op->rc, error);
155-
156-
dlclose(lib);
157-
return pcmk_rc_ok;
133+
op->opaque->repeat_timer = g_timeout_add(op->interval_ms,
134+
recurring_action_timer,
135+
(void *) op);
158136
}
159137
}
138+
139+
if (op->opaque->callback) {
140+
op->opaque->callback(op);
141+
}
142+
143+
crm_info("Exit code: %d, error: %s", op->rc, error);
144+
145+
dlclose(lib);
146+
return pcmk_rc_ok;
160147
}

0 commit comments

Comments
 (0)