Files
Jungfraujoch/image_pusher/ImagePusher.cpp
T
leonarski_f 086129f767 receiver: count only images the pusher accepted
images_sent was incremented right after image_pusher.SendImage(*loc), but the
ZeroCopyReturnValue overload was void and, for the TCP pusher, asynchronous: it
silently drops the image (releases the slot and returns) when there is no live
connection or the 2 s enqueue deadline expires. So images_sent over-counted on a
broken/slow writer connection and disagreed with the ACK-based GetImagesWritten().

Make SendImage(ZeroCopyReturnValue&) return whether the image was accepted
(enqueued/handed off) and only increment images_sent on success. The slot is
still released on the drop path. The authoritative delivered count remains
GetImagesWritten() (total_data_acked_ok for TCP). File/ZMQ pushers return true on
accept, preserving their previous always-counted behaviour.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 14:24:48 +02:00

33 lines
1.1 KiB
C++

// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#include "ImagePusher.h"
void PrepareCBORImage(DataMessage& message,
const DiffractionExperiment &experiment,
void *image, size_t image_size) {
message.image = CompressedImage(image, image_size,
experiment.GetXPixelsNum(),
experiment.GetYPixelsNum(),
experiment.GetImageMode(),
experiment.GetCompressionAlgorithm());
}
ImagePusher::ImagePusher()
: serialization_buffer(MESSAGE_SIZE_FOR_START_END),
serializer(serialization_buffer.data(), serialization_buffer.size()) {}
std::string ImagePusher::Finalize() {
return "";
}
std::string ImagePusher::GetWriterNotificationSocketAddress() const {
return "";
}
bool ImagePusher::SendImage(ZeroCopyReturnValue &z) {
const bool accepted = SendImage((uint8_t *) z.GetImage(), z.GetImageSize(), z.GetImageNumber());
z.release();
return accepted;
}