예제 #1
0
static void
dn_run(struct instance *nci)
{
    rstatus_t status;
    struct context *ctx;

    ctx = core_start(nci);
    if (ctx == NULL) {
        return;
    }

    ctx->enable_gossip = enable_gossip;
    ctx->admin_opt = admin_opt;

    if (!ctx->enable_gossip)
    	ctx->dyn_state = NORMAL;

    /* run rabbit run */
    for (;;) {
        status = core_loop(ctx);
        if (status != DN_OK) {
            break;
        }
    }

    core_stop(ctx);
}
예제 #2
0
static void
destroyed(struct context *ctx, event_type_t type, void *rarg, void *carg)
{
    struct conn *conn = carg;
    struct gen *g = &ctx->conn_gen;

    ASSERT(type == EVENT_CONN_DESTROYED);
    ASSERT(conn->ctx == ctx);

    core_close(ctx, conn);

    ctx->nconn_destroyed++;

    if (make_conn_done(ctx) && (ctx->nconn_destroyed == ctx->nconn_created)) {
        log_debug(LOG_NOTICE, "destroyed %"PRIu32" of %"PRIu32" of %"PRIu32" "
                  "connections", ctx->nconn_destroyed, ctx->nconn_created,
                  ctx->opt.num_conns);
        core_stop(ctx);
        return;
    }

    log_debug(LOG_INFO, "destroyed %"PRIu32" of %"PRIu32" of %"PRIu32" "
              "connections", ctx->nconn_destroyed, ctx->nconn_created,
              ctx->opt.num_conns);

    if (g->oneshot) {
        ecb_signal(ctx, EVENT_GEN_CONN_FIRE, g);
    }
}
예제 #3
0
static int
make_conn(struct context *ctx, void *arg)
{
    rstatus_t status;
    struct conn *conn;

    ASSERT(!make_conn_done(ctx));

    conn = conn_get(ctx);
    if (conn == NULL) {
        ctx->nconn_create_failed++;
        goto done;
    }

    status = core_connect(ctx, conn);
    if (status != MCP_OK) {
        ctx->nconn_create_failed++;
        ecb_signal(ctx, EVENT_CONN_FAILED, conn);
        goto done;
    }

    ctx->nconn_created++;
    ecb_signal(ctx, EVENT_CONN_CREATED, conn);

done:
    if (make_conn_done(ctx)) {
        log_debug(LOG_NOTICE, "created %"PRIu32" %"PRIu32" of %"PRIu32" "
                  "connections", ctx->nconn_create_failed, ctx->nconn_created,
                  ctx->opt.num_conns);
        if (ctx->nconn_destroyed == ctx->nconn_created) {
            core_stop(ctx);
        }
        return -1;
    }

    log_debug(LOG_INFO, "created %"PRIu32" %"PRIu32" of %"PRIu32" "
              "connections", ctx->nconn_create_failed, ctx->nconn_created,
              ctx->opt.num_conns);

    return 0;
}
예제 #4
0
파일: dynomite.c 프로젝트: dprof/dprof244b
static void
dn_run(struct instance *nci)
{
    rstatus_t status;
    struct context *ctx;

    ctx = core_start(nci);
    if (ctx == NULL) {
        return;
    }

    /* run rabbit run */
    for (;;) {
        status = core_loop(ctx);
        if (status != DN_OK) {
            break;
        }
    }

    core_stop(ctx);
}
예제 #5
0
파일: nc.c 프로젝트: happydayxiaoz/bdrp
static void
nc_run(struct instance *nci)
{
    rstatus_t status;
    struct context *ctx;

    ctx = core_start(nci);
    if (ctx == NULL) {
        return;
    }

    /* whitelist thread */
    nc_get_whitelist(nci);
    /* run rabbit run */
    for (;;) {
        status = core_loop(ctx);
        if (status != NC_OK) {
            break;
        }
    }

    core_stop(ctx);
}
예제 #6
0
파일: core.c 프로젝트: altf2o/ass
/*
 * Function:
 *    core_start
 * Arguments:
 *    NONE
 * Purpose:
 *    This is a central function one can call to pretty reliably
 *    open all /MUST HAVE/ file handles. We first build each path
 *    so we can open the files no matter our current working
 *    directory. Then just open 'em all up.
 * Returns:
 *    -1 - On error, call err_GetLastError for more information.
 *     0 - If everything went ok.
 */
int 
core_start( void )
{
  char file_path[MAX] = {0};
  int  retVal         = 0;
    
  /* Initialize this stuff up here */
  def   = NULL;
  desc  = NULL;
  ret   = NULL;
  dbase = NULL;

  /* Haven't called this function yet ? Cool proceed, otherwise do nothing */
  if( !core_startup ) 
  {
    core_startup++;

    retVal = core_createFilePath( file_path, "ANSIC99Def.txt" );
    if( retVal ) 
    {
      err_setError( FUNC_CORE_START, FILE_CORE_C, retVal, __LINE__ );
      return -1;
    }
    
    def = fopen( file_path, "rb" );
    if( def == NULL ) 
    {
      err_setError( FUNC_CORE_START, FILE_CORE_C, ERR_DEF_OPEN, __LINE__ );
      return -1;
    }
    
    retVal = core_createFilePath( file_path, "Descriptions.txt" );
    if( retVal ) 
    {
      err_setError( FUNC_CORE_START, FILE_CORE_C, retVal, __LINE__ );
      goto error;
    }
    
    desc = fopen( file_path, "rb" );
    if( desc == NULL ) 
    {
      err_setError( FUNC_CORE_START, FILE_CORE_C, ERR_DESC_OPEN, __LINE__ );
      goto error;
    }
    
    retVal = core_createFilePath( file_path, "Returns.txt" );
    if( retVal ) 
    {
      err_setError( FUNC_CORE_START, FILE_CORE_C, retVal, __LINE__ );
      goto error;
    }
    
    ret = fopen( file_path, "rb" );
    if( ret == NULL ) 
    {
      err_setError( FUNC_CORE_START, FILE_CORE_C, ERR_RET_OPEN, __LINE__ );
      goto error;
    }
    
    retVal = core_createFilePath( file_path, "db.txt" );
    if( retVal ) 
    {
      err_setError( FUNC_CORE_START, FILE_CORE_C, retVal, __LINE__ );
      goto error;
    }
        
    dbase = fopen( file_path, "rb" );
    if( dbase == NULL ) 
    {
      err_setError( FUNC_CORE_START, FILE_CORE_C, ERR_DB_OPEN, __LINE__ );
      goto error;
    }    
  }
  return 0;

error:
  core_stop();
  return -1;
}