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

Ovidiu Sas osas at voipembedded.com
Fri Oct 3 22:07:36 CEST 2014


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

Author: Ovidiu Sas <osas at voipembedded.com>
Committer: Ovidiu Sas <osas at voipembedded.com>
Date:   Fri Oct  3 16:07:26 2014 -0400

io_wait.c: logging: convert LOG to LM_*

---

 io_wait.c |   61 +++++++++++++++++++++++++------------------------------------
 1 files changed, 25 insertions(+), 36 deletions(-)

diff --git a/io_wait.c b/io_wait.c
index 1493283..9a80700 100644
--- a/io_wait.c
+++ b/io_wait.c
@@ -118,8 +118,8 @@ static int init_sigio(io_wait_h* h, int rsig)
 		n=SIGRTMAX-SIGRTMIN;
 	}else{
 		if ((rsig < SIGRTMIN) || (rsig >SIGRTMAX)){
-			LOG(L_CRIT, "ERROR: init_sigio: real time signal %d out of"
-					          " range  [%d, %d]\n", rsig, SIGRTMIN, SIGRTMAX);
+			LM_CRIT("real time signal %d out of range  [%d, %d]\n",
+					rsig, SIGRTMIN, SIGRTMAX);
 			goto error;
 		}
 		start_sig=rsig;
@@ -132,8 +132,7 @@ retry1:
 	/* get current block mask */
 	if (sigprocmask(SIG_BLOCK, &h->sset, &oldset )==-1){
 		if (errno==EINTR) goto retry1;
-		LOG(L_ERR, "ERROR: init_sigio: 1st sigprocmask failed: %s [%d]\n",
-				strerror(errno), errno);
+		LM_ERR("1st sigprocmask failed: %s [%d]\n", strerror(errno), errno);
 		/* try to continue */
 	}
 	
@@ -149,8 +148,7 @@ retry1:
 	}
 	
 	if (h->signo==0){
-			LOG(L_CRIT, "ERROR: init_sigio: %s\n",
-					rsig?"could not assign requested real-time signal":
+			LM_CRIT("%s\n", rsig?"could not assign requested real-time signal":
 						 "out of real-time signals");
 			goto error;
 	}
@@ -158,19 +156,19 @@ retry1:
 	DBG("init_sigio: trying signal %d... \n", h->signo);
 	
 	if (sigaddset(&h->sset, h->signo)==-1){
-		LOG(L_ERR, "ERROR: init_sigio: sigaddset failed for %d: %s [%d]\n",
+		LM_ERR("sigaddset failed for %d: %s [%d]\n",
 				h->signo, strerror(errno), errno);
 		goto error;
 	}
 	if (sigaddset(&h->sset, SIGIO)==-1){
-		LOG(L_ERR, "ERROR: init_sigio: sigaddset failed for %d: %s [%d]\n",
+		LM_ERR("sigaddset failed for %d: %s [%d]\n",
 				SIGIO, strerror(errno), errno);
 		goto error;
 	}
 retry:
 	if (sigprocmask(SIG_BLOCK, &h->sset, 0)==-1){
 		if (errno==EINTR) goto retry;
-		LOG(L_ERR, "ERROR: init_sigio: sigprocmask failed: %s [%d]\n",
+		LM_ERR("sigprocmask failed: %s [%d]\n",
 				strerror(errno), errno);
 		goto error;
 	}
@@ -206,8 +204,7 @@ again:
 	h->epfd=epoll_create(h->max_fd_no);
 	if (h->epfd==-1){
 		if (errno==EINTR) goto again;
-		LOG(L_ERR, "ERROR: init_epoll: epoll_create: %s [%d]\n",
-				strerror(errno), errno);
+		LM_ERR("epoll_create: %s [%d]\n", strerror(errno), errno);
 		return -1;
 	}
 	return 0;
@@ -235,8 +232,7 @@ again:
 	h->kq_fd=kqueue();
 	if (h->kq_fd==-1){
 		if (errno==EINTR) goto again;
-		LOG(L_ERR, "ERROR: init_kqueue: kqueue: %s [%d]\n",
-				strerror(errno), errno);
+		LM_ERR("kqueue: %s [%d]\n", strerror(errno), errno);
 		return -1;
 	}
 	return 0;
@@ -264,8 +260,7 @@ again:
 	h->dpoll_fd=open("/dev/poll", O_RDWR);
 	if (h->dpoll_fd==-1){
 		if (errno==EINTR) goto again;
-		LOG(L_ERR, "ERROR: init_/dev/poll: open: %s [%d]\n",
-				strerror(errno), errno);
+		LM_ERR("open: %s [%d]\n", strerror(errno), errno);
 		return -1;
 	}
 	return 0;
@@ -478,11 +473,11 @@ int init_io_wait(io_wait_h* h, int max_fd, enum poll_types poll_method)
 	if (poll_err || (poll_method==0)){
 		poll_method=choose_poll_method();
 		if (poll_err){
-			LOG(L_ERR, "ERROR: init_io_wait: %s, using %s instead\n",
+			LM_ERR("%s, using %s instead\n",
 					poll_err, poll_method_str[poll_method]);
 		}else{
-			LOG(L_INFO, "init_io_wait: using %s as the io watch method"
-					" (auto detected)\n", poll_method_str[poll_method]);
+			LM_INFO("using %s as the io watch method (auto detected)\n",
+					poll_method_str[poll_method]);
 		}
 	}
 	
@@ -491,8 +486,7 @@ int init_io_wait(io_wait_h* h, int max_fd, enum poll_types poll_method)
 	/* common stuff, everybody has fd_hash */
 	h->fd_hash=local_malloc(sizeof(*(h->fd_hash))*h->max_fd_no);
 	if (h->fd_hash==0){
-		LOG(L_CRIT, "ERROR: init_io_wait: could not alloc"
-					" fd hashtable (%ld bytes)\n",
+		LM_CRIT("could not alloc fd hashtable (%ld bytes)\n",
 					(long)sizeof(*(h->fd_hash))*h->max_fd_no );
 		goto error;
 	}
@@ -511,27 +505,26 @@ int init_io_wait(io_wait_h* h, int max_fd, enum poll_types poll_method)
 #endif
 			h->fd_array=local_malloc(sizeof(*(h->fd_array))*h->max_fd_no);
 			if (h->fd_array==0){
-				LOG(L_CRIT, "ERROR: init_io_wait: could not"
-							" alloc fd array (%ld bytes)\n",
-							(long)sizeof(*(h->fd_hash))*h->max_fd_no);
+				LM_CRIT("could not alloc fd array (%ld bytes)\n",
+						(long)sizeof(*(h->fd_hash))*h->max_fd_no);
 				goto error;
 			}
 			memset((void*)h->fd_array, 0, sizeof(*(h->fd_array))*h->max_fd_no);
 #ifdef HAVE_SIGIO_RT
 			if ((poll_method==POLL_SIGIO_RT) && (init_sigio(h, 0)<0)){
-				LOG(L_CRIT, "ERROR: init_io_wait: sigio init failed\n");
+				LM_CRIT("sigio init failed\n");
 				goto error;
 			}
 #endif
 #ifdef HAVE_DEVPOLL
 			if ((poll_method==POLL_DEVPOLL) && (init_devpoll(h)<0)){
-				LOG(L_CRIT, "ERROR: init_io_wait: /dev/poll init failed\n");
+				LM_CRIT("/dev/poll init failed\n");
 				goto error;
 			}
 #endif
 #ifdef HAVE_SELECT
 			if ((poll_method==POLL_SELECT) && (init_select(h)<0)){
-				LOG(L_CRIT, "ERROR: init_io_wait: select init failed\n");
+				LM_CRIT("select init failed\n");
 				goto error;
 			}
 #endif
@@ -542,13 +535,12 @@ int init_io_wait(io_wait_h* h, int max_fd, enum poll_types poll_method)
 		case POLL_EPOLL_ET:
 			h->ep_array=local_malloc(sizeof(*(h->ep_array))*h->max_fd_no);
 			if (h->ep_array==0){
-				LOG(L_CRIT, "ERROR: init_io_wait: could not alloc"
-							" epoll array\n");
+				LM_CRIT("could not alloc epoll array\n");
 				goto error;
 			}
 			memset((void*)h->ep_array, 0, sizeof(*(h->ep_array))*h->max_fd_no);
 			if (init_epoll(h)<0){
-				LOG(L_CRIT, "ERROR: init_io_wait: epoll init failed\n");
+				LM_CRIT("epoll init failed\n");
 				goto error;
 			}
 			break;
@@ -566,15 +558,13 @@ int init_io_wait(io_wait_h* h, int max_fd, enum poll_types poll_method)
 			h->kq_array_size=2 * h->max_fd_no + h->kq_changes_size;
 			h->kq_array=local_malloc(sizeof(*(h->kq_array))*h->kq_array_size);
 			if (h->kq_array==0){
-				LOG(L_CRIT, "ERROR: init_io_wait: could not alloc"
-							" kqueue event array\n");
+				LM_CRIT("could not alloc kqueue event array\n");
 				goto error;
 			}
 			h->kq_changes=local_malloc(sizeof(*(h->kq_changes))*
 										h->kq_changes_size);
 			if (h->kq_changes==0){
-				LOG(L_CRIT, "ERROR: init_io_wait: could not alloc"
-							" kqueue changes array\n");
+				LM_CRIT("could not alloc kqueue changes array\n");
 				goto error;
 			}
 			h->kq_nchanges=0;
@@ -583,14 +573,13 @@ int init_io_wait(io_wait_h* h, int max_fd, enum poll_types poll_method)
 			memset((void*)h->kq_changes, 0,
 						sizeof(*(h->kq_changes))* h->kq_changes_size);
 			if (init_kqueue(h)<0){
-				LOG(L_CRIT, "ERROR: init_io_wait: kqueue init failed\n");
+				LM_CRIT("kqueue init failed\n");
 				goto error;
 			}
 			break;
 #endif
 		default:
-			LOG(L_CRIT, "BUG: init_io_wait: unknown/unsupported poll"
-						" method %s (%d)\n",
+			LM_CRIT("unknown/unsupported poll method %s (%d)\n",
 						poll_method_str[poll_method], poll_method);
 			goto error;
 	}




More information about the sr-dev mailing list