Fix timers
Fucking hell. We're still having some event scheduling issues.
This commit is contained in:
parent
97bcad8a03
commit
01c2bfa5a4
|
@ -315,8 +315,8 @@ static bool generator_step (struct app_context *ctx);
|
||||||
struct app_context
|
struct app_context
|
||||||
{
|
{
|
||||||
struct str_map config; ///< User configuration
|
struct str_map config; ///< User configuration
|
||||||
unsigned connect_timeout; ///< Hard timeout for connect()
|
unsigned connect_timeout; ///< Timeout for connect() in sec.
|
||||||
unsigned scan_timeout; ///< Hard timeout for service scans
|
unsigned scan_timeout; ///< Timeout for service scans in sec.
|
||||||
|
|
||||||
json_t *json_results; ///< The results as a JSON value
|
json_t *json_results; ///< The results as a JSON value
|
||||||
const char *json_filename; ///< The filename to write JSON to
|
const char *json_filename; ///< The filename to write JSON to
|
||||||
|
@ -604,7 +604,7 @@ end:
|
||||||
static void
|
static void
|
||||||
unit_start_scan (struct unit *u)
|
unit_start_scan (struct unit *u)
|
||||||
{
|
{
|
||||||
poller_timer_set (&u->timeout_event, u->target->ctx->scan_timeout);
|
poller_timer_set (&u->timeout_event, u->target->ctx->scan_timeout * 1000);
|
||||||
u->fd_event.dispatcher = (poller_fd_fn) on_unit_ready;
|
u->fd_event.dispatcher = (poller_fd_fn) on_unit_ready;
|
||||||
unit_update_poller (u, NULL);
|
unit_update_poller (u, NULL);
|
||||||
}
|
}
|
||||||
|
@ -717,7 +717,7 @@ unit_make (struct target *target, uint32_t ip, uint16_t port,
|
||||||
unit_start_scan (u);
|
unit_start_scan (u);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
poller_timer_set (&u->timeout_event, ctx->connect_timeout);
|
poller_timer_set (&u->timeout_event, ctx->connect_timeout * 1000);
|
||||||
poller_fd_set (&u->fd_event, POLLOUT);
|
poller_fd_set (&u->fd_event, POLLOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
20
utils.c
20
utils.c
|
@ -926,21 +926,21 @@ poller_timers_heapify_down (struct poller_timers *self, size_t index)
|
||||||
timer_t *left = self->heap + 2 * index + 1;
|
timer_t *left = self->heap + 2 * index + 1;
|
||||||
timer_t *right = self->heap + 2 * index + 2;
|
timer_t *right = self->heap + 2 * index + 2;
|
||||||
|
|
||||||
timer_t *largest = parent;
|
timer_t *lowest = parent;
|
||||||
if (left < end && (*left) ->when > (*largest)->when)
|
if (left < end && (*left) ->when < (*lowest)->when)
|
||||||
largest = left;
|
lowest = left;
|
||||||
if (right < end && (*right)->when > (*largest)->when)
|
if (right < end && (*right)->when < (*lowest)->when)
|
||||||
largest = right;
|
lowest = right;
|
||||||
if (parent == largest)
|
if (parent == lowest)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
timer_t tmp = *parent;
|
timer_t tmp = *parent;
|
||||||
*parent = *largest;
|
*parent = *lowest;
|
||||||
*largest = tmp;
|
*lowest = tmp;
|
||||||
|
|
||||||
(*parent)->index = parent - self->heap;
|
(*parent)->index = parent - self->heap;
|
||||||
(*largest)->index = largest - self->heap;
|
(*lowest)->index = lowest - self->heap;
|
||||||
index = largest - self->heap;
|
index = lowest - self->heap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue