]> rtime.felk.cvut.cz Git - frescor/fna.git/blobdiff - src_frescan/frescan_servers_replenishments.c
changes to use the FRSH FSA module to do the analysis and spare capacity. TODO: finis...
[frescor/fna.git] / src_frescan / frescan_servers_replenishments.c
index 04202a9ef269239d431033e917908d576efe7850..df3b51683f44ce4f4283dd2b388c338620373e5f 100644 (file)
 
 #include <misc/freelist.h>   // freelist_t
 #include <misc/linux_list.h> // list_add_tail
-#include <misc/timespec_operations.h>
 
 #include "frescan_servers_replenishments.h"
 #include "frescan_config.h"  // FRESCAN_MX_REPL_OPS
-#include "frescan_debug.h"   // ERROR
+#include "frescan_debug.h"   // FRESCAN_ERROR
 #include "frescan_data.h"    // frescan_repl_op_t
-#include "fosa_threads_and_signals.h" // fosa_thread_attr_init...
+#include "fosa.h" // fosa_thread_attr_init, smaller_timespec, incr_timespec
 
 #if (FRESCAN_MEASURE_REPL_TH || FRESCAN_MEASURE_REPL_PROGRAM)
 #include <misc/time_measurement_posix.h>
@@ -114,7 +113,7 @@ frescan_repl_op_t *frescan_repl_op_alloc()
 
         pos = freelist_alloc(&the_repl_op_pool_freelist);
         if (pos == -1) {
-                ERROR("could not allocate repl op\n");
+                FRESCAN_ERROR("could not allocate repl op\n");
                 return NULL;
         }
         the_repl_op_pool[pos].pool_pos = pos; // to know how to free it
@@ -204,7 +203,7 @@ int frescan_replenishments_init(frescan_network_t net)
 
         ret = frescan_repl_op_init();
         if (ret != 0) {
-                ERROR("could not init repl_op pool\n");
+                FRESCAN_ERROR("could not init repl_op pool\n");
                 return ret;
         }
 
@@ -212,7 +211,7 @@ int frescan_replenishments_init(frescan_network_t net)
 
         ret = fosa_set_accepted_signals(signal_set, 1);
         if (ret != 0) {
-                ERROR("could not set the repl signal\n");
+                FRESCAN_ERROR("could not set the repl signal\n");
                 return ret;
         }
 
@@ -229,13 +228,13 @@ int frescan_replenishments_init(frescan_network_t net)
 
         ret = fosa_thread_attr_init(&attr);
         if (ret != 0) {
-                ERROR("could not init thread attributes\n");
+                FRESCAN_ERROR("could not init thread attributes\n");
                 return ret;
         }
 
         ret = fosa_thread_attr_set_prio(&attr, FRESCAN_REPL_THREAD_PRIO);
         if (ret != 0) {
-                ERROR("could not set repl thread prio %d\n",
+                FRESCAN_ERROR("could not set repl thread prio %d\n",
                       FRESCAN_REPL_THREAD_PRIO);
                 return ret;
         }
@@ -245,13 +244,13 @@ int frescan_replenishments_init(frescan_network_t net)
                                  frescan_repl_thread,
                                  (void *)(uint32_t)net);
         if (ret != 0) {
-                ERROR("could not create the replenishment thread\n");
+                FRESCAN_ERROR("could not create the replenishment thread\n");
                 return ret;
         }
 
         ret = fosa_thread_attr_destroy(&attr);
         if (ret != 0) {
-                ERROR("could not destroy thread attributes\n");
+                FRESCAN_ERROR("could not destroy thread attributes\n");
                 return ret;
         }
 
@@ -292,7 +291,7 @@ int frescan_replenishment_program(frescan_network_t net,
 
         // move to tail with new repl value
         repl->when = *timestamp;
-        incr_timespec (&repl->when, &server->params.values.period);
+        incr_timespec(repl->when, server->params.period);
         repl->amount = 1;
 
         list_add_tail(&repl->repl_list,
@@ -306,7 +305,7 @@ int frescan_replenishment_program(frescan_network_t net,
 
         clock_gettime (CLOCK_MONOTONIC, &now);
 
-        if (smaller_timespec(&now, &repl->when)) {
+        if (smaller_timespec(now, repl->when)) {
                 server->current_priority = FRESCAN_BACKGROUND_PRIO;
 
                 timerdata.it_interval.tv_sec  = 0;
@@ -320,7 +319,7 @@ int frescan_replenishment_program(frescan_network_t net,
                 ret = timer_settime(server->repl_timer,
                                     TIMER_ABSTIME, &timerdata, NULL);
                 if (ret != 0) {
-                        ERROR("could not set the replenishment timer\n");
+                        FRESCAN_ERROR("could not set the replenishment timer\n");
                         return ret;
                 }
         }