+ ssize_t result = ::read( fp, buf, length );
+ if ( length > 0 && result == 0 ) {
+ if (repeat < 0 || iteration < repeat - 1) {
+ iteration++;
+ // loop reading the file, unless it is empty
+ off_t fileLen = ::lseek(fp, 0, SEEK_CUR);
+ if (fileLen == 0) {
+ eof_flag = true;
+ return 0;
+ } else {
+ ::lseek(fp, 0, SEEK_SET);
+ return ::read(fp, buf, length);
+ }
+ } else {
+ eof_flag = true;
+ }
+ }
+ return result;