Hello All,

 Just checking the code of nspostgres driver (downloaded from git) and
found that the code needs some fixes. Couple of thing which I see

 1- in nspostgres.c

 fucntion: static int blob_dml_file

where we see these lines:

 if (fd == -1)
{
Ns_Log (Error, " Error opening file %s: %d(%s)", filename, errno,
strerror(errno));

Tcl_AppendResult (interp, "can't open file ", filename, " for reading. ",
"received error ", strerror(errno), NULL);
}



Why to continue the process when we are unable to open the file? Shouldn't
it be

 if (fd == -1)
{
Ns_Log (Error, " Error opening file %s: %d(%s)", filename, errno,
strerror(errno));
Tcl_AppendResult (interp, "can't open file ", filename, " for reading. ",
"received error ", strerror(errno), NULL);

*return TCL_ERROR;
*}



2- In the same function where we have this:



if (Ns_PgExec(handle, query) != NS_DML) {
 Tcl_DString errString;
 Tcl_DStringInit(&errString);

 Tcl_DStringAppend
 (&errString, "Error inserting data into BLOB\n", -1);

 if(handle->verbose)
 {
 append_PQresultStatus(&errString, nspgConn->res);

 Tcl_DStringAppend(&errString, "SQL: ", -1);
 Tcl_DStringAppend(&errString, query, -1);
 }

 Tcl_AppendResult(interp, Tcl_DStringValue(&errString), NULL);

 Tcl_DStringFree(&errString);
 return TCL_ERROR;
}

here while returning error we are not closing the file descriptor so I see
a resource leak and it should be

if (Ns_PgExec(handle, query) != NS_DML) {
 Tcl_DString errString;
 Tcl_DStringInit(&errString);

 Tcl_DStringAppend
 (&errString, "Error inserting data into BLOB\n", -1);

 if(handle->verbose)
 {
 append_PQresultStatus(&errString, nspgConn->res);

 Tcl_DStringAppend(&errString, "SQL: ", -1);
 Tcl_DStringAppend(&errString, query, -1);
 }

 Tcl_AppendResult(interp, Tcl_DStringValue(&errString), NULL);

 Tcl_DStringFree(&errString);

 *close(fd);
* return TCL_ERROR;
}

 Regards,

 Majid.
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
aolserver-talk mailing list
aolserver-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/aolserver-talk

Reply via email to