Example #1
0
        UDPClient::UDPClient() : _connected(false) {
            uv_loop_init(&loop);
            uv_udp_init(&loop, &client);
            uv_udp_init(&loop, &server);

            server.data = this;
            client.data = this;

        }
Example #2
0
 ThreadPool::ThreadPool() {
     loop_ = (uv_loop_t*)malloc(sizeof *loop_);
     UV_CHECK(uv_loop_init(loop_));
     UV_CHECK(uv_async_init(loop_, &async_, thread_pool_async_cb));
     async_.data = (void*)(this);
     thread_.reset(new thread([=] () {
                 UV_CHECK(uv_run(loop_, UV_RUN_DEFAULT));
                 }));
 }
Example #3
0
/* Initializes a new thread context. Note that this doesn't set up a
 * thread itself, it just creates the data structure that exists in
 * MoarVM per thread. */
MVMThreadContext * MVM_tc_create(MVMThreadContext *parent, MVMInstance *instance) {
    MVMThreadContext *tc = MVM_calloc(1, sizeof(MVMThreadContext));

    /* Associate with VM instance. */
    tc->instance = instance;

    /* Use default loop for main thread; create a new one for others. */
    if (instance->main_thread) {
        int r;

        tc->loop = MVM_calloc(1, sizeof(uv_loop_t));
        r = uv_loop_init(tc->loop);
        if (r < 0) {
            MVM_free(tc->loop);
            MVM_free(tc);
            MVM_exception_throw_adhoc(parent, "Could not create a new Thread: %s", uv_strerror(r));
        }
    } else {
        tc->loop = uv_default_loop();
    }

    /* Set up GC nursery. We only allocate tospace initially, and allocate
     * fromspace the first time this thread GCs, provided it ever does. */
    tc->nursery_tospace     = MVM_calloc(1, MVM_NURSERY_SIZE);
    tc->nursery_alloc       = tc->nursery_tospace;
    tc->nursery_alloc_limit = (char *)tc->nursery_alloc + MVM_NURSERY_SIZE;

    /* Set up temporary root handling. */
    tc->num_temproots   = 0;
    tc->alloc_temproots = MVM_TEMP_ROOT_BASE_ALLOC;
    tc->temproots       = MVM_malloc(sizeof(MVMCollectable **) * tc->alloc_temproots);

    /* Set up intergenerational root handling. */
    tc->num_gen2roots   = 0;
    tc->alloc_gen2roots = 64;
    tc->gen2roots       = MVM_malloc(sizeof(MVMCollectable *) * tc->alloc_gen2roots);

    /* Set up the second generation allocator. */
    tc->gen2 = MVM_gc_gen2_create(instance);

    /* Allocate an initial call stack region for the thread. */
    MVM_callstack_region_init(tc);

    /* Initialize random number generator state. */
    MVM_proc_seed(tc, (MVM_platform_now() / 10000) * MVM_proc_getpid(tc));

    /* Initialize frame sequence numbers */
    tc->next_frame_nr = 0;
    tc->current_frame_nr = 0;

    /* Initialize last_payload, so we can be sure it's never NULL and don't
     * need to check. */
    tc->last_payload = instance->VMNull;

    return tc;
}
Example #4
0
uv_loop_t *get_loop()
{
	if (loop == NULL)
	{
		loop = (uv_loop_t *)malloc(sizeof(uv_loop_t));
		uv_loop_init(loop);
	}

	return loop;
}
 ESDClient::ESDClient(std::string nodeID, std::string transactionID){
     this->nodeID        = nodeID;
     this->transactionID = transactionID;
     this->krpc          = std::unique_ptr<ESDKrpc>(new ESDKrpc);
     loop                = new uv_loop_t;
     uv_loop_init(loop);
     this->udp           = std::unique_ptr<ESDUdp>(new ESDUdp(loop));
     
     key = krpc->generateNodeID(NODE_ID_LENGTH);
 }
