Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 112128) +++ channels/chan_sip.c (working copy) @@ -2531,7 +2531,11 @@ var = ast_load_realtime("sippeers", "name", newpeername, "host", "dynamic", NULL); if (!var && sin) var = ast_load_realtime("sippeers", "name", newpeername, "host", ast_inet_ntoa(sin->sin_addr), NULL); - if (!var) { + /* checking for the existence of sin here is an optimization since below, there is a + * comparison made using it. If it is non-existent, then we can skip the next realtime + * and dns lookups since they will end up not being useful. + */ + if (!var && sin) { var = ast_load_realtime("sippeers", "name", newpeername, NULL); /*!\note * If this one loaded something, then we need to ensure that the host