summaryrefslogtreecommitdiffstats
path: root/src/ufo-roof-build-task.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2019-11-17 21:09:05 +0100
committerSuren A. Chilingaryan <csa@suren.me>2019-11-17 21:09:05 +0100
commitad39481f238218ed3f3ce0f46c975a7ab178b5b5 (patch)
tree7d95a9c5fede3bec3880c53198de3fe752a75f75 /src/ufo-roof-build-task.c
parentea9626b60092f2d2c79431718c3ca8bc383429a6 (diff)
downloadufo-roof-temp-ad39481f238218ed3f3ce0f46c975a7ab178b5b5.tar.gz
ufo-roof-temp-ad39481f238218ed3f3ce0f46c975a7ab178b5b5.tar.bz2
ufo-roof-temp-ad39481f238218ed3f3ce0f46c975a7ab178b5b5.tar.xz
ufo-roof-temp-ad39481f238218ed3f3ce0f46c975a7ab178b5b5.zip
Few timeouts & exit conditions
Diffstat (limited to 'src/ufo-roof-build-task.c')
-rw-r--r--src/ufo-roof-build-task.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/ufo-roof-build-task.c b/src/ufo-roof-build-task.c
index 821c761..e5e5518 100644
--- a/src/ufo-roof-build-task.c
+++ b/src/ufo-roof-build-task.c
@@ -39,6 +39,8 @@ struct _UfoRoofBuildTaskPrivate {
gboolean stop; // Stop flag
guint announced; // For debugging
+
+ struct timespec last_fragment_timestamp;
};
static void ufo_task_interface_init (UfoTaskIface *iface);
@@ -82,9 +84,11 @@ ufo_roof_build_task_setup (UfoTask *task,
roof_propagate_error(error, gerr, "roof-build-setup: ");
- priv->buf = ufo_roof_buffer_new(priv->cfg, &gerr);
+ priv->buf = ufo_roof_buffer_new(priv->cfg, priv->number, &gerr);
if (!priv->buf)
roof_propagate_error(error, gerr, "roof-build-setup: ");
+
+ clock_gettime(CLOCK_REALTIME, &priv->last_fragment_timestamp);
}
static void
@@ -188,8 +192,23 @@ ufo_roof_build_task_process (UfoTask *task,
}
// FIXME: if 2nd dataset is ready (2nd and 3rd?), skip the first one?
+
+ if (ready) {
+ clock_gettime(CLOCK_REALTIME, &priv->last_fragment_timestamp);
+ } else {
+ struct timespec current_time;
+ clock_gettime(CLOCK_REALTIME, &current_time);
+
+ // No new accepted events within timeout
+ if (((current_time.tv_sec - priv->last_fragment_timestamp.tv_sec) * 1000000 + (current_time.tv_nsec - priv->last_fragment_timestamp.tv_nsec) / 1000) > cfg->network_timeout) {
+ priv->stop = TRUE;
+ g_object_notify_by_pspec (G_OBJECT(task), properties[PROP_STOP]);
+ }
+ }
+
+
/*
- printf("proc (%s) - channel: %i, packets: %i, first dataset: %i\n", ready?"yes":" no", header->channel_id, header->n_packets,
+ printf("proc (%s - %u of %u) - channel: %i, packets: %i, first dataset: %i\n", ready?"yes":" no", buf->n_fragments[(buf->current_id)%buf->ring_size], buf->fragments_per_dataset, header->channel_id, header->n_packets,
(cfg->header_size >= sizeof(UfoRoofPacketHeader))?UFO_ROOF_PACKET_HEADER(data)->packet_id / (cfg->dataset_size / cfg->payload_size / cfg->n_streams):0);
*/
@@ -216,14 +235,16 @@ ufo_roof_build_task_generate (UfoTask *task,
ready = ufo_roof_buffer_get_dataset(buf, output_buffer, &gerr);
if (gerr) roof_print_error(gerr);
+ // FIXME: Or shall we start from counting from the ID of the first registerd dataset
if ((priv->number)&&(buf->current_id >= priv->number)) {
+// printf("%u datasets processed, stopping\n", buf->current_id);
priv->stop = TRUE;
g_object_notify_by_pspec (G_OBJECT(task), properties[PROP_STOP]);
}
- if ((buf->current_id - priv->announced) > 1000) {
- printf("Generating dataset %i (%s)\n", buf->current_id, ready?"yes":" no");
+ if ((priv->number < 100)||((buf->current_id - priv->announced) > 1000)) {
+ printf("Generating dataset %i (%s), next: %u out of %u)\n", buf->current_id, ready?"yes":" no", buf->n_fragments[buf->current_id%buf->ring_size], buf->fragments_per_dataset);
priv->announced = buf->current_id;
}