Beispiel #1
0
void reload_task(void *data)
{
    RELOAD_TASK = taskself();
    struct ServerTask *srv = data;

    while(1) {
        taskswitch();
        task_clear_signal();

        if(RELOAD) {
            log_info("Reload requested, will load %s from %s", bdata(srv->db_file), bdata(srv->server_id));
            Server *old_srv = Server_queue_latest();
            Server *new_srv = reload_server(old_srv, bdata(srv->db_file), bdata(srv->server_id));
            check(new_srv, "Failed to load the new configuration, exiting.");

            // for this to work handlers need to die more gracefully
            Server_queue_push(new_srv);
        } else {
            log_info("Shutdown requested, goodbye.");
            break;
        }
    }

    taskexit(0);
error:
    taskexit(1);
}
Beispiel #2
0
void fdtask(void *v)
{
    int i, ms;
    PollResult result;
    int rc = 0;
    FDTASK = taskself();
    
    rc = PollResult_init(POLL, &result);
    check(rc == 0, "Failed to initialize the poll result.");

    tasksystem();
    taskname("fdtask");

    for(;;){
        /* let everyone else run */
        while(taskyield() > 0)
            ;
        /* we're the only one runnable - poll for i/o */

        errno = 0;
        taskstate("poll");

        ms = next_task_sleeptime(500);

        if(task_was_signaled()) {
            fdtask_shutdown();
            task_clear_signal();
            break;
        } else {
            rc = SuperPoll_poll(POLL, &result, ms);
            check(rc != -1, "SuperPoll failure, aborting.");

            for(i = 0; i < rc; i++) {
                taskready(result.hits[i].data); 
            }

            wake_sleepers();
        }

    }

    PollResult_clean(&result);
    FDTASK = NULL;
    return;

error:
    taskexitall(1);
}