Example #6
0
void uv_init() {
  /* Initialize winsock */
  uv_winsock_init();

  /* Fetch winapi function pointers */
  uv_winapi_init();

  /* Intialize event loop */
  uv_loop_init();
}
Example #7
0
int async_init(void) {
	int rc = uv_loop_init(async_loop);
	if(rc < 0) return rc;
	master->fiber = co_active();
	master->flags = 0;
	active = master;
	async_main = master;
	trampoline = co_create(STACK_DEFAULT, trampoline_fn);
	if(!trampoline) return UV_ENOMEM;
	return 0;
}
Example #8
0
EventServer::EventServer() : thread_id_(std::this_thread::get_id())
{
  CHECK_EQ(0, uv_loop_init(&uv_loop_));

    async_handle_ = new AsyncHandle;
    async_handle_->es = this;
    async_handle_->uv_handle.data = async_handle_;
    CHECK_EQ(0, uv_async_init(&uv_loop_, &async_handle_->uv_handle,
                              &EventServer::uv_async_cb));

}
Example #9
0
int main()
{
	uv_loop_t *loop = (uv_loop_t*)malloc(sizeof(uv_loop_t));
	uv_loop_init(loop);

	printf("Now quitting.\n");
	uv_run(loop, UV_RUN_DEFAULT);

	uv_loop_close(loop);
	free(loop);
	return 0;
}
Example #10
0
 Loop::Loop(int device) : device_(device), stop_(false) {
     loop_ = (uv_loop_t*)malloc(sizeof *loop_);
     UV_CHECK(uv_loop_init(loop_));
     UV_CHECK(uv_async_init(loop_, &async_, async_cb));
     async_.data = (void*)(this);
     thread_.reset(new thread([=] () {
                 if (device_ >= 0) {
                 THREAD_SET_CUDA_DEVICE(device);
                 }
                 UV_CHECK(uv_run(loop_, UV_RUN_DEFAULT));
                 }));
 }
