[Freeswitch-svn] [commit] r11950 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/sresolv libsofia-sip-ua/sresolv/sofia-resolv

FreeSWITCH SVN mikej at freeswitch.org
Thu Feb 12 13:15:20 PST 2009


Author: mikej
Date: Thu Feb 12 15:15:20 2009
New Revision: 11950

Log:
Thu Feb 12 14:20:26 CST 2009  Pekka Pessi <first.last at nokia.com>
  * sres.c: improve logging upon errors



Modified:
   freeswitch/trunk/libs/sofia-sip/.update
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sofia-resolv/sres_record.h
   freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c

Modified: freeswitch/trunk/libs/sofia-sip/.update
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/.update	(original)
+++ freeswitch/trunk/libs/sofia-sip/.update	Thu Feb 12 15:15:20 2009
@@ -1 +1 @@
-Thu Feb 12 15:14:36 CST 2009
+Thu Feb 12 15:15:10 CST 2009

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sofia-resolv/sres_record.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sofia-resolv/sres_record.h	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sofia-resolv/sres_record.h	Thu Feb 12 15:15:20 2009
@@ -71,7 +71,10 @@
 
   /* Errors generated by sresolv */
   SRES_TIMEOUT_ERR = 32,	/**< Timeout occurred */
-  SRES_RECORD_ERR = 33	        /**< Name has no given record type */
+  SRES_RECORD_ERR = 33,	        /**< Name has no given record type */
+  SRES_INTERNAL_ERR = 34,	/**< Internal error */
+
+  _SRES_LAST_ERR
 };
 
 /** Start of a zone of authority record (@RFC1035). */
@@ -248,6 +251,9 @@
 /** Convert type to its name. */
 SRESPUBFUN char const *sres_record_type(int type, char buffer[8]);
 
+/** Convert status to its name. */
+SRESPUBFUN char const *sres_record_status(int status, char buffer[8]);
+
 /** Compare two records. */
 SRESPUBFUN int sres_record_compare(sres_record_t const *,
 				   sres_record_t const *);

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c	(original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/sresolv/sres.c	Thu Feb 12 15:15:20 2009
@@ -1538,6 +1538,30 @@
   }
 }
 
+/** Convert record status to its name */
+char const *sres_record_status(int status, char buffer[8])
+{
+  switch (status) {
+  case SRES_OK: return "OK";
+  case SRES_FORMAT_ERR: return "FORMAT_ERR";
+  case SRES_SERVER_ERR: return "SERVER_ERR";
+  case SRES_NAME_ERR: return "NAME_ERR";
+  case SRES_UNIMPL_ERR: return "UNIMPL_ERR";
+  case SRES_AUTH_ERR: return "AUTH_ERR";
+
+  /* Errors generated by sresolv */
+  case SRES_TIMEOUT_ERR: return "TIMEOUT_ERR";
+  case SRES_RECORD_ERR: return "RECORD_ERR";
+  case SRES_INTERNAL_ERR: return "INTERNAL_ERR";
+
+  default:
+    if (buffer)
+      sprintf(buffer, "%u?", status & 255);
+    return buffer;
+  }
+}
+
+
 /** Convert class to its name. */
 static char const *
 sres_record_class(int rclass, char buffer[8])
@@ -2899,6 +2923,9 @@
   int i;
 
   if (q->q_callback) {
+    char sbuf[8], tbuf[8];
+    int status = 0;
+
     for (i = 0; i <= SRES_MAX_SEARCH; i++) {
       if (q->q_subqueries[i])	/* a pending query... */
 	return;
@@ -2910,8 +2937,16 @@
       }
     }
 
-    SU_DEBUG_5(("sres(q=%p): reporting errors for %u %s\n",
-		(void *)q, q->q_type, q->q_name));
+    for (i = 0; answers[i]; i++) {
+      status = answers[i]->sr_record->r_status;
+      if (status)
+	break;
+    }
+
+    SU_DEBUG_5(("sres(q=%p): reporting error %s for %s %s\n",
+		(void *)q,
+		sres_record_status(status, sbuf),
+		sres_record_type(q->q_type, tbuf), q->q_name));
 
     sres_remove_query(q->q_res, q, 1);
     (q->q_callback)(q->q_context, q, answers);
@@ -3567,7 +3602,9 @@
   }
 
   if (i < total) {
-    SU_DEBUG_5(("sres_decode_msg: %s\n", "less records than promised"));
+    SU_DEBUG_5(("sres_decode_msg: got %u but expected "
+		"errors=%u an=%u ar=%u ns=%u\n", i, errorcount,
+		m->m_ancount, m->m_arcount, m->m_nscount));
     for (i = 0; i < total; i++)
       sres_cache_free_record(res->res_cache, answers[i]);
     su_free(chome, answers);



More information about the Freeswitch-svn mailing list