瀏覽代碼

To fix a bug that caused assertion failure in ares_strerror:
* src/NameResolver.cc (callback): Fixed the bug.

Tatsuhiro Tsujikawa 19 年之前
父節點
當前提交
d63e6fb052
共有 3 個文件被更改,包括 15 次插入3 次删除
  1. 3 0
      ChangeLog
  2. 9 0
      src/NameResolver.cc
  3. 3 3
      src/SharedHandle.h

+ 3 - 0
ChangeLog

@@ -8,6 +8,9 @@
 	(executeInternal): Made filename URL-decoded.
 	* src/Util.h (urldecode): New function.
 	* src/Util.cc (urldecode): New function.
+
+	To fix a bug that caused assertion failure in ares_strerror:
+	* src/NameResolver.cc (callback): Fixed the bug.
 	
 2006-08-27  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 

+ 9 - 0
src/NameResolver.cc

@@ -23,6 +23,15 @@
 
 void callback(void* arg, int status, struct hostent* host) {
   NameResolver* resolverPtr = (NameResolver*)arg;
+#ifdef HAVE_LIBARES
+  // This block is required since the assertion in ares_strerror fails
+  // if status = ARES_EDESTRUCTION is passed to ares_strerror as 1st argument.
+  // This does not happen in c-ares.
+  if(status == ARES_EDESTRUCTION) {
+    // we simply return in this case.
+    return;
+  }
+#endif
   if(status != ARES_SUCCESS) {
 #ifdef HAVE_LIBCARES
     resolverPtr->error = ares_strerror(status);

+ 3 - 3
src/SharedHandle.h

@@ -47,7 +47,7 @@ private:
 public:
   SharedHandle():obj(new T()), ucount(new int(1)) {}
   SharedHandle(T* obj):obj(obj), ucount(new int(1)) {}
-  SharedHandle(const SharedHandle<T>& t):obj(t.get()), ucount(t.getRefCount()) {
+  SharedHandle(const SharedHandle& t):obj(t.get()), ucount(t.getRefCount()) {
     ++*ucount;
   }
   template<class S>
@@ -62,7 +62,7 @@ public:
     }
   }
 
-  SharedHandle<T>& operator=(const SharedHandle<T>& t) { 
+  SharedHandle& operator=(const SharedHandle& t) { 
     ++*t.getRefCount();
     if(--*ucount == 0) {
       delete obj;
@@ -73,7 +73,7 @@ public:
     return *this;
   }
   template<class S>
-  SharedHandle<T>& operator=(const SharedHandle<S>& t) { 
+  SharedHandle& operator=(const SharedHandle<S>& t) { 
     ++*t.getRefCount();
     if(--*ucount == 0) {
       delete obj;