Example #11
0
int main() {
    uv_loop_t* loop = uv_default_loop();
    uv_loop_init(loop);

    uv_timer_t timer;
    uv_timer_init(loop, &timer);
    uv_timer_start(&timer, timer_callback, 0, 1000);

    uv_run(loop, UV_RUN_DEFAULT);

    uv_loop_close(loop);
    return 0;
}
Example #12
0
File: event.c Project: jollywho/nav
void event_init(void)
{
  log_msg("INIT", "event");
  uv_loop_init(eventloop());
  uv_prepare_init(eventloop(), &mainloop()->event_prepare);
  uv_timer_init(eventloop(), &mainloop()->children_kill_timer);
  uv_signal_init(eventloop(), &mainloop()->children_watcher);
  SLIST_INIT(&mainloop()->children);
  eventloop()->data = eventloop();
  QUEUE_INIT(&eventq()->headtail);
  QUEUE_INIT(&drawq()->headtail);
  mainloop()->running = false;
}
Example #13
0
void ipc_send_recv_helper_threadproc(void* arg) {
  int r;
  uv_loop_t loop;

  r = uv_loop_init(&loop);
  ASSERT(r == 0);

  r = run_ipc_send_recv_helper(&loop, 1);
  ASSERT(r == 0);

  r = uv_loop_close(&loop);
  ASSERT(r == 0);
}
CASE_TEST(atbus_endpoint, get_connection)
{
    atbus::node::conf_t conf;
    atbus::node::default_conf(&conf);
    conf.children_mask = 16;
    uv_loop_t ev_loop;
    uv_loop_init(&ev_loop);

    conf.ev_loop = &ev_loop;
    conf.recv_buffer_size = 64 * 1024;

    char* buffer = new char[conf.recv_buffer_size];
    memset(buffer, -1, sizeof(conf.recv_buffer_size)); // init it and then valgrind will now report uninitialised used

    char addr[32] = { 0 };
    UTIL_STRFUNC_SNPRINTF(addr, sizeof(addr), "mem://0x%p", buffer);
    if (addr[8] == '0' && addr[9] == 'x') {
        memset(addr, 0, sizeof(addr));
        UTIL_STRFUNC_SNPRINTF(addr, sizeof(addr), "mem://%p", buffer);
    }

    // 排除未完成连接
    {
        atbus::node::ptr_t node = atbus::node::create();
        node->init(0x12345678, &conf);

        atbus::connection::ptr_t conn1 = atbus::connection::create(node.get());

        CASE_EXPECT_EQ(0, conn1->connect(addr));

        atbus::connection::ptr_t conn2 = atbus::connection::create(node.get());
        conn2->connect("ipv4://127.0.0.1:80");

        atbus::endpoint::ptr_t ep = atbus::endpoint::create(node.get(), 0x12345679, 8, node->get_pid(), node->get_hostname());
        CASE_EXPECT_TRUE(ep->add_connection(conn1.get(), false));
        CASE_EXPECT_TRUE(ep->add_connection(conn2.get(), false));

        CASE_EXPECT_EQ(0, node->add_endpoint(ep));

        atbus::connection* conn3 = node->get_self_endpoint()->get_data_connection(ep.get());
        CASE_EXPECT_EQ(conn3, conn1.get());

    }

    while (UV_EBUSY == uv_loop_close(&ev_loop)) {
        uv_run(&ev_loop, UV_RUN_ONCE);
    }

    delete []buffer;
}
Example #15
0
static int uv_init(void)
{
	int ret = 0;
	ret = uv_loop_init(&g_loop);
	ret = uv_timer_init(&g_loop, &g_timer);
	//uv_ref((uv_handle_t*)&g_timer);
	ret = uv_timer_start(&g_timer, timer_fn, 10, 10);
	ret = uv_thread_create(&g_loop_thread, loop_thread, NULL);
	css_logger_init(&g_loop);
    g_sys = new CCaptureSys(&g_loop);
	//g_remote = new CRemoteSys(&g_loop);
	//g_sys->m_msgsock.set_loop(&g_loop);
	return ret;
}
Example #16
0
int main(int argc, char **argv)
{
    h2o_hostconf_t *hostconf;

    signal(SIGPIPE, SIG_IGN);

    h2o_config_init(&config);
    hostconf = h2o_config_register_host(&config, "default");
    register_handler(hostconf, "/post-test", post_test);
    register_handler(hostconf, "/chunked-test", chunked_test);
    h2o_file_register(h2o_config_register_path(hostconf, "/"), "examples/doc_root", NULL, NULL, 0);

#if 0 /* reproxy is not yet implemented */
    register_handler(hostconf, "/reproxy-test", reproxy_test);
    h2o_reproxy_register(hostconf);
#endif

#if H2O_USE_LIBUV
    uv_loop_t loop;
    uv_loop_init(&loop);
    h2o_context_init(&ctx, &loop, &config);
#else
    h2o_context_init(&ctx, h2o_evloop_create(), &config);
#endif

    /* disabled by default: uncomment the block below to use HTTPS instead of HTTP */
    /*
    if (setup_ssl("server.crt", "server.key") != 0)
        goto Error;
    */

    /* disabled by default: uncomment the line below to enable access logging */
    /* h2o_access_log_register(&config.default_host, "/dev/stdout", NULL); */

    if (create_listener() != 0) {
        fprintf(stderr, "failed to listen to 127.0.0.1:7890:%s\n", strerror(errno));
        goto Error;
    }

#if H2O_USE_LIBUV
    uv_run(ctx.loop, UV_RUN_DEFAULT);
#else
    while (h2o_evloop_run(ctx.loop) == 0)
        ;
#endif

Error:
    return 1;
}
Example #17
0
static int _do_fork_fs_events_child(int file_or_dir) {
  /* basic fsevents work in the child after a fork */
  pid_t child_pid;
  uv_loop_t loop;

  /* Watch in the parent, prime the loop and/or threads. */
  assert_watch_file_current_dir(uv_default_loop(), file_or_dir);
  child_pid = fork();
  ASSERT(child_pid != -1);

  if (child_pid != 0) {
    /* parent */
    assert_wait_child(child_pid);
  } else {
    /* child */
    /* Ee can watch in a new loop, but dirs only work
       if we're on linux. */
#if defined(__APPLE__)
    file_or_dir = FS_TEST_FILE;
#endif
    printf("Running child\n");
    uv_loop_init(&loop);
    printf("Child first watch\n");
    assert_watch_file_current_dir(&loop, file_or_dir);
    ASSERT(0 == uv_loop_close(&loop));
    printf("Child second watch default loop\n");
    /* Ee can watch in the default loop. */
    ASSERT(0 == uv_loop_fork(uv_default_loop()));
    /* On some platforms (OS X), if we don't update the time now,
     * the timer cb fires before the event loop enters uv__io_poll,
     * instead of after, meaning we don't see the change! This may be
     * a general race.
     */
    uv_update_time(uv_default_loop());
    assert_watch_file_current_dir(uv_default_loop(), file_or_dir);

    /* We can close the parent loop successfully too. This is
       especially important on Apple platforms where if we're not
       careful trying to touch the CFRunLoop, even just to shut it
       down, that we allocated in the FS_TEST_DIR case would crash. */
    ASSERT(0 == uv_loop_close(uv_default_loop()));

    printf("Exiting child \n");
  }

  MAKE_VALGRIND_HAPPY();
  return 0;

}
Example #18
0
File: stream.c Project: lucc/neovim
/// Sets the stream associated with `fd` to "blocking" mode.
///
/// @return `0` on success, or `-errno` on failure.
int stream_set_blocking(int fd, bool blocking)
{
  // Private loop to avoid conflict with existing watcher(s):
  //    uv__io_stop: Assertion `loop->watchers[w->fd] == w' failed.
  uv_loop_t loop;
  uv_pipe_t stream;
  uv_loop_init(&loop);
  uv_pipe_init(&loop, &stream, 0);
  uv_pipe_open(&stream, fd);
  int retval = uv_stream_set_blocking((uv_stream_t *)&stream, blocking);
  uv_close((uv_handle_t *)&stream, NULL);
  uv_run(&loop, UV_RUN_NOWAIT);  // not necessary, but couldn't hurt.
  uv_loop_close(&loop);
  return retval;
}
Example #19
0
  int init() {
    int rc = 0;
#if UV_VERSION_MAJOR > 0
    rc = uv_loop_init(&loop_);
    if (rc != 0) return rc;
    is_loop_initialized_ = true;
#endif

#if !defined(_WIN32)
    rc = uv_signal_init(loop(), &sigpipe_);
    if (rc != 0) return rc;
    rc = uv_signal_start(&sigpipe_, on_signal, SIGPIPE);
#endif
    return rc;
  }
