1 /****************************************************************************\
2  *  slurmdbd_defs.c - functions for use with Slurm DBD RPCs
3  *****************************************************************************
4  *  Copyright (C) 2011-2018 SchedMD LLC.
5  *  Copyright (C) 2008-2010 Lawrence Livermore National Security.
6  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
7  *  Written by Morris Jette <jette1@llnl.gov>
8  *  CODE-OCEC-09-009. All rights reserved.
9  *
10  *  This file is part of Slurm, a resource management program.
11  *  For details, see <https://slurm.schedmd.com/>.
12  *  Please also read the included file: DISCLAIMER.
13  *
14  *  Slurm is free software; you can redistribute it and/or modify it under
15  *  the terms of the GNU General Public License as published by the Free
16  *  Software Foundation; either version 2 of the License, or (at your option)
17  *  any later version.
18  *
19  *  In addition, as a special exception, the copyright holders give permission
20  *  to link the code of portions of this program with the OpenSSL library under
21  *  certain conditions as described in each individual source file, and
22  *  distribute linked combinations including the two. You must obey the GNU
23  *  General Public License in all respects for all of the code used other than
24  *  OpenSSL. If you modify file(s) with this exception, you may extend this
25  *  exception to your version of the file(s), but you are not obligated to do
26  *  so. If you do not wish to do so, delete this exception statement from your
27  *  version.  If you delete this exception statement from all source files in
28  *  the program, then also delete it here.
29  *
30  *  Slurm is distributed in the hope that it will be useful, but WITHOUT ANY
31  *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
32  *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
33  *  details.
34  *
35  *  You should have received a copy of the GNU General Public License along
36  *  with Slurm; if not, write to the Free Software Foundation, Inc.,
37  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
38 \*****************************************************************************/
39 
40 #include "src/common/slurmdbd_defs.h"
41 #include "src/common/slurm_jobacct_gather.h"
42 
43 /*
44  * Define slurm-specific aliases for use by plugins, see slurm_xlator.h
45  * for details.
46  */
47 strong_alias(slurmdbd_free_buffer,	slurm_slurmdbd_free_buffer);
48 strong_alias(slurmdbd_free_list_msg,	slurm_slurmdbd_free_list_msg);
49 strong_alias(slurmdbd_free_usage_msg,	slurm_slurmdbd_free_usage_msg);
50 strong_alias(slurmdbd_free_id_rc_msg,	slurm_slurmdbd_free_id_rc_msg);
51 
str_2_slurmdbd_msg_type(char * msg_type)52 extern slurmdbd_msg_type_t str_2_slurmdbd_msg_type(char *msg_type)
53 {
54 	if (!msg_type) {
55 		return NO_VAL;
56 	} else if (!xstrcasecmp(msg_type, "Fini")) {
57 		return DBD_FINI;
58 	} else if (!xstrcasecmp(msg_type, "Add Accounts")) {
59 		return DBD_ADD_ACCOUNTS;
60 	} else if (!xstrcasecmp(msg_type, "Add Account Coord")) {
61 		return DBD_ADD_ACCOUNT_COORDS;
62 	} else if (!xstrcasecmp(msg_type, "Add TRES")) {
63 		return DBD_ADD_TRES;
64 	} else if (!xstrcasecmp(msg_type, "Add Associations")) {
65 		return DBD_ADD_ASSOCS;
66 	} else if (!xstrcasecmp(msg_type, "Add Clusters")) {
67 		return DBD_ADD_CLUSTERS;
68 	} else if (!xstrcasecmp(msg_type, "Add Federations")) {
69 		return DBD_ADD_FEDERATIONS;
70 	} else if (!xstrcasecmp(msg_type, "Add Resources")) {
71 		return DBD_ADD_RES;
72 	} else if (!xstrcasecmp(msg_type, "Add Users")) {
73 		return DBD_ADD_USERS;
74 	} else if (!xstrcasecmp(msg_type, "Cluster TRES")) {
75 		return DBD_CLUSTER_TRES;
76 	} else if (!xstrcasecmp(msg_type, "Flush Jobs")) {
77 		return DBD_FLUSH_JOBS;
78 	} else if (!xstrcasecmp(msg_type, "Get Accounts")) {
79 		return DBD_GET_ACCOUNTS;
80 	} else if (!xstrcasecmp(msg_type, "Get TRES")) {
81 		return DBD_GET_TRES;
82 	} else if (!xstrcasecmp(msg_type, "Get Associations")) {
83 		return DBD_GET_ASSOCS;
84 	} else if (!xstrcasecmp(msg_type, "Get Association Usage")) {
85 		return DBD_GET_ASSOC_USAGE;
86 	} else if (!xstrcasecmp(msg_type, "Get Clusters")) {
87 		return DBD_GET_CLUSTERS;
88 	} else if (!xstrcasecmp(msg_type, "Get Cluster Usage")) {
89 		return DBD_GET_CLUSTER_USAGE;
90 	} else if (!xstrcasecmp(msg_type, "Get Events")) {
91 		return DBD_GET_EVENTS;
92 	} else if (!xstrcasecmp(msg_type, "Get Federations")) {
93 		return DBD_GET_FEDERATIONS;
94 	} else if (!xstrcasecmp(msg_type, "Reconfigure")) {
95 		return DBD_RECONFIG;
96 	} else if (!xstrcasecmp(msg_type, "Get Problems")) {
97 		return DBD_GET_PROBS;
98 	} else if (!xstrcasecmp(msg_type, "Get Resources")) {
99 		return DBD_GET_RES;
100 	} else if (!xstrcasecmp(msg_type, "Get Users")) {
101 		return DBD_GET_USERS;
102 	} else if (!xstrcasecmp(msg_type, "Got Accounts")) {
103 		return DBD_GOT_ACCOUNTS;
104 	} else if (!xstrcasecmp(msg_type, "Got TRES")) {
105 		return DBD_GOT_TRES;
106 	} else if (!xstrcasecmp(msg_type, "Got Associations")) {
107 		return DBD_GOT_ASSOCS;
108 	} else if (!xstrcasecmp(msg_type, "Got Association Usage")) {
109 		return DBD_GOT_ASSOC_USAGE;
110 	} else if (!xstrcasecmp(msg_type, "Got Clusters")) {
111 		return DBD_GOT_CLUSTERS;
112 	} else if (!xstrcasecmp(msg_type, "Got Cluster Usage")) {
113 		return DBD_GOT_CLUSTER_USAGE;
114 	} else if (!xstrcasecmp(msg_type, "Got Events")) {
115 		return DBD_GOT_EVENTS;
116 	} else if (!xstrcasecmp(msg_type, "Got Federations")) {
117 		return DBD_GOT_FEDERATIONS;
118 	} else if (!xstrcasecmp(msg_type, "Got Jobs")) {
119 		return DBD_GOT_JOBS;
120 	} else if (!xstrcasecmp(msg_type, "Got List")) {
121 		return DBD_GOT_LIST;
122 	} else if (!xstrcasecmp(msg_type, "Got Problems")) {
123 		return DBD_GOT_PROBS;
124 	} else if (!xstrcasecmp(msg_type, "Got Resources")) {
125 		return DBD_GOT_RES;
126 	} else if (!xstrcasecmp(msg_type, "Got Users")) {
127 		return DBD_GOT_USERS;
128 	} else if (!xstrcasecmp(msg_type, "Job Complete")) {
129 		return DBD_JOB_COMPLETE;
130 	} else if (!xstrcasecmp(msg_type, "Job Start")) {
131 		return DBD_JOB_START;
132 	} else if (!xstrcasecmp(msg_type, "ID RC")) {
133 		return DBD_ID_RC;
134 	} else if (!xstrcasecmp(msg_type, "Job Suspend")) {
135 		return DBD_JOB_SUSPEND;
136 	} else if (!xstrcasecmp(msg_type, "Modify Accounts")) {
137 		return DBD_MODIFY_ACCOUNTS;
138 	} else if (!xstrcasecmp(msg_type, "Modify Associations")) {
139 		return DBD_MODIFY_ASSOCS;
140 	} else if (!xstrcasecmp(msg_type, "Modify Clusters")) {
141 		return DBD_MODIFY_CLUSTERS;
142 	} else if (!xstrcasecmp(msg_type, "Modify Federations")) {
143 		return DBD_MODIFY_FEDERATIONS;
144 	} else if (!xstrcasecmp(msg_type, "Modify Job")) {
145 		return DBD_MODIFY_JOB;
146 	} else if (!xstrcasecmp(msg_type, "Modify QOS")) {
147 		return DBD_MODIFY_QOS;
148 	} else if (!xstrcasecmp(msg_type, "Modify Resources")) {
149 		return DBD_MODIFY_RES;
150 	} else if (!xstrcasecmp(msg_type, "Modify Users")) {
151 		return DBD_MODIFY_USERS;
152 	} else if (!xstrcasecmp(msg_type, "Node State")) {
153 		return DBD_NODE_STATE;
154 	} else if (!xstrcasecmp(msg_type, "Register Cluster")) {
155 		return DBD_REGISTER_CTLD;
156 	} else if (!xstrcasecmp(msg_type, "Remove Accounts")) {
157 		return DBD_REMOVE_ACCOUNTS;
158 	} else if (!xstrcasecmp(msg_type, "Remove Account Coords")) {
159 		return DBD_REMOVE_ACCOUNT_COORDS;
160 	} else if (!xstrcasecmp(msg_type, "Archive Dump")) {
161 		return DBD_ARCHIVE_DUMP;
162 	} else if (!xstrcasecmp(msg_type, "Archive Load")) {
163 		return DBD_ARCHIVE_LOAD;
164 	} else if (!xstrcasecmp(msg_type, "Remove Associations")) {
165 		return DBD_REMOVE_ASSOCS;
166 	} else if (!xstrcasecmp(msg_type, "Remove Clusters")) {
167 		return DBD_REMOVE_CLUSTERS;
168 	} else if (!xstrcasecmp(msg_type, "Remove Federations")) {
169 		return DBD_REMOVE_FEDERATIONS;
170 	} else if (!xstrcasecmp(msg_type, "Remove Resources")) {
171 		return DBD_REMOVE_RES;
172 	} else if (!xstrcasecmp(msg_type, "Remove Users")) {
173 		return DBD_REMOVE_USERS;
174 	} else if (!xstrcasecmp(msg_type, "Roll Usage")) {
175 		return DBD_ROLL_USAGE;
176 	} else if (!xstrcasecmp(msg_type, "Step Complete")) {
177 		return DBD_STEP_COMPLETE;
178 	} else if (!xstrcasecmp(msg_type, "Step Start")) {
179 		return DBD_STEP_START;
180 	} else if (!xstrcasecmp(msg_type, "Get Jobs Conditional")) {
181 		return DBD_GET_JOBS_COND;
182 	} else if (!xstrcasecmp(msg_type, "Get Transactions")) {
183 		return DBD_GET_TXN;
184 	} else if (!xstrcasecmp(msg_type, "Got Transactions")) {
185 		return DBD_GOT_TXN;
186 	} else if (!xstrcasecmp(msg_type, "Add QOS")) {
187 		return DBD_ADD_QOS;
188 	} else if (!xstrcasecmp(msg_type, "Get QOS")) {
189 		return DBD_GET_QOS;
190 	} else if (!xstrcasecmp(msg_type, "Got QOS")) {
191 		return DBD_GOT_QOS;
192 	} else if (!xstrcasecmp(msg_type, "Remove QOS")) {
193 		return DBD_REMOVE_QOS;
194 	} else if (!xstrcasecmp(msg_type, "Add WCKeys")) {
195 		return DBD_ADD_WCKEYS;
196 	} else if (!xstrcasecmp(msg_type, "Get WCKeys")) {
197 		return DBD_GET_WCKEYS;
198 	} else if (!xstrcasecmp(msg_type, "Got WCKeys")) {
199 		return DBD_GOT_WCKEYS;
200 	} else if (!xstrcasecmp(msg_type, "Remove WCKeys")) {
201 		return DBD_REMOVE_WCKEYS;
202 	} else if (!xstrcasecmp(msg_type, "Get WCKey Usage")) {
203 		return DBD_GET_WCKEY_USAGE;
204 	} else if (!xstrcasecmp(msg_type, "Got WCKey Usage")) {
205 		return DBD_GOT_WCKEY_USAGE;
206 	} else if (!xstrcasecmp(msg_type, "Add Reservation")) {
207 		return DBD_ADD_RESV;
208 	} else if (!xstrcasecmp(msg_type, "Remove Reservation")) {
209 		return DBD_REMOVE_RESV;
210 	} else if (!xstrcasecmp(msg_type, "Modify Reservation")) {
211 		return DBD_MODIFY_RESV;
212 	} else if (!xstrcasecmp(msg_type, "Get Reservations")) {
213 		return DBD_GET_RESVS;
214 	} else if (!xstrcasecmp(msg_type, "Got Reservations")) {
215 		return DBD_GOT_RESVS;
216 	} else if (!xstrcasecmp(msg_type, "Get Config")) {
217 		return DBD_GET_CONFIG;
218 	} else if (!xstrcasecmp(msg_type, "Got Config")) {
219 		return DBD_GOT_CONFIG;
220 	} else if (!xstrcasecmp(msg_type, "Send Multiple Job Starts")) {
221 		return DBD_SEND_MULT_JOB_START;
222 	} else if (!xstrcasecmp(msg_type, "Got Multiple Job Starts")) {
223 		return DBD_GOT_MULT_JOB_START;
224 	} else if (!xstrcasecmp(msg_type, "Send Multiple Messages")) {
225 		return DBD_SEND_MULT_MSG;
226 	} else if (!xstrcasecmp(msg_type, "Got Multiple Message Returns")) {
227 		return DBD_GOT_MULT_MSG;
228 	} else if (!xstrcasecmp(msg_type,
229 				"Persistent Connection Initialization")) {
230 		return SLURM_PERSIST_INIT;
231 	} else {
232 		return NO_VAL;
233 	}
234 
235 	return NO_VAL;
236 }
237 
slurmdbd_msg_type_2_str(slurmdbd_msg_type_t msg_type,int get_enum)238 extern char *slurmdbd_msg_type_2_str(slurmdbd_msg_type_t msg_type, int get_enum)
239 {
240 	static char unk_str[64];
241 
242 	switch (msg_type) {
243 	case DBD_FINI:
244 		if (get_enum) {
245 			return "DBD_FINI";
246 		} else
247 			return "Fini";
248 		break;
249 	case DBD_ADD_ACCOUNTS:
250 		if (get_enum) {
251 			return "DBD_ADD_ACCOUNTS";
252 		} else
253 			return "Add Accounts";
254 		break;
255 	case DBD_ADD_ACCOUNT_COORDS:
256 		if (get_enum) {
257 			return "DBD_ADD_ACCOUNT_COORDS";
258 		} else
259 			return "Add Account Coord";
260 		break;
261 	case DBD_ADD_TRES:
262 		if (get_enum) {
263 			return "DBD_ADD_TRES";
264 		} else
265 			return "Add TRES";
266 		break;
267 	case DBD_ADD_ASSOCS:
268 		if (get_enum) {
269 			return "DBD_ADD_ASSOCS";
270 		} else
271 			return "Add Associations";
272 		break;
273 	case DBD_ADD_CLUSTERS:
274 		if (get_enum) {
275 			return "DBD_ADD_CLUSTERS";
276 		} else
277 			return "Add Clusters";
278 		break;
279 	case DBD_ADD_FEDERATIONS:
280 		if (get_enum) {
281 			return "DBD_ADD_FEDERATIONS";
282 		} else
283 			return "Add Clusters";
284 		break;
285 	case DBD_ADD_RES:
286 		if (get_enum) {
287 			return "DBD_ADD_RES";
288 		} else
289 			return "Add Resources";
290 		break;
291 	case DBD_ADD_USERS:
292 		if (get_enum) {
293 			return "DBD_ADD_USERS";
294 		} else
295 			return "Add Users";
296 		break;
297 	case DBD_CLUSTER_TRES:
298 		if (get_enum) {
299 			return "DBD_CLUSTER_TRES";
300 		} else
301 			return "Cluster TRES";
302 		break;
303 	case DBD_FLUSH_JOBS:
304 		if (get_enum) {
305 			return "DBD_FLUSH_JOBS";
306 		} else
307 			return "Flush Jobs";
308 		break;
309 	case DBD_GET_ACCOUNTS:
310 		if (get_enum) {
311 			return "DBD_GET_ACCOUNTS";
312 		} else
313 			return "Get Accounts";
314 		break;
315 	case DBD_GET_TRES:
316 		if (get_enum) {
317 			return "DBD_GET_TRES";
318 		} else
319 			return "Get TRES";
320 		break;
321 	case DBD_GET_ASSOCS:
322 		if (get_enum) {
323 			return "DBD_GET_ASSOCS";
324 		} else
325 			return "Get Associations";
326 		break;
327 	case DBD_GET_ASSOC_USAGE:
328 		if (get_enum) {
329 			return "DBD_GET_ASSOC_USAGE";
330 		} else
331 			return "Get Association Usage";
332 		break;
333 	case DBD_GET_CLUSTERS:
334 		if (get_enum) {
335 			return "DBD_GET_CLUSTERS";
336 		} else
337 			return "Get Clusters";
338 		break;
339 	case DBD_GET_CLUSTER_USAGE:
340 		if (get_enum) {
341 			return "DBD_GET_CLUSTER_USAGE";
342 		} else
343 			return "Get Cluster Usage";
344 		break;
345 	case DBD_GET_EVENTS:
346 		if (get_enum) {
347 			return "DBD_GET_EVENTS";
348 		} else
349 			return "Get Events";
350 		break;
351 	case DBD_GET_FEDERATIONS:
352 		if (get_enum) {
353 			return "DBD_GET_FEDERATIONS";
354 		} else
355 			return "Get Federations";
356 		break;
357 	case DBD_RECONFIG:
358 		if (get_enum) {
359 			return "DBD_RECONFIG";
360 		} else
361 			return "Reconfigure";
362 		break;
363 	case DBD_GET_PROBS:
364 		if (get_enum) {
365 			return "DBD_GET_PROBS";
366 		} else
367 			return "Get Problems";
368 		break;
369 	case DBD_GET_RES:
370 		if (get_enum) {
371 			return "DBD_GET_RES";
372 		} else
373 			return "Get Resources";
374 		break;
375 	case DBD_GET_USERS:
376 		if (get_enum) {
377 			return "DBD_GET_USERS";
378 		} else
379 			return "Get Users";
380 		break;
381 	case DBD_GOT_ACCOUNTS:
382 		if (get_enum) {
383 			return "DBD_GOT_ACCOUNTS";
384 		} else
385 			return "Got Accounts";
386 		break;
387 	case DBD_GOT_TRES:
388 		if (get_enum) {
389 			return "DBD_GOT_TRES";
390 		} else
391 			return "Got TRES";
392 		break;
393 	case DBD_GOT_ASSOCS:
394 		if (get_enum) {
395 			return "DBD_GOT_ASSOCS";
396 		} else
397 			return "Got Associations";
398 		break;
399 	case DBD_GOT_ASSOC_USAGE:
400 		if (get_enum) {
401 			return "DBD_GOT_ASSOC_USAGE";
402 		} else
403 			return "Got Association Usage";
404 		break;
405 	case DBD_GOT_CLUSTERS:
406 		if (get_enum) {
407 			return "DBD_GOT_CLUSTERS";
408 		} else
409 			return "Got Clusters";
410 		break;
411 	case DBD_GOT_CLUSTER_USAGE:
412 		if (get_enum) {
413 			return "DBD_GOT_CLUSTER_USAGE";
414 		} else
415 			return "Got Cluster Usage";
416 		break;
417 	case DBD_GOT_EVENTS:
418 		if (get_enum) {
419 			return "DBD_GOT_EVENTS";
420 		} else
421 			return "Got Events";
422 		break;
423 	case DBD_GOT_FEDERATIONS:
424 		if (get_enum) {
425 			return "DBD_GOT_FEDERATIONS";
426 		} else
427 			return "Got Federations";
428 		break;
429 	case DBD_GOT_JOBS:
430 		if (get_enum) {
431 			return "DBD_GOT_JOBS";
432 		} else
433 			return "Got Jobs";
434 		break;
435 	case DBD_GOT_LIST:
436 		if (get_enum) {
437 			return "DBD_GOT_LIST";
438 		} else
439 			return "Got List";
440 		break;
441 	case DBD_GOT_PROBS:
442 		if (get_enum) {
443 			return "DBD_GOT_PROBS";
444 		} else
445 			return "Got Problems";
446 		break;
447 	case DBD_GOT_RES:
448 		if (get_enum) {
449 			return "DBD_GOT_RES";
450 		} else
451 			return "Got Resources";
452 		break;
453 	case DBD_GOT_USERS:
454 		if (get_enum) {
455 			return "DBD_GOT_USERS";
456 		} else
457 			return "Got Users";
458 		break;
459 	case DBD_JOB_COMPLETE:
460 		if (get_enum) {
461 			return "DBD_JOB_COMPLETE";
462 		} else
463 			return "Job Complete";
464 		break;
465 	case DBD_JOB_START:
466 		if (get_enum) {
467 			return "DBD_JOB_START";
468 		} else
469 			return "Job Start";
470 		break;
471 	case DBD_ID_RC:
472 		if (get_enum) {
473 			return "DBD_ID_RC";
474 		} else
475 			return "ID RC";
476 		break;
477 	case DBD_JOB_SUSPEND:
478 		if (get_enum) {
479 			return "DBD_JOB_SUSPEND";
480 		} else
481 			return "Job Suspend";
482 		break;
483 	case DBD_MODIFY_ACCOUNTS:
484 		if (get_enum) {
485 			return "DBD_MODIFY_ACCOUNTS";
486 		} else
487 			return "Modify Accounts";
488 		break;
489 	case DBD_MODIFY_ASSOCS:
490 		if (get_enum) {
491 			return "DBD_MODIFY_ASSOCS";
492 		} else
493 			return "Modify Associations";
494 		break;
495 	case DBD_MODIFY_CLUSTERS:
496 		if (get_enum) {
497 			return "DBD_MODIFY_CLUSTERS";
498 		} else
499 			return "Modify Clusters";
500 		break;
501 	case DBD_MODIFY_FEDERATIONS:
502 		if (get_enum) {
503 			return "DBD_MODIFY_FEDERATIONS";
504 		} else
505 			return "Modify Federations";
506 		break;
507 	case DBD_MODIFY_JOB:
508 		if (get_enum) {
509 			return "DBD_MODIFY_JOB";
510 		} else
511 			return "Modify Job";
512 		break;
513 	case DBD_MODIFY_QOS:
514 		if (get_enum) {
515 			return "DBD_MODIFY_QOS";
516 		} else
517 			return "Modify QOS";
518 		break;
519 	case DBD_MODIFY_RES:
520 		if (get_enum) {
521 			return "DBD_MODIFY_RES";
522 		} else
523 			return "Modify Resources";
524 		break;
525 	case DBD_MODIFY_USERS:
526 		if (get_enum) {
527 			return "DBD_MODIFY_USERS";
528 		} else
529 			return "Modify Users";
530 		break;
531 	case DBD_NODE_STATE:
532 		if (get_enum) {
533 			return "DBD_NODE_STATE";
534 		} else
535 			return "Node State";
536 		break;
537 	case DBD_REGISTER_CTLD:
538 		if (get_enum) {
539 			return "DBD_REGISTER_CTLD";
540 		} else
541 			return "Register Cluster";
542 		break;
543 	case DBD_REMOVE_ACCOUNTS:
544 		if (get_enum) {
545 			return "DBD_REMOVE_ACCOUNTS";
546 		} else
547 			return "Remove Accounts";
548 		break;
549 	case DBD_REMOVE_ACCOUNT_COORDS:
550 		if (get_enum) {
551 			return "DBD_REMOVE_ACCOUNT_COORDS";
552 		} else
553 			return "Remove Account Coords";
554 		break;
555 	case DBD_ARCHIVE_DUMP:
556 		if (get_enum) {
557 			return "DBD_ARCHIVE_DUMP";
558 		} else
559 			return "Archive Dump";
560 		break;
561 	case DBD_ARCHIVE_LOAD:
562 		if (get_enum) {
563 			return "DBD_ARCHIVE_LOAD";
564 		} else
565 			return "Archive Load";
566 		break;
567 	case DBD_REMOVE_ASSOCS:
568 		if (get_enum) {
569 			return "DBD_REMOVE_ASSOCS";
570 		} else
571 			return "Remove Associations";
572 		break;
573 	case DBD_REMOVE_CLUSTERS:
574 		if (get_enum) {
575 			return "DBD_REMOVE_CLUSTERS";
576 		} else
577 			return "Remove Clusters";
578 		break;
579 	case DBD_REMOVE_FEDERATIONS:
580 		if (get_enum) {
581 			return "DBD_REMOVE_FEDERATIONS";
582 		} else
583 			return "Remove Federations";
584 		break;
585 	case DBD_REMOVE_RES:
586 		if (get_enum) {
587 			return "DBD_REMOVE_RES";
588 		} else
589 			return "Remove Resources";
590 		break;
591 	case DBD_REMOVE_USERS:
592 		if (get_enum) {
593 			return "DBD_REMOVE_USERS";
594 		} else
595 			return "Remove Users";
596 		break;
597 	case DBD_ROLL_USAGE:
598 		if (get_enum) {
599 			return "DBD_ROLL_USAGE";
600 		} else
601 			return "Roll Usage";
602 		break;
603 	case DBD_STEP_COMPLETE:
604 		if (get_enum) {
605 			return "DBD_STEP_COMPLETE";
606 		} else
607 			return "Step Complete";
608 		break;
609 	case DBD_STEP_START:
610 		if (get_enum) {
611 			return "DBD_STEP_START";
612 		} else
613 			return "Step Start";
614 		break;
615 	case DBD_GET_JOBS_COND:
616 		if (get_enum) {
617 			return "DBD_GET_JOBS_COND";
618 		} else
619 			return "Get Jobs Conditional";
620 		break;
621 	case DBD_GET_TXN:
622 		if (get_enum) {
623 			return "DBD_GET_TXN";
624 		} else
625 			return "Get Transactions";
626 		break;
627 	case DBD_GOT_TXN:
628 		if (get_enum) {
629 			return "DBD_GOT_TXN";
630 		} else
631 			return "Got Transactions";
632 		break;
633 	case DBD_ADD_QOS:
634 		if (get_enum) {
635 			return "DBD_ADD_QOS";
636 		} else
637 			return "Add QOS";
638 		break;
639 	case DBD_GET_QOS:
640 		if (get_enum) {
641 			return "DBD_GET_QOS";
642 		} else
643 			return "Get QOS";
644 		break;
645 	case DBD_GOT_QOS:
646 		if (get_enum) {
647 			return "DBD_GOT_QOS";
648 		} else
649 			return "Got QOS";
650 		break;
651 	case DBD_REMOVE_QOS:
652 		if (get_enum) {
653 			return "DBD_REMOVE_QOS";
654 		} else
655 			return "Remove QOS";
656 		break;
657 	case DBD_ADD_WCKEYS:
658 		if (get_enum) {
659 			return "DBD_ADD_WCKEYS";
660 		} else
661 			return "Add WCKeys";
662 		break;
663 	case DBD_GET_WCKEYS:
664 		if (get_enum) {
665 			return "DBD_GET_WCKEYS";
666 		} else
667 			return "Get WCKeys";
668 		break;
669 	case DBD_GOT_WCKEYS:
670 		if (get_enum) {
671 			return "DBD_GOT_WCKEYS";
672 		} else
673 			return "Got WCKeys";
674 		break;
675 	case DBD_REMOVE_WCKEYS:
676 		if (get_enum) {
677 			return "DBD_REMOVE_WCKEYS";
678 		} else
679 			return "Remove WCKeys";
680 		break;
681 	case DBD_GET_WCKEY_USAGE:
682 		if (get_enum) {
683 			return "DBD_GET_WCKEY_USAGE";
684 		} else
685 			return "Get WCKey Usage";
686 		break;
687 	case DBD_GOT_WCKEY_USAGE:
688 		if (get_enum) {
689 			return "DBD_GOT_WCKEY_USAGE";
690 		} else
691 			return "Got WCKey Usage";
692 		break;
693 	case DBD_ADD_RESV:
694 		if (get_enum) {
695 			return "DBD_ADD_RESV";
696 		} else
697 			return "Add Reservation";
698 		break;
699 	case DBD_REMOVE_RESV:
700 		if (get_enum) {
701 			return "DBD_REMOVE_RESV";
702 		} else
703 			return "Remove Reservation";
704 		break;
705 	case DBD_MODIFY_RESV:
706 		if (get_enum) {
707 			return "DBD_MODIFY_RESV";
708 		} else
709 			return "Modify Reservation";
710 		break;
711 	case DBD_GET_RESVS:
712 		if (get_enum) {
713 			return "DBD_GET_RESVS";
714 		} else
715 			return "Get Reservations";
716 		break;
717 	case DBD_GOT_RESVS:
718 		if (get_enum) {
719 			return "DBD_GOT_RESVS";
720 		} else
721 			return "Got Reservations";
722 		break;
723 	case DBD_GET_CONFIG:
724 		if (get_enum) {
725 			return "DBD_GET_CONFIG";
726 		} else
727 			return "Get Config";
728 		break;
729 	case DBD_GOT_CONFIG:
730 		if (get_enum) {
731 			return "DBD_GOT_CONFIG";
732 		} else
733 			return "Got Config";
734 		break;
735 	case DBD_SEND_MULT_JOB_START:
736 		if (get_enum) {
737 			return "DBD_SEND_MULT_JOB_START";
738 		} else
739 			return "Send Multiple Job Starts";
740 		break;
741 	case DBD_GOT_MULT_JOB_START:
742 		if (get_enum) {
743 			return "DBD_GOT_MULT_JOB_START";
744 		} else
745 			return "Got Multiple Job Starts";
746 		break;
747 	case DBD_SEND_MULT_MSG:
748 		if (get_enum) {
749 			return "DBD_SEND_MULT_MSG";
750 		} else
751 			return "Send Multiple Messages";
752 		break;
753 	case DBD_GOT_MULT_MSG:
754 		if (get_enum) {
755 			return "DBD_GOT_MULT_MSG";
756 		} else
757 			return "Got Multiple Message Returns";
758 		break;
759 	case DBD_GET_STATS:
760 		if (get_enum) {
761 			return "DBD_GET_STATS";
762 		} else
763 			return "Get daemon statistics";
764 		break;
765 	case DBD_GOT_STATS:
766 		if (get_enum) {
767 			return "DBD_GOT_STATS";
768 		} else
769 			return "Got daemon statistics data";
770 		break;
771 	case DBD_CLEAR_STATS:
772 		if (get_enum) {
773 			return "DBD_CLEAR_STATS";
774 		} else
775 			return "Clear daemon statistics";
776 		break;
777 	case DBD_SHUTDOWN:
778 		if (get_enum) {
779 			return "DBD_SHUTDOWN";
780 		} else
781 			return "Shutdown daemon";
782 		break;
783 	case SLURM_PERSIST_INIT:
784 		if (get_enum) {
785 			return "SLURM_PERSIST_INIT";
786 		} else
787 			return "Persistent Connection Initialization";
788 		break;
789 	default:
790 		snprintf(unk_str, sizeof(unk_str), "MsgType=%d", msg_type);
791 		return unk_str;
792 		break;
793 	}
794 }
795 
796 
797 /****************************************************************************\
798  * Free data structures
799 \****************************************************************************/
slurmdbd_free_buffer(void * x)800 extern void slurmdbd_free_buffer(void *x)
801 {
802 	Buf buffer = (Buf) x;
803 	if (buffer)
804 		free_buf(buffer);
805 }
806 
slurmdbd_free_acct_coord_msg(dbd_acct_coord_msg_t * msg)807 extern void slurmdbd_free_acct_coord_msg(dbd_acct_coord_msg_t *msg)
808 {
809 	if (msg) {
810 		FREE_NULL_LIST(msg->acct_list);
811 		slurmdb_destroy_user_cond(msg->cond);
812 		xfree(msg);
813 	}
814 }
815 
slurmdbd_free_cluster_tres_msg(dbd_cluster_tres_msg_t * msg)816 extern void slurmdbd_free_cluster_tres_msg(dbd_cluster_tres_msg_t *msg)
817 {
818 	if (msg) {
819 		xfree(msg->cluster_nodes);
820 		xfree(msg->tres_str);
821 		xfree(msg);
822 	}
823 }
824 
slurmdbd_free_msg(persist_msg_t * msg)825 extern void slurmdbd_free_msg(persist_msg_t *msg)
826 {
827 	switch (msg->msg_type) {
828 	case DBD_ADD_ACCOUNTS:
829 	case DBD_ADD_TRES:
830 	case DBD_ADD_ASSOCS:
831 	case DBD_ADD_CLUSTERS:
832 	case DBD_ADD_FEDERATIONS:
833 	case DBD_ADD_RES:
834 	case DBD_ADD_USERS:
835 	case DBD_GOT_ACCOUNTS:
836 	case DBD_GOT_TRES:
837 	case DBD_GOT_ASSOCS:
838 	case DBD_GOT_CLUSTERS:
839 	case DBD_GOT_EVENTS:
840 	case DBD_GOT_FEDERATIONS:
841 	case DBD_GOT_JOBS:
842 	case DBD_GOT_LIST:
843 	case DBD_GOT_PROBS:
844 	case DBD_GOT_RES:
845 	case DBD_ADD_QOS:
846 	case DBD_GOT_QOS:
847 	case DBD_GOT_RESVS:
848 	case DBD_ADD_WCKEYS:
849 	case DBD_GOT_WCKEYS:
850 	case DBD_GOT_TXN:
851 	case DBD_GOT_USERS:
852 	case DBD_GOT_CONFIG:
853 	case DBD_SEND_MULT_JOB_START:
854 	case DBD_GOT_MULT_JOB_START:
855 	case DBD_SEND_MULT_MSG:
856 	case DBD_GOT_MULT_MSG:
857 	case DBD_FIX_RUNAWAY_JOB:
858 		slurmdbd_free_list_msg(msg->data);
859 		break;
860 	case DBD_ADD_ACCOUNT_COORDS:
861 	case DBD_REMOVE_ACCOUNT_COORDS:
862 		slurmdbd_free_acct_coord_msg(msg->data);
863 		break;
864 	case DBD_ARCHIVE_LOAD:
865 		slurmdb_destroy_archive_rec(msg->data);
866 		break;
867 	case DBD_CLUSTER_TRES:
868 	case DBD_FLUSH_JOBS:
869 		slurmdbd_free_cluster_tres_msg(msg->data);
870 		break;
871 	case DBD_GET_ACCOUNTS:
872 	case DBD_GET_TRES:
873 	case DBD_GET_ASSOCS:
874 	case DBD_GET_CLUSTERS:
875 	case DBD_GET_EVENTS:
876 	case DBD_GET_FEDERATIONS:
877 	case DBD_GET_JOBS_COND:
878 	case DBD_GET_PROBS:
879 	case DBD_GET_QOS:
880 	case DBD_GET_RESVS:
881 	case DBD_GET_RES:
882 	case DBD_GET_TXN:
883 	case DBD_GET_USERS:
884 	case DBD_GET_WCKEYS:
885 	case DBD_REMOVE_ACCOUNTS:
886 	case DBD_REMOVE_ASSOCS:
887 	case DBD_REMOVE_CLUSTERS:
888 	case DBD_REMOVE_FEDERATIONS:
889 	case DBD_REMOVE_QOS:
890 	case DBD_REMOVE_RES:
891 	case DBD_REMOVE_WCKEYS:
892 	case DBD_REMOVE_USERS:
893 	case DBD_ARCHIVE_DUMP:
894 		slurmdbd_free_cond_msg(msg->data, msg->msg_type);
895 		break;
896 	case DBD_GET_ASSOC_USAGE:
897 	case DBD_GOT_ASSOC_USAGE:
898 	case DBD_GET_CLUSTER_USAGE:
899 	case DBD_GOT_CLUSTER_USAGE:
900 	case DBD_GET_WCKEY_USAGE:
901 	case DBD_GOT_WCKEY_USAGE:
902 		slurmdbd_free_usage_msg(msg->data, msg->msg_type);
903 		break;
904 	case DBD_FINI:
905 		slurmdbd_free_fini_msg(msg->data);
906 		break;
907 	case DBD_JOB_COMPLETE:
908 		slurmdbd_free_job_complete_msg(msg->data);
909 		break;
910 	case DBD_JOB_START:
911 		slurmdbd_free_job_start_msg(msg->data);
912 		break;
913 	case DBD_JOB_SUSPEND:
914 		slurmdbd_free_job_suspend_msg(msg->data);
915 		break;
916 	case DBD_MODIFY_ACCOUNTS:
917 	case DBD_MODIFY_ASSOCS:
918 	case DBD_MODIFY_CLUSTERS:
919 	case DBD_MODIFY_FEDERATIONS:
920 	case DBD_MODIFY_JOB:
921 	case DBD_MODIFY_QOS:
922 	case DBD_MODIFY_RES:
923 	case DBD_MODIFY_USERS:
924 		slurmdbd_free_modify_msg(msg->data, msg->msg_type);
925 		break;
926 	case DBD_NODE_STATE:
927 		slurmdbd_free_node_state_msg(msg->data);
928 		break;
929 	case DBD_STEP_COMPLETE:
930 		slurmdbd_free_step_complete_msg(msg->data);
931 		break;
932 	case DBD_STEP_START:
933 		slurmdbd_free_step_start_msg(msg->data);
934 		break;
935 	case DBD_REGISTER_CTLD:
936 		slurmdbd_free_register_ctld_msg(msg->data);
937 		break;
938 	case DBD_ROLL_USAGE:
939 		slurmdbd_free_roll_usage_msg(msg->data);
940 		break;
941 	case DBD_ADD_RESV:
942 	case DBD_REMOVE_RESV:
943 	case DBD_MODIFY_RESV:
944 		slurmdbd_free_rec_msg(msg->data, msg->msg_type);
945 		break;
946 	case DBD_GET_CONFIG:
947 	case DBD_RECONFIG:
948 	case DBD_GET_STATS:
949 	case DBD_CLEAR_STATS:
950 	case DBD_SHUTDOWN:
951 		break;
952 	case SLURM_PERSIST_INIT:
953 		slurm_free_msg(msg->data);
954 		break;
955 	default:
956 		error("%s: Unknown rec type %d(%s)",
957 		      __func__, msg->msg_type,
958 		      slurmdbd_msg_type_2_str(msg->msg_type, true));
959 		return;
960 	}
961 }
962 
slurmdbd_free_rec_msg(dbd_rec_msg_t * msg,slurmdbd_msg_type_t type)963 extern void slurmdbd_free_rec_msg(dbd_rec_msg_t *msg,
964 				  slurmdbd_msg_type_t type)
965 {
966 	void (*my_destroy) (void *object);
967 
968 	if (msg) {
969 		switch (type) {
970 		case DBD_ADD_RESV:
971 		case DBD_REMOVE_RESV:
972 		case DBD_MODIFY_RESV:
973 			my_destroy = slurmdb_destroy_reservation_rec;
974 			break;
975 		default:
976 			fatal("Unknown rec type");
977 			return;
978 		}
979 		if (msg->rec)
980 			(*(my_destroy))(msg->rec);
981 		xfree(msg);
982 	}
983 }
984 
slurmdbd_free_cond_msg(dbd_cond_msg_t * msg,slurmdbd_msg_type_t type)985 extern void slurmdbd_free_cond_msg(dbd_cond_msg_t *msg,
986 				   slurmdbd_msg_type_t type)
987 {
988 	void (*my_destroy) (void *object);
989 
990 	if (msg) {
991 		switch (type) {
992 		case DBD_GET_ACCOUNTS:
993 		case DBD_REMOVE_ACCOUNTS:
994 			my_destroy = slurmdb_destroy_account_cond;
995 			break;
996 		case DBD_GET_TRES:
997 			my_destroy = slurmdb_destroy_tres_cond;
998 			break;
999 		case DBD_GET_ASSOCS:
1000 		case DBD_GET_PROBS:
1001 		case DBD_REMOVE_ASSOCS:
1002 			my_destroy = slurmdb_destroy_assoc_cond;
1003 			break;
1004 		case DBD_GET_CLUSTERS:
1005 		case DBD_REMOVE_CLUSTERS:
1006 			my_destroy = slurmdb_destroy_cluster_cond;
1007 			break;
1008 		case DBD_GET_FEDERATIONS:
1009 		case DBD_REMOVE_FEDERATIONS:
1010 			my_destroy = slurmdb_destroy_federation_cond;
1011 			break;
1012 		case DBD_GET_JOBS_COND:
1013 			my_destroy = slurmdb_destroy_job_cond;
1014 			break;
1015 		case DBD_GET_QOS:
1016 		case DBD_REMOVE_QOS:
1017 			my_destroy = slurmdb_destroy_qos_cond;
1018 			break;
1019 		case DBD_GET_RES:
1020 		case DBD_REMOVE_RES:
1021 			my_destroy = slurmdb_destroy_res_cond;
1022 			break;
1023 		case DBD_GET_WCKEYS:
1024 		case DBD_REMOVE_WCKEYS:
1025 			my_destroy = slurmdb_destroy_wckey_cond;
1026 			break;
1027 		case DBD_GET_TXN:
1028 			my_destroy = slurmdb_destroy_txn_cond;
1029 			break;
1030 		case DBD_GET_USERS:
1031 		case DBD_REMOVE_USERS:
1032 			my_destroy = slurmdb_destroy_user_cond;
1033 			break;
1034 		case DBD_ARCHIVE_DUMP:
1035 			my_destroy = slurmdb_destroy_archive_cond;
1036 			break;
1037 		case DBD_GET_RESVS:
1038 			my_destroy = slurmdb_destroy_reservation_cond;
1039 			break;
1040 		case DBD_GET_EVENTS:
1041 			my_destroy = slurmdb_destroy_event_cond;
1042 			break;
1043 		default:
1044 			fatal("Unknown cond type");
1045 			return;
1046 		}
1047 		if (msg->cond)
1048 			(*(my_destroy))(msg->cond);
1049 		xfree(msg);
1050 	}
1051 }
1052 
slurmdbd_free_fini_msg(dbd_fini_msg_t * msg)1053 extern void slurmdbd_free_fini_msg(dbd_fini_msg_t *msg)
1054 {
1055 	xfree(msg);
1056 }
1057 
slurmdbd_free_job_complete_msg(dbd_job_comp_msg_t * msg)1058 extern void slurmdbd_free_job_complete_msg(dbd_job_comp_msg_t *msg)
1059 {
1060 	if (msg) {
1061 		xfree(msg->admin_comment);
1062 		xfree(msg->comment);
1063 		xfree(msg->nodes);
1064 		xfree(msg->system_comment);
1065 		xfree(msg->tres_alloc_str);
1066 		xfree(msg);
1067 	}
1068 }
1069 
slurmdbd_free_job_start_msg(void * in)1070 extern void slurmdbd_free_job_start_msg(void *in)
1071 {
1072 	dbd_job_start_msg_t *msg = (dbd_job_start_msg_t *)in;
1073 	if (msg) {
1074 		xfree(msg->account);
1075 		xfree(msg->array_task_str);
1076 		xfree(msg->constraints);
1077 		xfree(msg->gres_alloc);
1078 		xfree(msg->gres_req);
1079 		xfree(msg->gres_used);
1080 		xfree(msg->mcs_label);
1081 		xfree(msg->name);
1082 		xfree(msg->nodes);
1083 		xfree(msg->node_inx);
1084 		xfree(msg->partition);
1085 		xfree(msg->tres_alloc_str);
1086 		xfree(msg->tres_req_str);
1087 		xfree(msg->wckey);
1088 		xfree(msg->work_dir);
1089 		xfree(msg);
1090 	}
1091 }
1092 
slurmdbd_free_id_rc_msg(void * in)1093 extern void slurmdbd_free_id_rc_msg(void *in)
1094 {
1095 	dbd_id_rc_msg_t *msg = (dbd_id_rc_msg_t *)in;
1096 	xfree(msg);
1097 }
1098 
slurmdbd_free_job_suspend_msg(dbd_job_suspend_msg_t * msg)1099 extern void slurmdbd_free_job_suspend_msg(dbd_job_suspend_msg_t *msg)
1100 {
1101 	xfree(msg);
1102 }
1103 
slurmdbd_free_list_msg(dbd_list_msg_t * msg)1104 extern void slurmdbd_free_list_msg(dbd_list_msg_t *msg)
1105 {
1106 	if (msg) {
1107 		FREE_NULL_LIST(msg->my_list);
1108 		xfree(msg);
1109 	}
1110 }
1111 
slurmdbd_free_modify_msg(dbd_modify_msg_t * msg,slurmdbd_msg_type_t type)1112 extern void slurmdbd_free_modify_msg(dbd_modify_msg_t *msg,
1113 				     slurmdbd_msg_type_t type)
1114 {
1115 	void (*destroy_cond) (void *object);
1116 	void (*destroy_rec) (void *object);
1117 
1118 	if (msg) {
1119 		switch (type) {
1120 		case DBD_MODIFY_ACCOUNTS:
1121 			destroy_cond = slurmdb_destroy_account_cond;
1122 			destroy_rec = slurmdb_destroy_account_rec;
1123 			break;
1124 		case DBD_MODIFY_ASSOCS:
1125 			destroy_cond = slurmdb_destroy_assoc_cond;
1126 			destroy_rec = slurmdb_destroy_assoc_rec;
1127 			break;
1128 		case DBD_MODIFY_CLUSTERS:
1129 			destroy_cond = slurmdb_destroy_cluster_cond;
1130 			destroy_rec = slurmdb_destroy_cluster_rec;
1131 			break;
1132 		case DBD_MODIFY_FEDERATIONS:
1133 			destroy_cond = slurmdb_destroy_federation_cond;
1134 			destroy_rec = slurmdb_destroy_federation_rec;
1135 			break;
1136 		case DBD_MODIFY_JOB:
1137 			destroy_cond = slurmdb_destroy_job_cond;
1138 			destroy_rec = slurmdb_destroy_job_rec;
1139 			break;
1140 		case DBD_MODIFY_QOS:
1141 			destroy_cond = slurmdb_destroy_qos_cond;
1142 			destroy_rec = slurmdb_destroy_qos_rec;
1143 			break;
1144 		case DBD_MODIFY_RES:
1145 			destroy_cond = slurmdb_destroy_res_cond;
1146 			destroy_rec = slurmdb_destroy_res_rec;
1147 			break;
1148 		case DBD_MODIFY_USERS:
1149 			destroy_cond = slurmdb_destroy_user_cond;
1150 			destroy_rec = slurmdb_destroy_user_rec;
1151 			break;
1152 		default:
1153 			fatal("Unknown modify type");
1154 			return;
1155 		}
1156 
1157 		if (msg->cond)
1158 			(*(destroy_cond))(msg->cond);
1159 		if (msg->rec)
1160 			(*(destroy_rec))(msg->rec);
1161 		xfree(msg);
1162 	}
1163 }
1164 
slurmdbd_free_node_state_msg(dbd_node_state_msg_t * msg)1165 extern void slurmdbd_free_node_state_msg(dbd_node_state_msg_t *msg)
1166 {
1167 	if (msg) {
1168 		xfree(msg->hostlist);
1169 		xfree(msg->reason);
1170 		xfree(msg->tres_str);
1171 		xfree(msg);
1172 	}
1173 }
1174 
slurmdbd_free_register_ctld_msg(dbd_register_ctld_msg_t * msg)1175 extern void slurmdbd_free_register_ctld_msg(dbd_register_ctld_msg_t *msg)
1176 {
1177 	xfree(msg);
1178 }
1179 
slurmdbd_free_roll_usage_msg(dbd_roll_usage_msg_t * msg)1180 extern void slurmdbd_free_roll_usage_msg(dbd_roll_usage_msg_t *msg)
1181 {
1182 	xfree(msg);
1183 }
1184 
slurmdbd_free_step_complete_msg(dbd_step_comp_msg_t * msg)1185 extern void slurmdbd_free_step_complete_msg(dbd_step_comp_msg_t *msg)
1186 {
1187 	if (msg) {
1188 		jobacctinfo_destroy(msg->jobacct);
1189 		xfree(msg->job_tres_alloc_str);
1190 		xfree(msg);
1191 	}
1192 }
1193 
slurmdbd_free_step_start_msg(dbd_step_start_msg_t * msg)1194 extern void slurmdbd_free_step_start_msg(dbd_step_start_msg_t *msg)
1195 {
1196 	if (msg) {
1197 		xfree(msg->name);
1198 		xfree(msg->nodes);
1199 		xfree(msg->node_inx);
1200 		xfree(msg->tres_alloc_str);
1201 		xfree(msg);
1202 	}
1203 }
1204 
slurmdbd_free_usage_msg(dbd_usage_msg_t * msg,slurmdbd_msg_type_t type)1205 extern void slurmdbd_free_usage_msg(dbd_usage_msg_t *msg,
1206 				    slurmdbd_msg_type_t type)
1207 {
1208 	void (*destroy_rec) (void *object);
1209 	if (msg) {
1210 		switch (type) {
1211 		case DBD_GET_ASSOC_USAGE:
1212 		case DBD_GOT_ASSOC_USAGE:
1213 			destroy_rec = slurmdb_destroy_assoc_rec;
1214 			break;
1215 		case DBD_GET_CLUSTER_USAGE:
1216 		case DBD_GOT_CLUSTER_USAGE:
1217 			destroy_rec = slurmdb_destroy_cluster_rec;
1218 			break;
1219 		case DBD_GET_WCKEY_USAGE:
1220 		case DBD_GOT_WCKEY_USAGE:
1221 			destroy_rec = slurmdb_destroy_wckey_rec;
1222 			break;
1223 		default:
1224 			fatal("Unknown usuage type");
1225 			return;
1226 		}
1227 
1228 		if (msg->rec)
1229 			(*(destroy_rec))(msg->rec);
1230 		xfree(msg);
1231 	}
1232 }
1233