2 * collectd - src/mcelog.c
5 * Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
26 * Maryam Tahhan <maryam.tahhan@intel.com>
27 * Volodymyr Mytnyk <volodymyrx.mytnyk@intel.com>
28 * Taras Chornyi <tarasx.chornyi@intel.com>
29 * Krzysztof Matczak <krzysztofx.matczak@intel.com>
35 #include "utils_llist.h"
38 #include <sys/socket.h>
42 #define MCELOG_PLUGIN "mcelog"
43 #define MCELOG_BUFF_SIZE 1024
44 #define MCELOG_POLL_TIMEOUT 1000 /* ms */
45 #define MCELOG_SOCKET_STR "SOCKET"
46 #define MCELOG_DIMM_NAME "DMI_NAME"
47 #define MCELOG_CORRECTED_ERR "corrected memory errors"
48 #define MCELOG_UNCORRECTED_ERR "uncorrected memory errors"
49 #define MCELOG_CORRECTED_ERR_TIMED "corrected memory timed errors"
50 #define MCELOG_UNCORRECTED_ERR_TIMED "uncorrected memory timed errors"
51 #define MCELOG_CORRECTED_ERR_TYPE_INS "corrected_memory_errors"
52 #define MCELOG_UNCORRECTED_ERR_TYPE_INS "uncorrected_memory_errors"
54 typedef struct mcelog_config_s {
55 char logfile[PATH_MAX]; /* mcelog logfile */
56 pthread_t tid; /* poll thread id */
57 llist_t *dimms_list; /* DIMMs list */
58 pthread_mutex_t dimms_lock; /* lock for dimms cache */
62 typedef struct socket_adapter_s socket_adapter_t;
64 struct socket_adapter_s {
65 int sock_fd; /* mcelog server socket fd */
66 struct sockaddr_un unix_sock; /* mcelog client socket */
67 pthread_rwlock_t lock;
68 /* function pointers for socket operations */
69 int (*write)(socket_adapter_t *self, const char *msg, const size_t len);
70 int (*reinit)(socket_adapter_t *self);
71 int (*receive)(socket_adapter_t *self, FILE **p_file);
72 int (*close)(socket_adapter_t *self);
75 typedef struct mcelog_memory_rec_s {
76 int corrected_err_total; /* x total*/
77 int corrected_err_timed; /* x in 24h*/
78 char corrected_err_timed_period[DATA_MAX_NAME_LEN / 2];
79 int uncorrected_err_total; /* x total*/
80 int uncorrected_err_timed; /* x in 24h*/
81 char uncorrected_err_timed_period[DATA_MAX_NAME_LEN / 2];
82 char location[DATA_MAX_NAME_LEN / 2]; /* SOCKET x CHANNEL x DIMM x*/
83 char dimm_name[DATA_MAX_NAME_LEN / 2]; /* DMI_NAME "DIMM_F1" */
84 } mcelog_memory_rec_t;
86 static int socket_close(socket_adapter_t *self);
87 static int socket_write(socket_adapter_t *self, const char *msg,
89 static int socket_reinit(socket_adapter_t *self);
90 static int socket_receive(socket_adapter_t *self, FILE **p_file);
92 static mcelog_config_t g_mcelog_config = {
93 .logfile = "/var/log/mcelog", .persist = 0,
96 static socket_adapter_t socket_adapter = {
100 .sun_family = AF_UNIX, .sun_path = "/var/run/mcelog-client",
102 .lock = PTHREAD_RWLOCK_INITIALIZER,
103 .close = socket_close,
104 .write = socket_write,
105 .reinit = socket_reinit,
106 .receive = socket_receive,
109 static _Bool mcelog_thread_running;
110 static _Bool mcelog_apply_defaults;
112 static void mcelog_free_dimms_list_records(llist_t *dimms_list) {
114 for (llentry_t *e = llist_head(dimms_list); e != NULL; e = e->next) {
120 /* Create or get dimm by dimm name/location */
121 static llentry_t *mcelog_dimm(const mcelog_memory_rec_t *rec,
122 llist_t *dimms_list) {
124 char dimm_name[DATA_MAX_NAME_LEN];
126 if (strlen(rec->dimm_name) > 0) {
127 snprintf(dimm_name, sizeof(dimm_name), "%s_%s", rec->location,
130 sstrncpy(dimm_name, rec->location, sizeof(dimm_name));
132 llentry_t *dimm_le = llist_search(g_mcelog_config.dimms_list, dimm_name);
137 /* allocate new linked list entry */
138 mcelog_memory_rec_t *dimm_mr = calloc(1, sizeof(*dimm_mr));
139 if (dimm_mr == NULL) {
140 ERROR(MCELOG_PLUGIN ": Error allocating dimm memory item");
143 char *p_name = strdup(dimm_name);
144 if (p_name == NULL) {
145 ERROR(MCELOG_PLUGIN ": strdup: error");
151 dimm_le = llentry_create(p_name, dimm_mr);
152 if (dimm_le == NULL) {
153 ERROR(MCELOG_PLUGIN ": llentry_create(): error");
158 pthread_mutex_lock(&g_mcelog_config.dimms_lock);
159 llist_append(g_mcelog_config.dimms_list, dimm_le);
160 pthread_mutex_unlock(&g_mcelog_config.dimms_lock);
165 static void mcelog_update_dimm_stats(llentry_t *dimm,
166 const mcelog_memory_rec_t *rec) {
167 pthread_mutex_lock(&g_mcelog_config.dimms_lock);
168 memcpy(dimm->value, rec, sizeof(mcelog_memory_rec_t));
169 pthread_mutex_unlock(&g_mcelog_config.dimms_lock);
172 static int mcelog_config(oconfig_item_t *ci) {
173 int use_logfile = 0, use_memory = 0;
174 for (int i = 0; i < ci->children_num; i++) {
175 oconfig_item_t *child = ci->children + i;
176 if (strcasecmp("McelogLogfile", child->key) == 0) {
179 ERROR(MCELOG_PLUGIN ": Invalid configuration option: \"%s\", Memory "
180 "option is already configured.",
184 if (cf_util_get_string_buffer(child, g_mcelog_config.logfile,
185 sizeof(g_mcelog_config.logfile)) < 0) {
186 ERROR(MCELOG_PLUGIN ": Invalid configuration option: \"%s\".",
190 memset(socket_adapter.unix_sock.sun_path, 0,
191 sizeof(socket_adapter.unix_sock.sun_path));
192 } else if (strcasecmp("Memory", child->key) == 0) {
194 ERROR(MCELOG_PLUGIN ": Invalid configuration option: \"%s\", Logfile "
195 "option is already configured.",
200 for (int j = 0; j < child->children_num; j++) {
201 oconfig_item_t *mem_child = child->children + j;
202 if (strcasecmp("McelogClientSocket", mem_child->key) == 0) {
203 if (cf_util_get_string_buffer(
204 mem_child, socket_adapter.unix_sock.sun_path,
205 sizeof(socket_adapter.unix_sock.sun_path)) < 0) {
206 ERROR(MCELOG_PLUGIN ": Invalid configuration option: \"%s\".",
210 } else if (strcasecmp("PersistentNotification", mem_child->key) == 0) {
211 if (cf_util_get_boolean(mem_child, &g_mcelog_config.persist) < 0) {
212 ERROR(MCELOG_PLUGIN ": Invalid configuration option: \"%s\".",
217 ERROR(MCELOG_PLUGIN ": Invalid Memory configuration option: \"%s\".",
222 memset(g_mcelog_config.logfile, 0, sizeof(g_mcelog_config.logfile));
224 ERROR(MCELOG_PLUGIN ": Invalid configuration option: \"%s\".",
230 if (!use_logfile && !use_memory)
231 mcelog_apply_defaults = 1;
236 static int socket_close(socket_adapter_t *self) {
238 pthread_rwlock_rdlock(&self->lock);
239 if (fcntl(self->sock_fd, F_GETFL) != -1) {
240 if (shutdown(self->sock_fd, SHUT_RDWR) != 0) {
241 ERROR(MCELOG_PLUGIN ": Socket shutdown failed: %s", STRERRNO);
244 if (close(self->sock_fd) != 0) {
245 ERROR(MCELOG_PLUGIN ": Socket close failed: %s", STRERRNO);
249 pthread_rwlock_unlock(&self->lock);
253 static int socket_write(socket_adapter_t *self, const char *msg,
256 pthread_rwlock_rdlock(&self->lock);
257 if (swrite(self->sock_fd, msg, len) != 0)
259 pthread_rwlock_unlock(&self->lock);
263 static void mcelog_dispatch_notification(notification_t *n) {
265 ERROR(MCELOG_PLUGIN ": %s: NULL pointer", __FUNCTION__);
269 sstrncpy(n->host, hostname_g, sizeof(n->host));
270 sstrncpy(n->type, "gauge", sizeof(n->type));
271 plugin_dispatch_notification(n);
273 plugin_notification_meta_free(n->meta);
276 static int socket_reinit(socket_adapter_t *self) {
278 cdtime_t interval = plugin_get_interval();
279 struct timeval socket_timeout = CDTIME_T_TO_TIMEVAL(interval);
281 /* synchronization via write lock since sock_fd may be changed here */
282 pthread_rwlock_wrlock(&self->lock);
284 socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
285 if (self->sock_fd < 0) {
286 ERROR(MCELOG_PLUGIN ": Could not create a socket. %s", STRERRNO);
287 pthread_rwlock_unlock(&self->lock);
291 /* Set socket timeout option */
292 if (setsockopt(self->sock_fd, SOL_SOCKET, SO_SNDTIMEO, &socket_timeout,
293 sizeof(socket_timeout)) < 0)
294 ERROR(MCELOG_PLUGIN ": Failed to set the socket timeout option.");
296 /* downgrading to read lock due to possible recursive read locks
297 * in self->close(self) call */
298 pthread_rwlock_unlock(&self->lock);
299 pthread_rwlock_rdlock(&self->lock);
300 if (connect(self->sock_fd, (struct sockaddr *)&(self->unix_sock),
301 sizeof(self->unix_sock)) < 0) {
302 ERROR(MCELOG_PLUGIN ": Failed to connect to mcelog server. %s", STRERRNO);
307 mcelog_dispatch_notification(
308 &(notification_t){.severity = NOTIF_OKAY,
310 .message = "Connected to mcelog server",
311 .plugin = MCELOG_PLUGIN,
312 .type_instance = "mcelog_status"});
314 pthread_rwlock_unlock(&self->lock);
318 static int mcelog_dispatch_mem_notifications(const mcelog_memory_rec_t *mr) {
319 notification_t n = {.severity = NOTIF_WARNING,
321 .plugin = MCELOG_PLUGIN,
324 int dispatch_corrected_notifs = 0, dispatch_uncorrected_notifs = 0;
329 llentry_t *dimm = mcelog_dimm(mr, g_mcelog_config.dimms_list);
332 ": Error adding/getting dimm memory item to/from cache");
335 mcelog_memory_rec_t *mr_old = dimm->value;
336 if (!g_mcelog_config.persist) {
338 if (mr_old->corrected_err_total != mr->corrected_err_total ||
339 mr_old->corrected_err_timed != mr->corrected_err_timed)
340 dispatch_corrected_notifs = 1;
342 if (mr_old->uncorrected_err_total != mr->uncorrected_err_total ||
343 mr_old->uncorrected_err_timed != mr->uncorrected_err_timed)
344 dispatch_uncorrected_notifs = 1;
346 if (!dispatch_corrected_notifs && !dispatch_uncorrected_notifs) {
347 DEBUG("%s: No new notifications to dispatch", MCELOG_PLUGIN);
351 dispatch_corrected_notifs = 1;
352 dispatch_uncorrected_notifs = 1;
355 sstrncpy(n.host, hostname_g, sizeof(n.host));
357 if (mr->dimm_name[0] != '\0')
358 snprintf(n.plugin_instance, sizeof(n.plugin_instance), "%s_%s",
359 mr->location, mr->dimm_name);
361 sstrncpy(n.plugin_instance, mr->location, sizeof(n.plugin_instance));
363 if (dispatch_corrected_notifs &&
364 (mr->corrected_err_total > 0 || mr->corrected_err_timed > 0)) {
365 /* Corrected Error Notifications */
366 plugin_notification_meta_add_signed_int(&n, MCELOG_CORRECTED_ERR,
367 mr->corrected_err_total);
368 plugin_notification_meta_add_signed_int(&n, MCELOG_CORRECTED_ERR_TIMED,
369 mr->corrected_err_timed);
370 snprintf(n.message, sizeof(n.message), MCELOG_CORRECTED_ERR);
371 sstrncpy(n.type_instance, MCELOG_CORRECTED_ERR_TYPE_INS,
372 sizeof(n.type_instance));
373 plugin_dispatch_notification(&n);
375 plugin_notification_meta_free(n.meta);
379 if (dispatch_uncorrected_notifs &&
380 (mr->uncorrected_err_total > 0 || mr->uncorrected_err_timed > 0)) {
381 /* Uncorrected Error Notifications */
382 plugin_notification_meta_add_signed_int(&n, MCELOG_UNCORRECTED_ERR,
383 mr->uncorrected_err_total);
384 plugin_notification_meta_add_signed_int(&n, MCELOG_UNCORRECTED_ERR_TIMED,
385 mr->uncorrected_err_timed);
386 snprintf(n.message, sizeof(n.message), MCELOG_UNCORRECTED_ERR);
387 sstrncpy(n.type_instance, MCELOG_UNCORRECTED_ERR_TYPE_INS,
388 sizeof(n.type_instance));
389 n.severity = NOTIF_FAILURE;
390 plugin_dispatch_notification(&n);
392 plugin_notification_meta_free(n.meta);
399 static int mcelog_submit(const mcelog_memory_rec_t *mr) {
402 ERROR(MCELOG_PLUGIN ": %s: NULL pointer", __FUNCTION__);
406 llentry_t *dimm = mcelog_dimm(mr, g_mcelog_config.dimms_list);
409 ": Error adding/getting dimm memory item to/from cache");
415 .values = &(value_t){.derive = (derive_t)mr->corrected_err_total},
417 .plugin = MCELOG_PLUGIN,
419 .type_instance = MCELOG_CORRECTED_ERR_TYPE_INS};
421 mcelog_update_dimm_stats(dimm, mr);
423 if (mr->dimm_name[0] != '\0')
424 snprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s_%s",
425 mr->location, mr->dimm_name);
427 sstrncpy(vl.plugin_instance, mr->location, sizeof(vl.plugin_instance));
429 plugin_dispatch_values(&vl);
431 snprintf(vl.type_instance, sizeof(vl.type_instance),
432 "corrected_memory_errors_in_%s", mr->corrected_err_timed_period);
433 vl.values = &(value_t){.derive = (derive_t)mr->corrected_err_timed};
434 plugin_dispatch_values(&vl);
436 sstrncpy(vl.type_instance, MCELOG_UNCORRECTED_ERR_TYPE_INS,
437 sizeof(vl.type_instance));
438 vl.values = &(value_t){.derive = (derive_t)mr->uncorrected_err_total};
439 plugin_dispatch_values(&vl);
441 snprintf(vl.type_instance, sizeof(vl.type_instance),
442 "uncorrected_memory_errors_in_%s", mr->uncorrected_err_timed_period);
443 vl.values = &(value_t){.derive = (derive_t)mr->uncorrected_err_timed};
444 plugin_dispatch_values(&vl);
449 static int parse_memory_info(FILE *p_file, mcelog_memory_rec_t *memory_record) {
450 char buf[DATA_MAX_NAME_LEN] = {0};
451 while (fgets(buf, sizeof(buf), p_file)) {
452 /* Got empty line or "done" */
453 if ((!strncmp("\n", buf, strlen(buf))) ||
454 (!strncmp(buf, "done\n", strlen(buf))))
458 if (!strncmp(buf, MCELOG_SOCKET_STR, strlen(MCELOG_SOCKET_STR))) {
459 sstrncpy(memory_record->location, buf, strlen(buf));
460 /* replace spaces with '_' */
461 for (size_t i = 0; i < strlen(memory_record->location); i++)
462 if (memory_record->location[i] == ' ')
463 memory_record->location[i] = '_';
464 DEBUG(MCELOG_PLUGIN ": Got SOCKET INFO %s", memory_record->location);
466 if (!strncmp(buf, MCELOG_DIMM_NAME, strlen(MCELOG_DIMM_NAME))) {
468 char *saveptr = NULL;
469 name = strtok_r(buf, "\"", &saveptr);
470 if (name != NULL && saveptr != NULL) {
471 name = strtok_r(NULL, "\"", &saveptr);
473 sstrncpy(memory_record->dimm_name, name,
474 sizeof(memory_record->dimm_name));
475 DEBUG(MCELOG_PLUGIN ": Got DIMM NAME %s", memory_record->dimm_name);
479 if (!strncmp(buf, MCELOG_CORRECTED_ERR, strlen(MCELOG_CORRECTED_ERR))) {
481 if (fgets(buf, sizeof(buf), p_file) != NULL) {
482 sscanf(buf, "\t%d total", &(memory_record->corrected_err_total));
483 DEBUG(MCELOG_PLUGIN ": Got corrected error total %d",
484 memory_record->corrected_err_total);
486 if (fgets(buf, sizeof(buf), p_file) != NULL) {
487 sscanf(buf, "\t%d in %s", &(memory_record->corrected_err_timed),
488 memory_record->corrected_err_timed_period);
489 DEBUG(MCELOG_PLUGIN ": Got timed corrected errors %d in %s",
490 memory_record->corrected_err_total,
491 memory_record->corrected_err_timed_period);
494 if (!strncmp(buf, MCELOG_UNCORRECTED_ERR, strlen(MCELOG_UNCORRECTED_ERR))) {
495 if (fgets(buf, sizeof(buf), p_file) != NULL) {
496 sscanf(buf, "\t%d total", &(memory_record->uncorrected_err_total));
497 DEBUG(MCELOG_PLUGIN ": Got uncorrected error total %d",
498 memory_record->uncorrected_err_total);
500 if (fgets(buf, sizeof(buf), p_file) != NULL) {
501 sscanf(buf, "\t%d in %s", &(memory_record->uncorrected_err_timed),
502 memory_record->uncorrected_err_timed_period);
503 DEBUG(MCELOG_PLUGIN ": Got timed uncorrected errors %d in %s",
504 memory_record->uncorrected_err_total,
505 memory_record->uncorrected_err_timed_period);
508 memset(buf, 0, sizeof(buf));
510 /* parsing definitely finished */
514 static void poll_worker_cleanup(void *arg) {
515 mcelog_thread_running = 0;
516 FILE *p_file = *((FILE **)arg);
522 static int socket_receive(socket_adapter_t *self, FILE **pp_file) {
524 pthread_rwlock_rdlock(&self->lock);
525 struct pollfd poll_fd = {
526 .fd = self->sock_fd, .events = POLLIN | POLLPRI,
529 if ((res = poll(&poll_fd, 1, MCELOG_POLL_TIMEOUT)) <= 0) {
530 if (res != 0 && errno != EINTR) {
531 ERROR("mcelog: poll failed: %s", STRERRNO);
533 pthread_rwlock_unlock(&self->lock);
537 if (poll_fd.revents & (POLLERR | POLLHUP | POLLNVAL)) {
538 /* connection is broken */
539 ERROR(MCELOG_PLUGIN ": Connection to socket is broken");
540 if (poll_fd.revents & (POLLERR | POLLHUP)) {
541 mcelog_dispatch_notification(
542 &(notification_t){.severity = NOTIF_FAILURE,
544 .message = "Connection to mcelog socket is broken.",
545 .plugin = MCELOG_PLUGIN,
546 .type_instance = "mcelog_status"});
548 pthread_rwlock_unlock(&self->lock);
552 if (!(poll_fd.revents & (POLLIN | POLLPRI))) {
553 INFO(MCELOG_PLUGIN ": No data to read");
554 pthread_rwlock_unlock(&self->lock);
558 if ((*pp_file = fdopen(dup(self->sock_fd), "r")) == NULL)
561 pthread_rwlock_unlock(&self->lock);
565 static void *poll_worker(__attribute__((unused)) void *arg) {
566 mcelog_thread_running = 1;
567 FILE **pp_file = calloc(1, sizeof(*pp_file));
568 if (pp_file == NULL) {
569 ERROR("mcelog: memory allocation failed: %s", STRERRNO);
570 pthread_exit((void *)1);
573 pthread_cleanup_push(poll_worker_cleanup, pp_file);
577 int res = socket_adapter.receive(&socket_adapter, pp_file);
579 socket_adapter.close(&socket_adapter);
580 while (socket_adapter.reinit(&socket_adapter) != 0) {
581 nanosleep(&CDTIME_T_TO_TIMESPEC(MS_TO_CDTIME_T(MCELOG_POLL_TIMEOUT)),
586 /* timeout or no data to read */
590 if (*pp_file == NULL)
593 mcelog_memory_rec_t memory_record = {0};
594 while (parse_memory_info(*pp_file, &memory_record)) {
595 /* Check if location was successfully parsed */
596 if (memory_record.location[0] == '\0') {
597 memset(&memory_record, 0, sizeof(memory_record));
601 if (mcelog_dispatch_mem_notifications(&memory_record) != 0)
602 ERROR(MCELOG_PLUGIN ": Failed to submit memory errors notification");
603 if (mcelog_submit(&memory_record) != 0)
604 ERROR(MCELOG_PLUGIN ": Failed to submit memory errors");
605 memset(&memory_record, 0, sizeof(memory_record));
612 mcelog_thread_running = 0;
613 pthread_cleanup_pop(1);
617 static int mcelog_init(void) {
618 if (mcelog_apply_defaults) {
620 ": No configuration selected defaulting to memory errors.");
621 memset(g_mcelog_config.logfile, 0, sizeof(g_mcelog_config.logfile));
623 g_mcelog_config.dimms_list = llist_create();
624 int err = pthread_mutex_init(&g_mcelog_config.dimms_lock, NULL);
626 ERROR(MCELOG_PLUGIN ": plugin: failed to initialize cache lock");
630 if (socket_adapter.reinit(&socket_adapter) != 0) {
631 ERROR(MCELOG_PLUGIN ": Cannot connect to client socket");
635 if (strlen(socket_adapter.unix_sock.sun_path)) {
636 if (plugin_thread_create(&g_mcelog_config.tid, NULL, poll_worker, NULL,
638 ERROR(MCELOG_PLUGIN ": Error creating poll thread.");
645 static int get_memory_machine_checks(void) {
646 static const char dump[] = "dump all bios\n";
647 int ret = socket_adapter.write(&socket_adapter, dump, sizeof(dump));
649 ERROR(MCELOG_PLUGIN ": SENT DUMP REQUEST FAILED");
651 DEBUG(MCELOG_PLUGIN ": SENT DUMP REQUEST OK");
655 static int mcelog_read(__attribute__((unused)) user_data_t *ud) {
656 DEBUG(MCELOG_PLUGIN ": %s", __FUNCTION__);
658 if (get_memory_machine_checks() != 0)
659 ERROR(MCELOG_PLUGIN ": MACHINE CHECK INFO NOT AVAILABLE");
664 static int mcelog_shutdown(void) {
666 if (mcelog_thread_running) {
667 pthread_cancel(g_mcelog_config.tid);
668 if (pthread_join(g_mcelog_config.tid, NULL) != 0) {
669 ERROR(MCELOG_PLUGIN ": Stopping thread failed.");
673 pthread_mutex_lock(&g_mcelog_config.dimms_lock);
674 mcelog_free_dimms_list_records(g_mcelog_config.dimms_list);
675 llist_destroy(g_mcelog_config.dimms_list);
676 g_mcelog_config.dimms_list = NULL;
677 pthread_mutex_unlock(&g_mcelog_config.dimms_lock);
678 pthread_mutex_destroy(&g_mcelog_config.dimms_lock);
679 ret = socket_adapter.close(&socket_adapter) || ret;
680 pthread_rwlock_destroy(&(socket_adapter.lock));
684 void module_register(void) {
685 plugin_register_complex_config(MCELOG_PLUGIN, mcelog_config);
686 plugin_register_init(MCELOG_PLUGIN, mcelog_init);
687 plugin_register_complex_read(NULL, MCELOG_PLUGIN, mcelog_read, 0, NULL);
688 plugin_register_shutdown(MCELOG_PLUGIN, mcelog_shutdown);