conga/ricci/ricci RicciWorker.cpp
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2008-01-24 06:14:37
Modified files:
ricci/ricci : RicciWorker.cpp
Log message:
Fix stupid bug that caused reading batch jobs with XML longer than 4k to fail.
ricci/ricci/RicciWorker.cpp +14 -7
@@ -258,6 +258,7 @@ _path(path) { QueueLocker lock; + struct stat st; _fd = open(_path.c_str(), O_RDONLY); if (_fd == -1)
@@ -276,18 +277,24 @@ } } + if (fstat(_fd, &st) != 0) + throw String("Unable to stat file: ") + String(strerror(errno)); + // read file String xml_str; - char buff[4096]; - ssize_t res; - res = read_restart(_fd, buff, sizeof(buff)); - if (res <= 0) { - throw String("error reading batch file: ") + while ((off_t) xml_str.size() < st.st_size) { + char buff[4096]; + ssize_t res; + + res = read_restart(_fd, buff, sizeof(buff)); + if (res <= 0) { + throw String("error reading batch file: ") + String(strerror(-res)); + } + xml_str.append(buff, res); + memset(buff, 0, sizeof(buff)); } - xml_str.append(buff, res); - memset(buff, 0, sizeof(buff)); // _xml _xml = parseXML(xml_str);