From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 24 Jan 2008 06:14:38 -0000 Subject: [Cluster-devel] conga/ricci/ricci RicciWorker.cpp Message-ID: <20080124061438.15037.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/ricci/RicciWorker.cpp.diff?cvsroot=cluster&r1=1.16&r2=1.17 --- conga/ricci/ricci/RicciWorker.cpp 2008/01/02 20:47:38 1.16 +++ conga/ricci/ricci/RicciWorker.cpp 2008/01/24 06:14:37 1.17 @@ -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);