From e385e960ac0820f41a940babcede1fe21699e67b Mon Sep 17 00:00:00 2001 From: Karl Lehenbauer Date: Wed, 26 Feb 2014 20:34:07 +0000 Subject: [PATCH] In mongotcl_appendBsonFromObject, after a type conversion error report the name of the field associated with the error. Update the README part about memory leaks to reflect our successful insertion of lots of rows without client-side memory footprint growth. BUGZID: --- README.md | 3 +++ generic/bson.c | 15 +++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index afa4daf..8638678 100755 --- a/README.md +++ b/README.md @@ -500,3 +500,6 @@ The code is currently early beta quality so there could be quite a few bugs incl There are almost for sure some memory leaks so until those are all tracked down expect long-running jobs' memory footprint to grow and plan accordingly. +Update: We have now inserted hundreds of millions of rows without appreciable client memory footprint growth, so that process seems pretty solid. + + diff --git a/generic/bson.c b/generic/bson.c index c3ed306..fb01876 100644 --- a/generic/bson.c +++ b/generic/bson.c @@ -488,6 +488,12 @@ mongotcl_appendBsonFromObject(Tcl_Interp *interp, bson *bs, bson_type bsonType, int num; if (Tcl_GetIntFromObj (interp, valueObj, &num) == TCL_ERROR) { + + conversion_error: + Tcl_AddErrorInfo(interp, " while processing field '"); + Tcl_AddErrorInfo(interp, key); + Tcl_AddErrorInfo(interp, "'"); + return TCL_ERROR; } @@ -501,7 +507,7 @@ mongotcl_appendBsonFromObject(Tcl_Interp *interp, bson *bs, bson_type bsonType, long num; if (Tcl_GetLongFromObj (interp, valueObj, &num) == TCL_ERROR) { - return TCL_ERROR; + goto conversion_error; } if (bson_append_long (bs, key, num) != BSON_OK) { @@ -514,7 +520,7 @@ mongotcl_appendBsonFromObject(Tcl_Interp *interp, bson *bs, bson_type bsonType, double num; if (Tcl_GetDoubleFromObj (interp, valueObj, &num) == TCL_ERROR) { - return TCL_ERROR; + goto conversion_error; } if (bson_append_double (bs, key, num) != BSON_OK) { @@ -527,7 +533,7 @@ mongotcl_appendBsonFromObject(Tcl_Interp *interp, bson *bs, bson_type bsonType, int bool; if (Tcl_GetBooleanFromObj (interp, valueObj, &bool) == TCL_ERROR) { - return TCL_ERROR; + goto conversion_error; } if (bson_append_bool (bs, key, bool) != BSON_OK) { @@ -538,8 +544,9 @@ mongotcl_appendBsonFromObject(Tcl_Interp *interp, bson *bs, bson_type bsonType, case BSON_DATE: { long clock; + if (Tcl_GetLongFromObj (interp, valueObj, &clock) == TCL_ERROR) { - return TCL_ERROR; + goto conversion_error; } if (bson_append_time_t (bs, key, (time_t)clock) != BSON_OK) {