Browse Source

kazoo: add missing log line breaks, partially by conversion to mem log helper

Henning Westerholt 6 years ago
parent
commit
5484083570
2 changed files with 18 additions and 18 deletions
  1. 14 14
      src/modules/kazoo/kz_amqp.c
  2. 4 4
      src/modules/kazoo/kz_hash.c

+ 14 - 14
src/modules/kazoo/kz_amqp.c

@@ -140,7 +140,7 @@ static inline str* kz_str_dup(str* src)
 {
 	char *dst_char = (char*)shm_malloc(sizeof(str)+src->len+1);
 	if (!dst_char) {
-		LM_ERR("error allocating shared memory for str");
+		SHM_MEM_ERROR;
 		return NULL;
 	}
 	str* dst = (str*)dst_char;
@@ -157,7 +157,7 @@ static inline str* kz_str_dup_from_char(char* src)
 	int len = strlen(src);
 	char *dst_char = (char*)shm_malloc(sizeof(str)+len+1);
 	if (!dst_char) {
-		LM_ERR("error allocating shared memory for str");
+		SHM_MEM_ERROR;
 		return NULL;
 	}
 	str* dst = (str*)dst_char;
@@ -216,7 +216,7 @@ static inline str* kz_local_str_dup(str* src)
 {
 	char *dst_char = (char*)pkg_malloc(sizeof(str)+src->len+1);
 	if (!dst_char) {
-		LM_ERR("error allocating shared memory for str");
+		SHM_MEM_ERROR;
 		return NULL;
 	}
 	str* dst = (str*)dst_char;
@@ -247,7 +247,7 @@ static inline str* kz_str_from_amqp_bytes(amqp_bytes_t src)
 {
 	char *dst_char = (char*)shm_malloc(sizeof(str)+src.len+1);
 	if (!dst_char) {
-		LM_ERR("error allocating shared memory for str");
+		SHM_MEM_ERROR;
 		return NULL;
 	}
 	str* dst = (str*)dst_char;
@@ -1531,7 +1531,7 @@ kz_amqp_queue_ptr kz_amqp_queue_new(str *name)
 {
 	kz_amqp_queue_ptr queue = (kz_amqp_queue_ptr) shm_malloc(sizeof(kz_amqp_queue));
 	if(queue == NULL) {
-		LM_ERR("NO MORE SHARED MEMORY!");
+		SHM_MEM_ERROR;
 		return NULL;
 	}
 	memset(queue, 0, sizeof(kz_amqp_queue));
@@ -1558,7 +1558,7 @@ kz_amqp_queue_ptr kz_amqp_queue_from_json(str *name, json_object* json_obj)
 	kz_amqp_queue_ptr queue = kz_amqp_queue_new(name);
 
 	if(queue == NULL) {
-		LM_ERR("NO MORE SHARED MEMORY!");
+		SHM_MEM_ERROR;
 		return NULL;
 	}
 
@@ -1601,7 +1601,7 @@ kz_amqp_exchange_ptr kz_amqp_exchange_new(str *name, str* type)
 {
 	kz_amqp_exchange_ptr exchange = (kz_amqp_exchange_ptr) shm_malloc(sizeof(kz_amqp_exchange));
 	if(exchange == NULL) {
-		LM_ERR("NO MORE SHARED MEMORY!");
+		SHM_MEM_ERROR;
 		return NULL;
 	}
 	memset(exchange, 0, sizeof(kz_amqp_exchange));
@@ -1646,7 +1646,7 @@ kz_amqp_exchange_ptr kz_amqp_exchange_from_json(str *name, json_object* json_obj
 
 	exchange = kz_amqp_exchange_new(name, &type);
 	if(exchange == NULL) {
-		LM_ERR("NO MORE SHARED MEMORY!");
+		SHM_MEM_ERROR;
 		return NULL;
 	}
 
@@ -1723,7 +1723,7 @@ kz_amqp_routings_ptr kz_amqp_routing_from_json(json_object* json_obj)
 		break;
 
    	default:
-   		LM_DBG("type not handled in routing");
+		LM_DBG("type not handled in routing\n");
    		break;
    	}
    	return ret;
@@ -1765,7 +1765,7 @@ kz_amqp_exchange_binding_ptr kz_amqp_exchange_binding_from_json(json_object* JOb
 		    	binding->from_exchange = exchange;
 		    	binding->routing = kz_amqp_routing_from_json(routingObj);
 		    	if(binding->routing == NULL) {
-		    		LM_DBG("invalid routing");
+					LM_DBG("invalid routing\n");
 		    		kz_amqp_exchange_bindings_free(binding);
 		    		binding = NULL;
 		    	} else {
@@ -2371,7 +2371,7 @@ void kz_amqp_consumer_event(kz_amqp_consumer_delivery_ptr Evt)
 				if(kz_amqp_consumer_fire_event(buffer) != 0) {
 					sprintf(buffer, "kazoo:consumer-event");
 					if(kz_amqp_consumer_fire_event(buffer) != 0) {
-						LM_ERR("kazoo:consumer-event not found");
+						LM_ERR("kazoo:consumer-event not found\n");
 					}
 				}
             }
@@ -2401,7 +2401,7 @@ void kz_amqp_send_consumer_event_ex(char* payload, char* event_key, char* event_
 {
 	kz_amqp_consumer_delivery_ptr ptr = (kz_amqp_consumer_delivery_ptr) shm_malloc(sizeof(kz_amqp_consumer_delivery));
 	if(ptr == NULL) {
-		LM_ERR("NO MORE SHARED MEMORY!");
+		SHM_MEM_ERROR;
 		return;
 	}
 	memset(ptr, 0, sizeof(kz_amqp_consumer_delivery));
@@ -2467,7 +2467,7 @@ int kz_send_worker_error_event(kz_amqp_cmd_ptr cmd)
 	cmd->return_code = -1;
 	kz_amqp_consumer_delivery_ptr ptr = (kz_amqp_consumer_delivery_ptr) shm_malloc(sizeof(kz_amqp_consumer_delivery));
 	if(ptr == NULL) {
-		LM_ERR("NO MORE SHARED MEMORY!");
+		SHM_MEM_ERROR;
 		return 0;
 	}
 	memset(ptr, 0, sizeof(kz_amqp_consumer_delivery));
@@ -2997,7 +2997,7 @@ void kz_amqp_send_worker_event(kz_amqp_server_ptr server_ptr, amqp_envelope_t* e
 
 	ptr = (kz_amqp_consumer_delivery_ptr) shm_malloc(sizeof(kz_amqp_consumer_delivery));
 	if(ptr == NULL) {
-		LM_ERR("NO MORE SHARED MEMORY!");
+		SHM_MEM_ERROR;
 		goto error;
 	}
 	memset(ptr, 0, sizeof(kz_amqp_consumer_delivery));

+ 4 - 4
src/modules/kazoo/kz_hash.c

@@ -45,7 +45,7 @@ int kz_hash_init()
 
 	if(kz_cmd_htable)
 	{
-		LM_ERR("already initialized");
+		LM_ERR("already initialized\n");
 		return 1;
 	}
 	
@@ -53,7 +53,7 @@ int kz_hash_init()
 	kz_cmd_htable = (kz_amqp_cmd_table_ptr)shm_malloc(dbk_command_table_size* sizeof(kz_amqp_cmd_table));
 	if(kz_cmd_htable == NULL)
 	{
-		LM_ERR("memory error allocating command table");
+		SHM_MEM_ERROR_FMT("command table\n");
 		return 0;
 	}
 	memset(kz_cmd_htable, 0, dbk_command_table_size* sizeof(kz_amqp_cmd_table));
@@ -68,7 +68,7 @@ int kz_hash_init()
 		kz_cmd_htable[i].entries= (kz_amqp_cmd_entry_ptr)shm_malloc(sizeof(kz_amqp_cmd_entry));
 		if(kz_cmd_htable[i].entries== NULL)
 		{
-			LM_ERR("memory error allocating command entry");
+			SHM_MEM_ERROR_FMT("command entry\n");
 			return 0;
 		}
 		memset(kz_cmd_htable[i].entries, 0, sizeof(kz_amqp_cmd_entry));
@@ -154,7 +154,7 @@ int kz_cmd_store(kz_amqp_cmd_ptr cmd)
 	if(p== NULL)
 	{
 		lock_release(&kz_cmd_htable[hash_code].lock);
-		LM_ERR("memory error allocation command pointer\n");
+		SHM_MEM_ERROR_FMT("command pointer\n");
 		return 0;
 	}
 	memset(p, 0, sizeof(kz_amqp_cmd_entry));