From grdetil@scrc.umanitoba.ca Thu Jul  5 12:10:44 2001
Date: Thu, 5 Jul 2001 11:19:08 -0500 (CDT)
From: Gilles Detillieux <grdetil@scrc.umanitoba.ca>
To: Geoff Hutchison <ghutchis@wso.williams.edu>
Cc: Andreas Vogt <a_vogt@gaia.de>, htdig-general@lists.sourceforge.net
Subject: Re: [htdig] problems compiling htdig 3.2.0b3

According to Geoff Hutchison:
> At 12:00 AM +0000 7/3/01, Andreas Vogt wrote:
> >I wanted to test the new beta Version 3.2.0b3
> >[snip]
> >I examined in Display.cc that neither DBL_MAX nor MAXFLOAT are defined !?
> 
> Grab the latest snapshot from <http://www.htdig.org/files/snapshots/>

The latest snapshot may compile, but it likely won't run.  There are some
pretty serious problems with it.  You can either wait until this Sunday's
snapshot (070801), or use the 070101 snapshot and apply the following patch.

--- htdig/Retriever.cc.orig	Wed May 16 12:43:09 2001
+++ htdig/Retriever.cc	Tue Jul  3 12:09:38 2001
@@ -1009,6 +1009,7 @@ Retriever::GetLocal(const String &strurl
     static StringList *paths = 0;
     StringList *defaultdocs = 0;
     URL aUrl(url);
+    url = aUrl.get();		// make sure we look at a parsed URL
 
     //
     // Initialize prefix/path list if this is the first time.
--- htcommon/URL.cc.orig	Sun Jun 24 02:14:04 2001
+++ htcommon/URL.cc	Wed Jul  4 23:36:09 2001
@@ -307,6 +307,8 @@ void URL::parse(const String &u)
 	_port = 0;
 	_url = 0;
 	_path = p;
+	if (strcmp((char*)_service, "file") == 0)
+	  _host = "localhost";
     }
     else
     {
@@ -682,12 +684,12 @@ void URL::ServerAlias()
   String *al= 0;
   int newport;
   int delim;
-  _signature = _host;
-  _signature << ':' << _port;
-  if ((al= (String *) serveraliases->Find(_signature)))
+  String serversig = _host;
+  serversig << ':' << _port;
+  if ((al= (String *) serveraliases->Find(serversig)))
     {
       delim= al->indexOf(':');
-      // fprintf(stderr, "\nOld URL: %s->%s\n", (char *) _signature, (char *) *al);
+      // fprintf(stderr, "\nOld URL: %s->%s\n", (char *) serversig, (char *) *al);
       _host= al->sub(0,delim).get();
       sscanf((char*)al->sub(delim+1), "%d", &newport);
       _port= newport;
--- htnet/Connection.cc.orig	Fri May  4 07:42:33 2001
+++ htnet/Connection.cc	Tue Jul  3 13:41:56 2001
@@ -62,8 +62,8 @@ Connection::Connection()
 {
     sock = -1;
     connected = 0;
-    peer = 0;
-    server_name = 0;
+    peer = "";
+    server_name = "";
     all_connections.Add(this);
     timeout_value = 0;
     retry_value = 1;
@@ -89,8 +89,8 @@ Connection::Connection(int socket)
     {
 	perror("getpeername");
     }
-    peer = 0;
-    server_name = 0;
+    peer = "";
+    server_name = "";
     all_connections.Add(this);
     timeout_value = 0;
     retry_value = 1;
@@ -106,8 +106,6 @@ Connection::~Connection()
 {
     all_connections.Remove(this);
     this->Close();
-    delete peer;
-    free(server_name);
 }
 
 
@@ -251,8 +249,7 @@ int Connection::Assign_Server(const Stri
 	memcpy((char *)&server.sin_addr, (char *)&addr, sizeof(addr));
     }
 
-    if(server_name) free(server_name);
-    server_name = strdup(name);
+    server_name = name.get();
 
     return OK;
 }
@@ -713,7 +710,7 @@ extern "C" char *inet_ntoa(struct in_add
 //
 char *Connection::Get_Peername()
 {
-    if (!peer)
+    if (peer.empty())
     {
 	struct sockaddr_in	p;
 	GETPEERNAME_LENGTH_T	length = sizeof(p);
@@ -727,11 +724,11 @@ char *Connection::Get_Peername()
 	length = sizeof(p.sin_addr);
 	hp = gethostbyaddr((const char *) &p.sin_addr, length, AF_INET);
 	if (hp)
-	    peer = strdup((char *) hp->h_name);
+	    peer = (char *) hp->h_name;
 	else
-	    peer = strdup((char *) inet_ntoa(p.sin_addr));
+	    peer = (char *) inet_ntoa(p.sin_addr);
     }
-    return peer;
+    return peer.get();
 }
 
 
@@ -740,14 +737,14 @@ char *Connection::Get_Peername()
 //
 char *Connection::Get_PeerIP()
 {
-    struct sockaddr_in	peer;
-    GETPEERNAME_LENGTH_T	length = sizeof(peer);
+    struct sockaddr_in	p;
+    GETPEERNAME_LENGTH_T	length = sizeof(p);
     
-    if (getpeername(sock, (struct sockaddr *) &peer, &length) < 0)
+    if (getpeername(sock, (struct sockaddr *) &p, &length) < 0)
     {
 	return 0;
     }
-    return inet_ntoa(peer.sin_addr);
+    return inet_ntoa(p.sin_addr);
 }
 
 #ifdef NEED_PROTO_GETHOSTNAME
--- htnet/Connection.h.orig	Sat Mar 17 16:45:49 2001
+++ htnet/Connection.h	Fri Jun 29 17:58:39 2001
@@ -19,6 +19,7 @@
 #define	_Connection_h_
 
 #include "Object.h"
+#include "htString.h"
 
 #include <stdlib.h>
 #include <sys/types.h>
@@ -26,7 +27,7 @@
 #include <netinet/in.h>
 #include <netdb.h>
 
-class String;
+//class String;
 
 class Connection : public Object
 {
@@ -54,7 +55,7 @@ public:
     // Host stuff
     int				Assign_Server(const String& name);
     int				Assign_Server(unsigned int addr = INADDR_ANY);
-    char		       *Get_Server()		{return server_name;}
+    char		       *Get_Server()		{return server_name.get();}
 
     // Connection establishment
     virtual int			Connect();
@@ -104,8 +105,8 @@ private:
     int				sock;
     struct sockaddr_in		server;
     int				connected;
-    char			*peer;
-    char			*server_name;
+    String			peer;
+    String			server_name;
     int				need_io_stop;
     int                         timeout_value;
     int                         retry_value;
--- htnet/HtHTTP.cc.orig	Fri May  4 07:42:33 2001
+++ htnet/HtHTTP.cc	Tue Jul  3 13:42:27 2001
@@ -124,7 +124,8 @@ HtHTTP::HtHTTP()
    _useproxy = 0;
 
    // Create a new Connection object, as long as HTTP needs a TCP conn
-   _connection = new Connection();
+   // This is now done in HtHTTPBasic or HtHTTPSecure constructor...
+   //_connection = new Connection();
 
 }
 
@@ -133,8 +134,10 @@ HtHTTP::HtHTTP()
 HtHTTP::~HtHTTP()
 {
    // Let's delete the connection object
+   CloseConnection();
    if (_connection)
       delete (_connection);
+   _connection = 0;
 }
 
 
--- htnet/HtHTTPBasic.cc.orig	Sat Mar 17 16:45:49 2001
+++ htnet/HtHTTPBasic.cc	Tue Jul  3 13:42:51 2001
@@ -43,6 +43,9 @@ HtHTTPBasic::~HtHTTPBasic()
 {
   // Free up the Connection
   //
-  delete _connection;
+  CloseConnection();
+  if (_connection)
+    delete _connection;
+  _connection = 0;
 }
 
--- htnet/HtHTTPSecure.cc.orig	Sat Mar 17 16:45:49 2001
+++ htnet/HtHTTPSecure.cc	Tue Jul  3 13:42:59 2001
@@ -45,7 +45,10 @@ HtHTTPSecure::~HtHTTPSecure()
 {
   // Free up the connection
   //
-  delete _connection;
+  CloseConnection();
+  if (_connection)
+    delete _connection;
+  _connection = 0;
 }
 
 #endif
--- htnet/HtNNTP.cc.orig	Sat Mar 17 16:45:49 2001
+++ htnet/HtNNTP.cc	Tue Jul  3 13:44:43 2001
@@ -109,7 +109,10 @@ HtNNTP::~HtNNTP()
 {
   // Free the connection
   //
-  delete _connection;
+  CloseConnection();
+  if (_connection)
+    delete _connection;
+  _connection = 0;
 }
 
 
--- htnet/Transport.cc.orig	Fri May  4 07:42:33 2001
+++ htnet/Transport.cc	Tue Jul  3 13:41:40 2001
@@ -309,8 +309,11 @@ int Transport::CloseConnection()
 {
    if( _connection == 0 )
      {
-       cout << "Transport::CloseConnection: _connection is NULL\n";
-       exit(0);
+       // We can't treat this as a fatal error, because CloseConnection()
+       // may be called from our destructor after _connection already deleted.
+//     cout << "Transport::CloseConnection: _connection is NULL\n";
+//     exit(0);
+       return 0;
      }
 
    if(_connection->IsOpen())
--- test/document.cc.orig	Thu Oct 19 22:40:59 2000
+++ test/document.cc	Wed Jul  4 11:59:46 2001
@@ -85,11 +85,12 @@ int main(int ac, char **av)
 
 static void dodoc(params_t* params)
 {
-  config.Defaults(&defaults[0]);
-  config.Read(params->config);
+  HtConfiguration* const config= HtConfiguration::config();
+  config->Defaults(&defaults[0]);
+  config->Read(params->config);
 
   DocumentDB docs;
-  if(docs.Read(config["doc_db"], config["doc_index"], config["doc_excerpt"]) < 0) {
+  if(docs.Read(config->Find("doc_db"), config->Find("doc_index"), config->Find("doc_excerpt")) < 0) {
     cerr << "dodoc: cannot open\n";
     exit(1);
   }
--- test/url.cc.orig	Thu Oct 19 22:41:00 2000
+++ test/url.cc	Wed Jul  4 12:01:54 2001
@@ -48,7 +48,6 @@ typedef struct {
   int test_children;
 } params_t;
 
-static HtConfiguration	config;
 
 static void usage();
 static void dourl(params_t* params);
@@ -105,7 +104,8 @@ static void dourl(params_t* params)
 {
   if(verbose) cerr << "Test WordKey class with " <<
 		params->url_parents << " and " << params->url_children << "\n";
-  config.Defaults(defaults);
+  HtConfiguration* const config= HtConfiguration::config();
+  config->Defaults(defaults);
   dolist(params);
 }
 
--- test/testnet.cc.orig	Fri Mar  3 04:34:32 2000
+++ test/testnet.cc	Wed Jul  4 13:43:54 2001
@@ -5,6 +5,7 @@
 
 #include "Transport.h"
 #include "HtHTTP.h"
+#include "HtHTTPBasic.h"
 #include "HtDateTime.h"
 #include <URL.h>
 #include <iostream.h>
@@ -334,7 +335,7 @@ Transport::DocStatus Retrieve()
             if (debug>1)
             cout << "Creating an HtHTTP object" << endl;
       
-            HTTPConnect = new HtHTTP();
+            HTTPConnect = new HtHTTPBasic();
 
             if (!HTTPConnect)
                reportError(strerror(errno));
@@ -346,7 +347,8 @@ Transport::DocStatus Retrieve()
             
 	    HTTPConnect->SetRequestURL(*url);
 
-            // Set the referer
+            // Let's disable the cookies for this test
+	    HTTPConnect->DisableCookies();
 
             // We may issue a config paramater to enable/disable them
             if (!persistent) HTTPConnect->DisablePersistentConnection();

-- 
Gilles R. Detillieux              E-mail: <grdetil@scrc.umanitoba.ca>
Spinal Cord Research Centre       WWW:    http://www.scrc.umanitoba.ca/~grdetil
Dept. Physiology, U. of Manitoba  Phone:  (204)789-3766
Winnipeg, MB  R3E 3J7  (Canada)   Fax:    (204)789-3930

_______________________________________________
htdig-general mailing list <htdig-general@lists.sourceforge.net>
To unsubscribe, send a message to <htdig-general-request@lists.sourceforge.net> with a subject of unsubscribe
FAQ: http://htdig.sourceforge.net/FAQ.html
