Skip to content

Commit 4cc220b

Browse files
committed
Renamed CRITICAL log-level to FATAL
1 parent 649b0a3 commit 4cc220b

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/handlers.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ static int connect_handler(struct io_event *e) {
372372
// TODO check for will_topic != NULL
373373
struct topic *t = topic_get_or_create(&server, will_topic);
374374
if (!t)
375-
log_critical("connect_handler failed: Out of memory");
375+
log_fatal("connect_handler failed: Out of memory");
376376
if (!topic_exists(&server, t->name))
377377
topic_put(&server, t);
378378
// I'm sure that the string will be NUL terminated by unpack function
@@ -391,15 +391,15 @@ static int connect_handler(struct io_event *e) {
391391
};
392392

393393
if (!cc->session->lwt_msg.publish.topic || !cc->session->lwt_msg.publish.payload)
394-
log_critical("connect_handler failed: Out of memory");
394+
log_fatal("connect_handler failed: Out of memory");
395395

396396
cc->session->lwt_msg.header.bits.qos = c->bits.will_qos;
397397
// We must store the retained message in the topic
398398
if (c->bits.will_retain == 1) {
399399
size_t publen = mqtt_size(&cc->session->lwt_msg, NULL);
400400
unsigned char *payload = xmalloc(publen);
401401
if (!payload)
402-
log_critical("connect_handler failed: Out of memory")
402+
log_fatal("connect_handler failed: Out of memory")
403403
mqtt_pack(&cc->session->lwt_msg, payload);
404404
// We got a ready-to-be-sent bytestring in the retained message
405405
// field
@@ -449,11 +449,11 @@ static inline void add_wildcard(const char *topic, struct subscriber *s,
449449
bool wildcard) {
450450
struct subscription *subscription = xmalloc(sizeof(*subscription));
451451
if (!subscription)
452-
log_critical("add_wildcard failed: Out of memory");
452+
log_fatal("add_wildcard failed: Out of memory");
453453
subscription->subscriber = s;
454454
subscription->topic = xstrdup(topic);
455455
if (!subscription->topic)
456-
log_critical("add_wildcard failed: Out of memory");
456+
log_fatal("add_wildcard failed: Out of memory");
457457
subscription->multilevel = wildcard;
458458
INCREF(s, struct subscriber);
459459
server.wildcards = list_push(server.wildcards, subscription);
@@ -516,7 +516,7 @@ static int subscribe_handler(struct io_event *e) {
516516

517517
struct topic *t = topic_get_or_create(&server, topic);
518518
if (!t)
519-
log_critical("subscribe_handler failed: Out of memory");
519+
log_fatal("subscribe_handler failed: Out of memory");
520520
/*
521521
* Let's explore two possible scenarios:
522522
* 1. Normal topic (no single level wildcard '+') which can end with
@@ -666,7 +666,7 @@ static int publish_handler(struct io_event *e) {
666666
*/
667667
struct topic *t = topic_get_or_create(&server, topic);
668668
if (!t)
669-
log_critical("publish_handler failed: Out of memory");
669+
log_fatal("publish_handler failed: Out of memory");
670670

671671
/* Check for # wildcards subscriptions */
672672
if (list_size(server.wildcards) > 0) {
@@ -697,7 +697,7 @@ static int publish_handler(struct io_event *e) {
697697
if (hdr->bits.retain == 1) {
698698
t->retained_msg = xmalloc(mqtt_size(&e->data, NULL));
699699
if (!t->retained_msg)
700-
log_critical("publish_handler failed: Out of memory");
700+
log_fatal("publish_handler failed: Out of memory");
701701
mqtt_pack(&e->data, t->retained_msg);
702702
}
703703
#if THREADSNR > 0

src/server.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,13 +396,13 @@ static void client_init(struct client *client) {
396396
if (!client->rbuf)
397397
client->rbuf = xcalloc(conf->max_request_size, sizeof(unsigned char));
398398
if (!client->rbuf)
399-
log_critical("client_init failed: Out of memory");
399+
log_fatal("client_init failed: Out of memory");
400400
client->wrote = ATOMIC_VAR_INIT(0);
401401
client->towrite = ATOMIC_VAR_INIT(0);
402402
if (!client->wbuf)
403403
client->wbuf = xcalloc(conf->max_request_size, sizeof(unsigned char));
404404
if (!client->wbuf)
405-
log_critical("client_init failed: Out of memory");
405+
log_fatal("client_init failed: Out of memory");
406406
client->last_seen = time(NULL);
407407
client->has_lwt = false;
408408
client->session = NULL;
@@ -980,7 +980,7 @@ int start_server(const char *addr, const char *port) {
980980
for (int i = 0; i < SYS_TOPICS; i++) {
981981
struct topic *t = topic_new(xstrdup(sys_topics[i].name));
982982
if (!t)
983-
log_critical("start_server failed: Out of memory");
983+
log_fatal("start_server failed: Out of memory");
984984
topic_put(&server, t);
985985
}
986986

@@ -1102,10 +1102,10 @@ void session_init(struct client_session *session, const char *session_id) {
11021102
snprintf(session->session_id, MQTT_CLIENT_ID_LEN, "%s", session_id);
11031103
session->i_acks = xcalloc(MAX_INFLIGHT_MSGS, sizeof(time_t));
11041104
if (!session->i_acks)
1105-
log_critical("session_init failed: Out of memory");
1105+
log_fatal("session_init failed: Out of memory");
11061106
session->i_msgs = xcalloc(MAX_INFLIGHT_MSGS, sizeof(struct inflight_msg));
11071107
if (!session->i_msgs)
1108-
log_critical("session_init failed: Out of memory");
1108+
log_fatal("session_init failed: Out of memory");
11091109
session->refcount = (struct ref) { session_free, 0 };
11101110
}
11111111

src/util.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
#define SOL_PREFIX "sol"
3939

40-
enum log_level { DEBUG, INFORMATION, WARNING, ERROR, CRITICAL };
40+
enum log_level { DEBUG, INFORMATION, WARNING, ERROR, FATAL };
4141

4242
bool is_integer(const char *);
4343
int parse_int(const char *);
@@ -70,8 +70,8 @@ long get_fh_soft_limit(void);
7070
#define log_warning(...) log(WARNING, __VA_ARGS__)
7171
#define log_error(...) log(ERROR, __VA_ARGS__)
7272
#define log_info(...) log(INFORMATION, __VA_ARGS__)
73-
#define log_critical(...) do { \
74-
log(CRITICAL, __VA_ARGS__); \
73+
#define log_fatal(...) do { \
74+
log(FATAL, __VA_ARGS__); \
7575
exit(EXIT_FAILURE); \
7676
} while(0);
7777

0 commit comments

Comments
 (0)