- fix a few unlikely but possible file-descriptor leaks

- remote job submission: always compute fraction done when showing
    batch list; check for nonexistent user
This commit is contained in:
David Anderson 2012-11-01 10:54:48 -07:00 committed by Oliver Bock
parent 5b740acee0
commit 1e06eb2fda
6 changed files with 31 additions and 5 deletions

View File

@ -6554,3 +6554,18 @@ David 1 Nov 2012
common_defs.h common_defs.h
filesys.h filesys.h
gui_rpc_client.h gui_rpc_client.h
David 1 Nov 2012
- fix a few unlikely but possible file-descriptor leaks
- remote job submission: always compute fraction done when showing
batch list; check for nonexistent user
client/
cs_scheduler.cpp
html/user/
submit.php
lib/
cert_sig.cpp
mem_usage.cpp
sched/
sched_timezone.cpp

View File

@ -369,6 +369,7 @@ int CLIENT_STATE::make_scheduler_request(PROJECT* p) {
fprintf(f, "<client_opaque>\n<![CDATA[\n"); fprintf(f, "<client_opaque>\n<![CDATA[\n");
copy_stream(cof, f); copy_stream(cof, f);
fprintf(f, "\n]]>\n</client_opaque>\n"); fprintf(f, "\n]]>\n</client_opaque>\n");
fclose(cof);
} }
fprintf(f, "</scheduler_request>\n"); fprintf(f, "</scheduler_request>\n");

View File

@ -31,7 +31,7 @@ ini_set('display_startup_errors', true);
// //
function show_batches($batches) { function show_batches($batches) {
foreach ($batches as $batch) { foreach ($batches as $batch) {
if ($batch->state < BATCH_STATE_COMPLETE) { if ($batch->state < BATCH_STATE_COMPLETE || $batch->fraction_done < 1) {
$wus = BoincWorkunit::enum("batch = $batch->id"); $wus = BoincWorkunit::enum("batch = $batch->id");
$batch = get_batch_params($batch, $wus); $batch = get_batch_params($batch, $wus);
} }
@ -42,7 +42,11 @@ function show_batches($batches) {
$batch->app_name = "unknown"; $batch->app_name = "unknown";
} }
$user = BoincUser::lookup_id($batch->user_id); $user = BoincUser::lookup_id($batch->user_id);
$batch->user_name = $user->name; if ($user) {
$batch->user_name = $user->name;
} else {
$batch->user_name = "missing user $batch->user_id";
}
} }
$first = true; $first = true;

View File

@ -150,6 +150,7 @@ int CERT_SIGS::parse_file(const char* filename) {
mf.init_file(f); mf.init_file(f);
XML_PARSER xp(&mf); XML_PARSER xp(&mf);
if (!xp.parse_start("signatures")) { if (!xp.parse_start("signatures")) {
fclose(f);
return ERR_XML_PARSE; return ERR_XML_PARSE;
} }
retval = this->parse(xp); retval = this->parse(xp);

View File

@ -118,6 +118,7 @@ int mem_usage(double& vm_usage, double& resident_set) {
++p; // move past space ++p; // move past space
} }
if (!p) { if (!p) {
fclose(f);
return ERR_NOT_IMPLEMENTED; return ERR_NOT_IMPLEMENTED;
} }

View File

@ -124,14 +124,18 @@ URLTYPE* read_download_list() {
} }
// read in lines from file // read in lines from file
//
while (1) { while (1) {
// allocate memory in blocks // allocate memory in blocks
if ((count % BLOCKSIZE)==0) { if ((count % BLOCKSIZE)==0) {
cached=(URLTYPE *)realloc(cached, (count+BLOCKSIZE)*sizeof(URLTYPE)); cached=(URLTYPE *)realloc(cached, (count+BLOCKSIZE)*sizeof(URLTYPE));
if (!cached) return NULL; if (!cached) {
fclose(fp);
return NULL;
}
} }
// read timezone offset and URL from file, and store in cache // read timezone offset and URL from file, and store in cache list
// list //
if (2==fscanf(fp, "%d %s", &(cached[count].zone), cached[count].name)) { if (2==fscanf(fp, "%d %s", &(cached[count].zone), cached[count].name)) {
count++; count++;
} else { } else {