Example #20
0
uv_loop_t* uv_loop_new(void) {
  uv_loop_t* loop;

  /* Initialize libuv itself first */
  uv_once(&uv_init_guard_, uv_init);

  loop = (uv_loop_t*)malloc(sizeof(uv_loop_t));

  if (!loop) {
    uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
  }

  uv_loop_init(loop);
  return loop;
}
Example #21
0
uv_loop_t* ThreadManager::initTask(const std::string& name) {
    Task& task = task_map[name];

    uv_loop_t* loop;
    if (adaptor) {
        loop = &adaptor->main_loop;
    } else {
        task.loop = new uv_loop_t;
        uv_loop_init(task.loop);
        loop = task.loop;
    }
    uv_async_init(loop, &task.cleanup, cleanup_func);
    task.cleanup.data = &task;

    return loop;
}
Example #22
0
void loop_init(Loop *loop, void *data)
{
  uv_loop_init(&loop->uv);
  loop->recursive = 0;
  loop->uv.data = loop;
  loop->children = kl_init(WatcherPtr);
  loop->children_stop_requests = 0;
  loop->events = multiqueue_new_parent(loop_on_put, loop);
  loop->fast_events = multiqueue_new_child(loop->events);
  loop->thread_events = multiqueue_new_parent(NULL, NULL);
  uv_mutex_init(&loop->mutex);
  uv_async_init(&loop->uv, &loop->async, async_cb);
  uv_signal_init(&loop->uv, &loop->children_watcher);
  uv_timer_init(&loop->uv, &loop->children_kill_timer);
  uv_timer_init(&loop->uv, &loop->poll_timer);
}
Example #23
0
sg_etp_session_t * sg_etp_session_open(IUINT32 conv, const struct sockaddr * addr, uv_loop_t * loop, void * data)
{
    sg_etp_session_t * session = NULL;

    do
    {
        session = (sg_etp_session_t *)malloc(sizeof(sg_etp_session_t));
        SG_ASSERT_BRK(NULL != session, "create client failed");

        memset(session, 0, sizeof(sg_etp_session_t));

        session->data = data;
        session->conv = conv;

        memcpy(&(session->addr), addr, sizeof(struct sockaddr));

        if (NULL == loop) /* self-contained loop, for client */
        {
            session->loop = &(session->loop_hdl);
            uv_loop_init(session->loop);
        }
        else
        {
            session->loop = loop;
        }

        /* create the kcp object */
        session->kcp = ikcp_create(session->conv, (void*)session);
        SG_ASSERT_BRK(NULL != session->kcp, "create ikcp failed");

        session->kcp->output = on_kcp_output;

        session->timeout        = SG_ETP_SESSION_TIMEOUT;
        session->recv_data_time = uv_now(session->loop) + session->timeout;

        return session;
    } while (0);

    if (NULL != session)
    {
        free(session);
        session = NULL;
    }

    return session;
}
Example #24
0
LWS_VISIBLE int
lws_uv_initloop(struct lws_context *context, uv_loop_t *loop, int tsi)
{
	struct lws_context_per_thread *pt = &context->pt[tsi];
	struct lws *wsi = wsi_from_fd(context, pt->lserv_fd);
	int status = 0, n;

	if (!loop) {
		loop = lws_malloc(sizeof(*loop));
		uv_loop_init(loop);
		pt->ev_loop_foreign = 0;
	} else
		pt->ev_loop_foreign = 1;

	pt->io_loop_uv = loop;

	if (pt->context->use_ev_sigint) {
		assert(ARRAY_SIZE(sigs) <= ARRAY_SIZE(pt->signals));
		for (n = 0; n < ARRAY_SIZE(sigs); n++) {
			uv_signal_init(loop, &pt->signals[n]);
			pt->signals[n].data = pt->context;
			uv_signal_start(&pt->signals[n], context->lws_uv_sigint_cb, sigs[n]);
		}
	}

	/*
	 * Initialize the accept wsi read watcher with the listening socket
	 * and register a callback for read operations
	 *
	 * We have to do it here because the uv loop(s) are not
	 * initialized until after context creation.
	 */
	if (wsi) {
		wsi->w_read.context = context;
		uv_poll_init(pt->io_loop_uv, &wsi->w_read.uv_watcher,
			     pt->lserv_fd);
		uv_poll_start(&wsi->w_read.uv_watcher, UV_READABLE,
			      lws_io_cb);
	}

	uv_timer_init(pt->io_loop_uv, &pt->uv_timeout_watcher);
	uv_timer_start(&pt->uv_timeout_watcher, lws_uv_timeout_cb, 1000, 1000);

	return status;
}
Example #25
0
static void read_cb(uv_stream_t *stream, ssize_t cnt, const uv_buf_t *buf)
{
  if (cnt <= 0) {
    uv_read_stop(stream);
    return;
  }

  int *interrupted = stream->data;

  for (int i = 0; i < cnt; i++) {
    if (buf->base[i] == CTRL_C) {
      (*interrupted)++;
    }
  }

  uv_loop_t write_loop;
  uv_loop_init(&write_loop);
  uv_tty_t out;
  uv_tty_init(&write_loop, &out, fileno(stdout), 0);

  uv_write_t req;
  uv_buf_t b = {
    .base = buf->base,
#ifdef WIN32
    .len = (ULONG)cnt
#else
    .len = (size_t)cnt
#endif
  };
  uv_write(&req, STRUCT_CAST(uv_stream_t, &out), &b, 1, NULL);
  uv_run(&write_loop, UV_RUN_DEFAULT);

  uv_close(STRUCT_CAST(uv_handle_t, &out), NULL);
  uv_run(&write_loop, UV_RUN_DEFAULT);
  if (uv_loop_close(&write_loop)) {
    abort();
  }
  free(buf->base);

  if (*interrupted >= 2) {
    uv_walk(uv_default_loop(), walk_cb, NULL);
  } else if (*interrupted == 1) {
    fprintf(stderr, "interrupt received, press again to exit\n");
  }
}
Example #26
0
File: vm.c Project: 0x73/wren
static void initVM()
{
  WrenConfiguration config;
  wrenInitConfiguration(&config);

  config.bindForeignMethodFn = bindForeignMethod;
  config.bindForeignClassFn = bindForeignClass;
  config.loadModuleFn = readModule;
  config.writeFn = write;

  // Since we're running in a standalone process, be generous with memory.
  config.initialHeapSize = 1024 * 1024 * 100;
  vm = wrenNewVM(&config);

  // Initialize the event loop.
  loop = (uv_loop_t*)malloc(sizeof(uv_loop_t));
  uv_loop_init(loop);
}
Example #27
0
void rtScriptDuk::init2(int argc, char** argv)
#endif
{
  // Hack around with the argv pointer. Used for process.title = "blah".
#ifdef ENABLE_DEBUG_MODE
  g_argvduk = uv_setup_args(g_argcduk, g_argvduk);
#else
  argv = uv_setup_args(argc, argv);
#endif

  rtLogInfo(__FUNCTION__);

#if 0
#warning Using DEBUG AGENT...
  use_debug_agent = true; // JUNK
#endif

  if(duk_is_initialized == false)
  {
    duk_is_initialized = true;

    uv_loop_t *dukLoop = new uv_loop_t();
    uv_loop_init(dukLoop);
    //uv_loop_t dukLoop = uv_default_loop();
    dukCtx = duk_create_heap(NULL, NULL, NULL, dukLoop, NULL);
    if (!dukCtx) {
	    rtLogWarn("Problem initiailizing duktape heap\n");
	    return;
    }

    dukLoop->data = dukCtx;
    uvLoops.push_back(dukLoop);

    {
      duk_push_thread_stash(dukCtx, dukCtx);
      duk_push_pointer(dukCtx, (void*)dukLoop);
      duk_bool_t rc = duk_put_prop_string(dukCtx, -2, "__duk_loop");
      assert(rc);
      duk_pop(dukCtx);
    }

    rtScriptDukUtils::rtSetupJsModuleBindings(dukCtx);
  }
}
Example #28
0
File: loop.c Project: nubjs/libnub
void nub_loop_init(nub_loop_t* loop) {
  uv_async_t* async_handle;
  int er;

  er = uv_loop_init(&loop->uvloop);
  ASSERT(0 == er);

  er = uv_prepare_init(&loop->uvloop, &loop->queue_processor_);
  ASSERT(0 == er);
  loop->queue_processor_.data = loop;
  uv_unref((uv_handle_t*) &loop->queue_processor_);

  er = uv_mutex_init(&loop->queue_processor_lock_);
  ASSERT(0 == er);

  fuq_init(&loop->blocking_queue_);

  er = uv_sem_init(&loop->loop_lock_sem_, 0);
  ASSERT(0 == er);

  fuq_init(&loop->thread_dispose_queue_);

  er = uv_mutex_init(&loop->thread_dispose_lock_);
  ASSERT(0 == er);

  fuq_init(&loop->work_queue_);

  er = uv_mutex_init(&loop->work_lock_);
  ASSERT(0 == er);

  async_handle = (uv_async_t*) malloc(sizeof(*async_handle));
  CHECK_NE(NULL, async_handle);
  er = uv_async_init(&loop->uvloop, async_handle, nub__thread_dispose);
  ASSERT(0 == er);
  async_handle->data = loop;
  loop->work_ping_ = async_handle;
  uv_unref((uv_handle_t*) loop->work_ping_);

  loop->ref_ = 0;
  loop->disposed_ = 0;

  er = uv_prepare_start(&loop->queue_processor_, nub__async_prepare_cb);
  ASSERT(0 == er);
}
Example #29
0
int main(int argc, char **argv)
{
    h2o_hostconf_t *hostconf;
    h2o_pathconf_t *pathconf;

    h2o_config_init(&config);
    hostconf = h2o_config_register_host(&config, h2o_iovec_init(H2O_STRLIT("default")), 65535);
    pathconf = h2o_config_register_path(hostconf, "/", 0);
    h2o_create_handler(pathconf, sizeof(h2o_handler_t))->on_req = on_req;

#if H2O_USE_LIBUV
    uv_loop_t loop;
    uv_loop_init(&loop);
    h2o_context_init(&ctx, &loop, &config);
#else
    h2o_context_init(&ctx, h2o_evloop_create(), &config);
#endif

    /* disabled by default: uncomment the block below to use HTTPS instead of HTTP */
    /*
    if (setup_ssl("server.crt", "server.key") != 0)
        goto Error;
    */

    accept_ctx.ctx = &ctx;
    accept_ctx.hosts = config.hosts;

    if (create_listener() != 0) {
        fprintf(stderr, "failed to listen to 127.0.0.1:7890:%s\n", strerror(errno));
        goto Error;
    }

#if H2O_USE_LIBUV
    uv_run(ctx.loop, UV_RUN_DEFAULT);
#else
    while (h2o_evloop_run(ctx.loop, INT32_MAX) == 0)
        ;
#endif

Error:
    return 1;
}
static void
foreign_event_loop_init_and_run_libuv(void)
{
	/* we create and start our "foreign loop" */

#if (UV_VERSION_MAJOR > 0) // Travis...
	uv_loop_init(&loop_uv);
#endif
	uv_signal_init(&loop_uv, &sighandler_uv);
	uv_signal_start(&sighandler_uv, signal_cb_uv, SIGINT);

	uv_timer_init(&loop_uv, &timer_outer_uv);
#if (UV_VERSION_MAJOR > 0) // Travis...
	uv_timer_start(&timer_outer_uv, timer_cb_uv, 0, 1000);
#else
	(void)timer_cb_uv;
#endif

	uv_run(&loop_uv, UV_RUN_DEFAULT);
}