Browse code

core: print udp sock fd in debug messages of probe_max_receive_buffer()

Daniel-Constantin Mierla authored on 23/11/2021 16:12:48
Showing 1 changed files
... ...
@@ -143,15 +143,15 @@ int probe_max_receive_buffer( int udp_sock )
143 143
 	if (getsockopt( udp_sock, SOL_SOCKET, SO_RCVBUF, (void*) &ioptval,
144 144
 		    &ioptvallen) == -1 )
145 145
 	{
146
-		LM_ERR("getsockopt: %s\n", strerror(errno));
146
+		LM_ERR("fd: %d getsockopt: %s\n", udp_sock, strerror(errno));
147 147
 		return -1;
148 148
 	}
149 149
 	if ( ioptval==0 )
150 150
 	{
151
-		LM_DBG("SO_RCVBUF initially set to 0; resetting to %d\n",
152
-			BUFFER_INCREMENT );
151
+		LM_DBG("SO_RCVBUF initially set to 0 for fd %d; resetting to %d\n",
152
+				udp_sock, BUFFER_INCREMENT);
153 153
 		ioptval=BUFFER_INCREMENT;
154
-	} else LM_INFO("SO_RCVBUF is initially %d\n", ioptval );
154
+	} else LM_INFO("SO_RCVBUF is initially %d for fd %d\n", ioptval, udp_sock);
155 155
 	for (optval=ioptval; ;  ) {
156 156
 		/* increase size; double in initial phase, add linearly later */
157 157
 		if (phase==0) optval <<= 1; else optval+=BUFFER_INCREMENT;
... ...
@@ -160,11 +160,12 @@ int probe_max_receive_buffer( int udp_sock )
160 160
 			else { phase=1; optval >>=1; continue; }
161 161
 		}
162 162
 		if(ksr_verbose_startup)
163
-			LM_DBG("trying SO_RCVBUF: %d\n", optval);
163
+			LM_DBG("trying SO_RCVBUF: %d on fd: %d\n", optval, udp_sock);
164 164
 		if (setsockopt( udp_sock, SOL_SOCKET, SO_RCVBUF,
165 165
 			(void*)&optval, sizeof(optval)) ==-1){
166 166
 			/* Solaris returns -1 if asked size too big; Linux ignores */
167
-			LM_DBG("SOL_SOCKET failed for %d, phase %d: %s\n", optval, phase, strerror(errno));
167
+			LM_DBG("SOL_SOCKET failed for val %d on fd %d, phase %d: %s\n",
168
+					optval, udp_sock, phase, strerror(errno));
168 169
 			/* if setting buffer size failed and still in the aggressive
169 170
 			   phase, try less aggressively; otherwise give up
170 171
 			*/
... ...
@@ -179,14 +180,14 @@ int probe_max_receive_buffer( int udp_sock )
179 180
 		if (getsockopt( udp_sock, SOL_SOCKET, SO_RCVBUF, (void*) &voptval,
180 181
 		    &voptvallen) == -1 )
181 182
 		{
182
-			LM_ERR("getsockopt: %s\n", strerror(errno));
183
+			LM_ERR("fd: %d getsockopt: %s\n", udp_sock, strerror(errno));
183 184
 			return -1;
184 185
 		} else {
185 186
 			if(ksr_verbose_startup)
186
-				LM_DBG("setting SO_RCVBUF; set=%d,verify=%d\n",
187
-						optval, voptval);
187
+				LM_DBG("setting SO_RCVBUF on fd %d; val=%d, verify=%d\n",
188
+						udp_sock, optval, voptval);
188 189
 			if (voptval<optval) {
189
-				LM_DBG("setting SO_RCVBUF has no effect\n");
190
+				LM_DBG("setting SO_RCVBUF on fd %d has no effect\n", udp_sock);
190 191
 				/* if setting buffer size failed and still in the aggressive
191 192
 				phase, try less aggressively; otherwise give up
192 193
 				*/
... ...
@@ -200,10 +201,10 @@ int probe_max_receive_buffer( int udp_sock )
200 201
 	if (getsockopt( udp_sock, SOL_SOCKET, SO_RCVBUF, (void*) &foptval,
201 202
 		    &foptvallen) == -1 )
202 203
 	{
203
-		LM_ERR("getsockopt: %s\n", strerror(errno));
204
+		LM_ERR("fd: %d getsockopt: %s\n", udp_sock, strerror(errno));
204 205
 		return -1;
205 206
 	}
206
-	LM_INFO("SO_RCVBUF is finally %d\n", foptval );
207
+	LM_INFO("SO_RCVBUF is finally %d on fd %d\n", foptval, udp_sock);
207 208
 
208 209
 	return 0;
209 210