[sr-dev] git:master: pt.c: logging: convert LOG to LM_*

Ovidiu Sas osas at voipembedded.com
Sat Oct 4 02:48:58 CEST 2014


Module: sip-router
Branch: master
Commit: 7afea2225e210cd8652dea22f4813d82c20126ee
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=7afea2225e210cd8652dea22f4813d82c20126ee

Author: Ovidiu Sas <osas at voipembedded.com>
Committer: Ovidiu Sas <osas at voipembedded.com>
Date:   Fri Oct  3 20:48:51 2014 -0400

pt.c: logging: convert LOG to LM_*

---

 pt.c |   49 +++++++++++++++++++------------------------------
 1 files changed, 19 insertions(+), 30 deletions(-)

diff --git a/pt.c b/pt.c
index 9721869..bec1c4e 100644
--- a/pt.c
+++ b/pt.c
@@ -122,7 +122,7 @@ int init_pt(int proc_no)
 	process_lock = lock_alloc();
 	process_lock = lock_init(process_lock);
 	if (pt==0||process_count==0||process_lock==0){
-		LOG(L_ERR, "ERROR: out  of memory\n");
+		LM_ERR("out of memory\n");
 		return -1;
 	}
 	memset(pt, 0, sizeof(struct process_table)*estimated_proc_no);
@@ -147,7 +147,7 @@ int init_pt(int proc_no)
 int register_procs(int no)
 {
 	if (pt){
-		LOG(L_CRIT, "BUG: register_procs(%d) called at runtime\n", no);
+		LM_CRIT("(%d) called at runtime\n", no);
 		return -1;
 	}
 	estimated_proc_no+=no;
@@ -160,8 +160,7 @@ int register_procs(int no)
 int get_max_procs()
 {
 	if (pt==0){
-		LOG(L_CRIT, "BUG: get_max_procs() called too early "
-				"(it must _not_ be called from mod_init())\n");
+		LM_CRIT("too early (it must _not_ be called from mod_init())\n");
 		abort(); /* crash to quickly catch offenders */
 	}
 	return estimated_proc_no;
@@ -189,8 +188,7 @@ int register_fds(int no)
 int get_max_open_fds()
 {
 	if (pt==0){
-		LOG(L_CRIT, "BUG: get_max_open_fds() called too early "
-				"(it must _not_ be called from mod_init())\n");
+		LM_CRIT("too early (it must _not_ be called from mod_init())\n");
 		abort(); /* crash to quickly catch offenders */
 	}
 	return estimated_fds_no;
@@ -272,19 +270,18 @@ int fork_process(int child_id, char *desc, int make_sock)
 		sockfd[0]=sockfd[1]=-1;
 		if(make_sock && !tcp_disable){
 			 if (!is_main){
-				 LOG(L_CRIT, "BUG: fork_process(..., 1) called from a non "
+				 LM_CRIT("called from a non "
 						 "\"main\" process! If forking from a module's "
 						 "child_init() fork only if rank==PROC_MAIN or"
 						 " give up tcp send support (use 0 for make_sock)\n");
 				 goto error;
 			 }
 			 if (tcp_main_pid){
-				 LOG(L_CRIT, "BUG: fork_process(..., 1) called, but tcp main "
-						 " is already started\n");
+				 LM_CRIT("called, but tcp main is already started\n");
 				 goto error;
 			 }
 			 if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockfd)<0){
-				LOG(L_ERR, "ERROR: fork_process(): socketpair failed: %s\n",
+				LM_ERR("socketpair failed: %s\n",
 							strerror(errno));
 				goto error;
 			}
@@ -292,8 +289,7 @@ int fork_process(int child_id, char *desc, int make_sock)
 	#endif
 	lock_get(process_lock);
 	if (*process_count>=estimated_proc_no) {
-		LOG(L_CRIT, "ERROR: fork_process(): Process limit of %d exceeded."
-					" Will simulate fork fail.\n", estimated_proc_no);
+		LM_CRIT("Process limit of %d exceeded. Will simulate fork fail.\n", estimated_proc_no);
 		lock_release(process_lock);
 		goto error;
 	}	
@@ -341,9 +337,8 @@ int fork_process(int child_id, char *desc, int make_sock)
 			}
 		#endif		
 		if ((child_id!=PROC_NOCHLDINIT) && (init_child(child_id) < 0)) {
-			LOG(L_ERR, "ERROR: fork_process(): init_child failed for "
-					" process %d, pid %d, \"%s\"\n", process_no,
-					pt[process_no].pid, pt[process_no].desc);
+			LM_ERR("init_child failed for process %d, pid %d, \"%s\"\n",
+					process_no, pt[process_no].pid, pt[process_no].desc);
 			return -1;
 		}
 		return pid;
@@ -405,36 +400,31 @@ int fork_tcp_process(int child_id, char *desc, int r, int *reader_fd_1)
 	ret=-1;
 	
 	if (!is_main){
-		 LOG(L_CRIT, "BUG: fork_tcp_process() called from a non \"main\" "
-				 	"process\n");
+		 LM_CRIT("called from a non \"main\" process\n");
 		 goto error;
 	 }
 	 if (tcp_main_pid){
-		 LOG(L_CRIT, "BUG: fork_tcp_process(..., 1) called _after_ starting"
-				 	" tcp main\n");
+		 LM_CRIT("called _after_ starting tcp main\n");
 		 goto error;
 	 }
 	if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockfd)<0){
-		LOG(L_ERR, "ERROR: fork_tcp_process(): socketpair failed: %s\n",
-					strerror(errno));
+		LM_ERR("socketpair failed: %s\n", strerror(errno));
 		goto error;
 	}
 	if (socketpair(AF_UNIX, SOCK_STREAM, 0, reader_fd)<0){
-		LOG(L_ERR, "ERROR: fork_tcp_process(): socketpair failed: %s\n",
-					strerror(errno));
+		LM_ERR("socketpair failed: %s\n", strerror(errno));
 		goto error;
 	}
 	if (tcp_fix_child_sockets(reader_fd)<0){
-		LOG(L_ERR, "ERROR: fork_tcp_process(): failed to set non blocking"
-					"on child sockets\n");
+		LM_ERR("failed to set non blocking on child sockets\n");
 		/* continue, it's not critical (it will go slower under
 		 * very high connection rates) */
 	}
 	lock_get(process_lock);
 	/* set the local process_no */
 	if (*process_count>=estimated_proc_no) {
-		LOG(L_CRIT, "ERROR: fork_tcp_process(): Process limit of %d exceeded."
-					" Simulating fork fail\n", estimated_proc_no);
+		LM_CRIT("Process limit of %d exceeded. Simulating fork fail\n",
+					estimated_proc_no);
 		lock_release(process_lock);
 		goto error;
 	}
@@ -485,9 +475,8 @@ int fork_tcp_process(int child_id, char *desc, int r, int *reader_fd_1)
 		close(reader_fd[0]);
 		if (reader_fd_1) *reader_fd_1=reader_fd[1];
 		if ((child_id!=PROC_NOCHLDINIT) && (init_child(child_id) < 0)) {
-			LOG(L_ERR, "ERROR: fork_tcp_process(): init_child failed for "
-					"process %d, pid %d, \"%s\"\n", process_no, 
-					pt[process_no].pid, pt[process_no].desc);
+			LM_ERR("init_child failed for process %d, pid %d, \"%s\"\n",
+				process_no, pt[process_no].pid, pt[process_no].desc);
 			return -1;
 		}
 		return pid;




More information about the sr-dev mailing list