rem: Ns_Log(Error, "%s: duplicate host map: %s", module, host);
add: Ns_Log(Error, "%s: duplicate host map: %s", module, vhost);
context: Ns_DriverInit(char *server, char *module, Ns_DriverInitData *init){    char *path,*address, *host, *bindaddr, *defproto;    int i, n, socktimeout, defport;    ServerMap *mapPtr;    Tcl_HashEntry *hPtr;    Ns_DString ds;    Ns_Set *set;    struct in_addr  ia;    struct hostent *he;    Driver *drvPtr;    NsServer *servPtr = NULL;    if (server != NULL && (servPtr = NsGetServer(server)) == NULL) {	Ns_Log(Error, "%s: no such server: %s", module, server);	return NS_ERROR;    }    if (init->version != NS_DRIVER_VERSION_1) {        Ns_Log(Error, "%s: version field of init argument is invalid: %d",                 module, init->version);        return NS_ERROR;    }    path = (init->path ? init->path : Ns_ConfigGetPath(server, module, NULL));    /*     * Determine the hostname used for the local address to bind     * to and/or the HTTP location string.     */    host = Ns_ConfigGetValue(path, "hostname");    bindaddr = address = Ns_ConfigGetValue(path, "address");    /*     * If the listen address was not specified, attempt to determine it     * through a DNS lookup of the specified hostname or the server's     * primary hostname.     */    if (address == NULL) {        he = gethostbyname(host ? host : Ns_InfoHostname());        /*	 * If the lookup suceeded but the resulting hostname does not	 * appear to be fully qualified, attempt a reverse lookup on the	 * address which often returns the fully qualified name.	 *	 * NB: This is a common but sloppy configuration for a Unix	 * network.	 */        if (he != NULL && he->h_name != NULL &&	    strchr(he->h_name, '.') == NULL) {            he = gethostbyaddr(he->h_addr, he->h_length, he->h_addrtype);	}	/*	 * If the lookup suceeded, use the first address in host entry list.	 */        if (he == NULL || he->h_name == NULL) {            Ns_Log(Error, "%s: could not resolve %s: %s", module,		   host ? host : Ns_InfoHostname(), strerror(errno));	    return NS_ERROR;	}        if (*(he->h_addr_list) == NULL) {            Ns_Log(Error, "%s: no addresses for %s", module, he->h_name);	    return NS_ERROR;	}        memcpy(&ia.s_addr, *(he->h_addr_list), sizeof(ia.s_addr));        address = ns_inet_ntoa(ia);	/*	 * Finally, if no hostname was specified, set it to the hostname	 * derived from the lookup(s) above.	 */ 	if (host == NULL) {	    host = he->h_name;	}    }    /*     * If the hostname was not specified and not determined by the lookup     * above, set it to the specified or derived IP address string.     */    if (host == NULL) {	host = address;    }    /*     * Set the protocol and port defaults.     */    if (init->opts & NS_DRIVER_SSL) {	defproto = "https";	defport = 443;    } else {	defproto = "http";	defport = 80;    }    /*     * Allocate a new driver instance and set configurable parameters.     */    Ns_DStringInit(&ds);    drvPtr = ns_calloc(1, sizeof(Driver));    Ns_MutexSetName2(&drvPtr->lock, "ns:drv", module);    if (ns_sockpair(drvPtr->trigger) != 0) {	Ns_Fatal("ns_sockpair() failed: %s", ns_sockstrerror(ns_sockerrno));    }    drvPtr->server = server;    drvPtr->module = module;    drvPtr->name = init->name;    drvPtr->proc = init->proc;    drvPtr->arg = init->arg;    drvPtr->opts = init->opts;    drvPtr->servPtr = servPtr;#define _MAX(x,y)	((x) > (y) ? (x) : (y))#define _MIN(x,y)	((x) > (y) ? (y) : (x))    if (!Ns_ConfigGetInt(path, "bufsize", &n) || n < 1) {         n = 16000; 	/* ~16k */    }    drvPtr->bufsize = _MAX(n, 1024);    if (!Ns_ConfigGetInt(path, "rcvbuf", &n)) {	n = 0;		/* Use OS default. */    }    drvPtr->rcvbuf = _MAX(n, 0);    if (!Ns_ConfigGetInt(path, "sndbuf", &n)) {	n = 0;		/* Use OS default. */    }    drvPtr->sndbuf = _MAX(n, 0);    if (!Ns_ConfigGetInt(path, "socktimeout", &n) || n < 1) {	n = 30;		/* 30 seconds. */    }    socktimeout = n;    if (!Ns_ConfigGetInt(path, "sendwait", &n) || n < 1) {	n = socktimeout; /* Use previous socktimeout option. */    }    drvPtr->sendwait = _MAX(n, 1);    if (!Ns_ConfigGetInt(path, "recvwait", &n) || n < 1) {	n = socktimeout; /* Use previous socktimeout option. */    }    drvPtr->recvwait = _MAX(n, 1);    if (!Ns_ConfigGetInt(path, "closewait", &n) || n < 0) {	n = 2;		/* 2 seconds */    }    drvPtr->closewait = _MAX(n, 0); /* NB: 0 for no graceful close. */    if (!Ns_ConfigGetInt(path, "keepwait", &n) || n < 0) {	n = 30;		/* 30 seconds */    }    drvPtr->keepwait = _MAX(n, 0); /* NB: 0 for no keepalive. */    if (!Ns_ConfigGetInt(path, "backlog", &n) || n < 1) {	n = 5;		/* 5 pending connections. */    }    drvPtr->backlog = _MAX(n, 1);    if (!Ns_ConfigGetInt(path, "maxinput", &n) || n < 1) {	n = 1000 * 1024;	/* 1m. */    }    drvPtr->maxinput = _MAX(n, 1024);    if (!Ns_ConfigGetInt(path, "maxsock", &n) || n < 1) {	n = 100;		/* 100 total sockets. */    }    drvPtr->maxsock = _MAX(n, 1);    if (!Ns_ConfigGetInt(path, "maxreaders", &n) || n < 1) {	n = 10;    }    n = _MAX(n, 1);    n = _MIN(n, drvPtr->maxsock);    drvPtr->readers = ns_calloc(n, sizeof(Ns_Thread));    drvPtr->maxreaders = n;#undef _MAX#undef _MIN    /*     * Determine the port and then set the HTTP location string either     * as specified in the config file or constructed from the     * hostname and port.     */    drvPtr->bindaddr = bindaddr;    drvPtr->address = ns_strdup(address);    if (!Ns_ConfigGetInt(path, "port", &drvPtr->port)) {	drvPtr->port = defport;    }    drvPtr->location = Ns_ConfigGetValue(path, "location");    if (drvPtr->location != NULL) {	drvPtr->location = ns_strdup(drvPtr->location);    } else {	Ns_DStringVarAppend(&ds, defproto, "://", host, NULL);	if (drvPtr->port != defport) {	    Ns_DStringPrintf(&ds, ":%d", drvPtr->port);	}	drvPtr->location = Ns_DStringExport(&ds);    }    drvPtr->nextPtr = firstDrvPtr;    firstDrvPtr = drvPtr;    /*     * Map Host headers for drivers not bound to servers.     */    if (server == NULL) {	path = Ns_ConfigGetPath(NULL, module, "servers", NULL);	set = Ns_ConfigGetSection(path);	for (i = 0; set != NULL && i < Ns_SetSize(set); ++i) {	    server = Ns_SetKey(set, i);	    host = Ns_SetValue(set, i);	    servPtr = NsGetServer(server);	    if (servPtr == NULL) {		Ns_Log(Error, "%s: no such server: %s", module, server);	    } else {		hPtr = Tcl_CreateHashEntry(&hosts, host, &n);		if (!n) {		    Ns_Log(Error, "%s: duplicate host map: %s", module, host);		} else {		    Ns_DStringVarAppend(&ds, defproto, "://", host, NULL);    		    mapPtr = ns_malloc(sizeof(ServerMap) + ds.length);    		    mapPtr->servPtr  = servPtr;		    strcpy(mapPtr->location, ds.string);		    Ns_DStringTrunc(&ds, 0);    		    Tcl_SetHashValue(hPtr, mapPtr);		}	    }	}    }    Ns_DStringFree(&ds);    return NS_OK;}