Fix NetString::ReadStringFromStream() EoF case in 'object list' command

refs #6109
This commit is contained in:
Michael Friedrich 2015-02-15 14:37:16 +01:00
parent 608ec97ece
commit 2036b87943
1 changed files with 11 additions and 3 deletions

View File

@ -83,8 +83,6 @@ int ObjectListCommand::Run(const boost::program_options::variables_map& vm, cons
unsigned long objects_count = 0; unsigned long objects_count = 0;
std::map<String, int> type_count; std::map<String, int> type_count;
String message;
StreamReadContext src;
String name_filter, type_filter; String name_filter, type_filter;
if (vm.count("name")) if (vm.count("name"))
@ -94,7 +92,17 @@ int ObjectListCommand::Run(const boost::program_options::variables_map& vm, cons
bool first = true; bool first = true;
while (NetString::ReadStringFromStream(sfp, &message, src) == StatusNewItem) { String message;
StreamReadContext src;
for (;;) {
StreamReadStatus srs = NetString::ReadStringFromStream(sfp, &message, src);
if (srs == StatusEof)
break;
if (srs != StatusNewItem)
continue;
PrintObject(std::cout, first, message, type_count, name_filter, type_filter); PrintObject(std::cout, first, message, type_count, name_filter, type_filter);
objects_count++; objects_count++;
} }