void LocationService::handleLocationUpdateSubstreamRead(const UUID& source, SSTStreamPtr s, std::stringstream* prevdata, uint8* buffer, int length) { prevdata->write((const char*)buffer, length); String payload(prevdata->str()); if (locationUpdate(source, (void*)payload.c_str(), payload.size())) { // FIXME we should be getting a callback on stream close instead of // relying on this parsing as an indicator delete prevdata; // Clear out callback so we aren't responsible for any remaining // references to s, and close the stream s->registerReadCallback(0); s->close(false); } }
void AlwaysLocationUpdatePolicy::locSubstreamCallback(int x, SSTStreamPtr substream, SSTStreamPtr parent_stream, std::string* msg, int count) { // If we got it, the data got sent and we can drop the stream if (substream) { delete msg; substream->close(false); return; } // If we didn't get it and we haven't retried too many times, try // again. Otherwise, report error and give up. if (count < 5) { tryCreateChildStream(parent_stream, msg, count); } else { SILOG(always_loc,error,"Failed multiple times to open loc update substream."); delete msg; } }