Index: TODO =================================================================== diff -u -r40c99702db40bd86761bfea1f1209cc761e61e62 -r696ef3ae9b9f8f70e3c1813510f4721056f1ab8a --- TODO (.../TODO) (revision 40c99702db40bd86761bfea1f1209cc761e61e62) +++ TODO (.../TODO) (revision 696ef3ae9b9f8f70e3c1813510f4721056f1ab8a) @@ -3173,6 +3173,10 @@ "... require class method" * extended regression test +- library/mongodb: + * replaced NsfMongoGetHostPort() with the newly available + function mongo_parse_host() + TODO: - zzz why is the method recompiled for /tmp/sp.tcl ? debug output with VAR_RESOLVER_TRACE Index: library/mongodb/nsfmongo.c =================================================================== diff -u -r11a710e482b254fe98e3574a34e070c30d2e6ae5 -r696ef3ae9b9f8f70e3c1813510f4721056f1ab8a --- library/mongodb/nsfmongo.c (.../nsfmongo.c) (revision 11a710e482b254fe98e3574a34e070c30d2e6ae5) +++ library/mongodb/nsfmongo.c (.../nsfmongo.c) (revision 696ef3ae9b9f8f70e3c1813510f4721056f1ab8a) @@ -390,69 +390,6 @@ return TCL_OK; } -/* - *---------------------------------------------------------------------- - * - * NsfMongoGetHostPort -- - * - * Obtain from the provided string host and port. The provided - * string might be of the form "host" or "host:port". The parts - * are returned via arguments. - * - * Results: - * Tcl result code and variables bufferPtr, hostPtr and portPtr. - * If bufferPtr is not NULL, the caller must free it. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ -/* -The entries of the list might be "host" (dns or ip -* addresses) or of the form "host:port".*/ -static int -NsfMongoGetHostPort(CONST char *string, - char **bufferPtr, char CONST**hostPtr, int *portPtr) { - CONST char *colon, *host; - int port; - - assert(string); - colon = strchr(string, ':'); - - if (colon) { - /* - * The passed string contained a colon; we must copy the entry, - * since string is read only. - */ - int length = strlen(string) + 1; - int offset = colon-string; - char *buffer; - - buffer = ckalloc(length); - *bufferPtr = buffer; - memcpy(buffer, string, length); - buffer[offset] = '\0'; - host = buffer; - port = atoi(buffer+offset+1); - } else { - /* - * The passed string contained no colon. - */ - *bufferPtr = NULL; - host = string; - port = 27017; - } - - /* - * Return always host and port via arguments. - */ - *hostPtr = host; - *portPtr = port; - - return TCL_OK; -} - /*********************************************************************** * Define the api functions ***********************************************************************/ @@ -482,11 +419,11 @@ static int NsfMongoConnect(Tcl_Interp *interp, CONST char *replicaSet, Tcl_Obj *server, int withTimeout) { char channelName[80], *buffer = NULL; - int result, port, objc = 0; + mongo_host_port host_port; + int result, objc = 0; mongo *connPtr; int status; Tcl_Obj **objv; - CONST char *host; if (server) { result = Tcl_ListObjGetElements(interp, server, &objc, &objv); @@ -509,8 +446,8 @@ * A single element was provided to -server, we have no replica * set specified. */ - NsfMongoGetHostPort(ObjStr(objv[0]), &buffer, &host, &port); - status = mongo_connect( connPtr, host, port ); + mongo_parse_host(ObjStr(objv[0]), &host_port); + status = mongo_connect( connPtr, host_port.host, host_port.port ); if (buffer) {ckfree(buffer);} } else if (replicaSet) { @@ -523,8 +460,8 @@ mongo_replset_init( connPtr, replicaSet ); for (i = 0; i < objc; i++) { - NsfMongoGetHostPort(ObjStr(objv[i]), &buffer, &host, &port); - mongo_replset_add_seed(connPtr, host, port ); + mongo_parse_host(ObjStr(objv[i]), &host_port); + mongo_replset_add_seed(connPtr, host_port.host, host_port.port ); if (buffer) {ckfree(buffer);} }