Browse code

core: tsend - updated log macros

(cherry picked from commit 83cf43715bf3727b8b618f8239b896ecd83e859a)

Daniel-Constantin Mierla authored on 02/02/2017 10:14:19
Showing 2 changed files
... ...
@@ -55,45 +55,45 @@ poll_loop: \
55 55
 		else{ \
56 56
 			diff=expire-get_ticks_raw(); \
57 57
 			if (diff<=0){ \
58
-				LOG(L_ERR, "ERROR: " f_name ": send timeout (%d)\n", timeout);\
58
+				LM_ERR(" - " f_name ": send timeout (%d)\n", timeout);\
59 59
 				goto error; \
60 60
 			} \
61 61
 			n=poll(&pf, 1, TICKS_TO_MS((ticks_t)diff)); \
62 62
 		} \
63 63
 		if (n<0){ \
64 64
 			if (errno==EINTR) continue; /* signal, ignore */ \
65
-			LOG(L_ERR, "ERROR: " f_name ": poll failed: %s [%d]\n", \
65
+			LM_ERR(" - " f_name ": poll failed: %s [%d]\n", \
66 66
 					strerror(errno), errno); \
67 67
 			goto error; \
68 68
 		}else if (n==0){ \
69 69
 			/* timeout */ \
70
-			LOG(L_ERR, "ERROR: " f_name ": send timeout (p %d)\n", timeout); \
70
+			LM_ERR(" - " f_name ": send timeout (p %d)\n", timeout); \
71 71
 			goto error; \
72 72
 		} \
73 73
 		if (pf.revents&POLLOUT){ \
74 74
 			/* we can write again */ \
75 75
 			goto again; \
76 76
 		}else if (pf.revents&(POLLERR|POLLHUP|POLLNVAL)){ \
77
-			LOG(L_ERR, "ERROR: " f_name ": bad poll flags %x\n", \
77
+			LM_ERR(" - " f_name ": bad poll flags %x\n", \
78 78
 					pf.revents); \
79 79
 			goto error; \
80 80
 		} \
81 81
 		/* if POLLIN or POLLPRI or other non-harmful events happened,    \
82 82
 		 * continue ( although poll should never signal them since we're  \
83 83
 		 * not interested in them => we should never reach this point) */ \
84
-	} 
84
+	}
85 85
 
86 86
 
87 87
 #define TSEND_ERR_CHECK(f_name)\
88 88
 	if (n<0){ \
89 89
 		if (errno==EINTR) goto again; \
90 90
 		else if (errno!=EAGAIN && errno!=EWOULDBLOCK){ \
91
-			LOG(L_ERR, "ERROR: " f_name ": failed to send: (%d) %s\n", \
91
+			LM_ERR(" - " f_name ": failed to send: (%d) %s\n", \
92 92
 					errno, strerror(errno)); \
93 93
 			goto error; \
94 94
 		}else goto poll_loop; \
95 95
 	}
96
-	
96
+
97 97
 
98 98
 
99 99
 /* sends on fd (which must be O_NONBLOCK if you want a finite timeout); if it
... ...
@@ -108,7 +108,7 @@ int tsend_stream(int fd, const char* buf, unsigned int len, int timeout)
108 108
 {
109 109
 	int written;
110 110
 	TSEND_INIT;
111
-	
111
+
112 112
 	written=0;
113 113
 again:
114 114
 	n=send(fd, buf, len,
... ...
@@ -119,13 +119,13 @@ again:
119 119
 #endif
120 120
 		);
121 121
 	TSEND_ERR_CHECK("tsend_stream");
122
-	written+=n; 
123
-	if (n<(int)len){ 
124
-		/* partial write */ 
125
-		buf+=n; 
126
-		len-=n; 
127
-	}else{ 
128
-		/* successful full write */ 
122
+	written+=n;
123
+	if (n<(int)len){
124
+		/* partial write */
125
+		buf+=n;
126
+		len-=n;
127
+	}else{
128
+		/* successful full write */
129 129
 		return written;
130 130
 	}
131 131
 	TSEND_POLL("tsend_stream");
... ...
@@ -141,14 +141,14 @@ error:
141 141
  *  (if less than len => couldn't send all)
142 142
  *  bugs: signals will reset the timer
143 143
  */
144
-int tsend_dgram(int fd, const char* buf, unsigned int len, 
144
+int tsend_dgram(int fd, const char* buf, unsigned int len,
145 145
 				const struct sockaddr* to, socklen_t tolen, int timeout)
146 146
 {
147 147
 	TSEND_INIT;
148 148
 again:
149 149
 	n=sendto(fd, buf, len, 0, to, tolen);
150 150
 	TSEND_ERR_CHECK("tsend_dgram");
151
-	/* we don't care about partial writes: they shouldn't happen on 
151
+	/* we don't care about partial writes: they shouldn't happen on
152 152
 	 * a datagram socket */
153 153
 	return n;
154 154
 	TSEND_POLL("tsend_datagram");
... ...
@@ -156,8 +156,8 @@ error:
156 156
 	return -1;
157 157
 }
158 158
 
159
-	
160
-/* sends on connected datagram fd (which must be O_NONBLOCK); 
159
+
160
+/* sends on connected datagram fd (which must be O_NONBLOCK);
161 161
  * if it cannot send any data in timeout milliseconds it will return ERROR
162 162
  * returns: -1 on error, or number of bytes written
163 163
  *  (if less than len => couldn't send all)
... ...
@@ -23,7 +23,7 @@
23 23
 
24 24
 
25 25
 int tsend_stream(int fd, const char* buf, unsigned int len, int timeout);
26
-int tsend_dgram(int fd, const char* buf, unsigned int len, 
26
+int tsend_dgram(int fd, const char* buf, unsigned int len,
27 27
 				const struct sockaddr* to, socklen_t tolen, int timeout);
28 28
 int tsend_dgram_ev(int fd, const struct iovec* v, int count, int timeout);
29 29