]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/mainloop.c
UCW::CGI: Escaping functions silently convert undef to undef
[libucw.git] / ucw / mainloop.c
index 23eed5e14a4874c6134a4eaed5508bef2438bc6c..b5e54965bb87de3e8fab2b3ba877b4c491553832 100644 (file)
@@ -9,11 +9,13 @@
 
 #undef LOCAL_DEBUG
 
-#include "ucw/lib.h"
-#include "ucw/heap.h"
-#include "ucw/mainloop.h"
-#include "ucw/threads.h"
-#include "ucw/gary.h"
+#include <ucw/lib.h>
+#include <ucw/heap.h>
+#include <ucw/mainloop.h>
+#include <ucw/threads.h>
+#include <ucw/gary.h>
+#include <ucw/process.h>
+#include <ucw/time.h>
 
 #include <stdio.h>
 #include <string.h>
@@ -49,10 +51,7 @@ static void signal_del_ctx(struct main_context *m, struct main_signal *ms);
 static void
 main_get_time_ctx(struct main_context *m)
 {
-  struct timeval tv;
-  gettimeofday(&tv, NULL);
-  m->now_seconds = tv.tv_sec;
-  m->now = (timestamp_t)tv.tv_sec * 1000 + tv.tv_usec / 1000;
+  m->now = get_timestamp();
 }
 
 static struct main_context *
@@ -261,13 +260,13 @@ timer_add(struct main_timer *tm, timestamp_t expires)
        {
          tm->expires = expires;
          tm->index = num_timers + 1;
-         *GARY_PUSH(m->timer_table, 1) = tm;
-         HEAP_INSERT(struct main_timer *, m->timer_table, tm->index, MAIN_TIMER_LESS, MAIN_TIMER_SWAP);
+         GARY_RESIZE(m->timer_table, num_timers + 2);
+         HEAP_INSERT(struct main_timer *, m->timer_table, num_timers, MAIN_TIMER_LESS, MAIN_TIMER_SWAP, tm);
        }
       else
        {
          tm->expires = expires;
-         HEAP_INCREASE(struct main_timer *, m->timer_table, num_timers, MAIN_TIMER_LESS, MAIN_TIMER_SWAP, tm->index);
+         HEAP_INCREASE(struct main_timer *, m->timer_table, num_timers, MAIN_TIMER_LESS, MAIN_TIMER_SWAP, tm->index, tm);
        }
     }
   else if (tm->expires > expires)
@@ -283,7 +282,7 @@ timer_add(struct main_timer *tm, timestamp_t expires)
       else
        {
          tm->expires = expires;
-         HEAP_DECREASE(struct main_timer *, m->timer_table, num_timers, MAIN_TIMER_LESS, MAIN_TIMER_SWAP, tm->index);
+         HEAP_DECREASE(struct main_timer *, m->timer_table, num_timers, MAIN_TIMER_LESS, MAIN_TIMER_SWAP, tm->index, tm);
        }
     }
 }
@@ -597,7 +596,7 @@ signal_del(struct main_signal *ms)
   signal_del_ctx(main_current(), ms);
 }
 
-#ifdef CONFIG_DEBUG
+#ifdef CONFIG_UCW_DEBUG
 
 void
 file_debug(struct main_file *fi)