示例#1
0
rstatus_t
core_core(void *arg, uint32_t events)
{
	rstatus_t status;
	struct conn *conn = arg;
	struct context *ctx = conn_to_ctx(conn);

    log_debug(LOG_VVERB, "event %04"PRIX32" on %s %d", events,
              conn_get_type_string(conn), conn->sd);

	conn->events = events;

	/* error takes precedence over read | write */
	if (events & EVENT_ERR) {
		if (conn->err && conn->dyn_mode) {
			loga("conn err on dnode EVENT_ERR: %d", conn->err);
		}
		core_error(ctx, conn);

		return DN_ERROR;
	}

	/* read takes precedence over write */
	if (events & EVENT_READ) {
		status = core_recv(ctx, conn);

		if (status != DN_OK || conn->done || conn->err) {
			if (conn->dyn_mode) {
				if (conn->err) {
					loga("conn err on dnode EVENT_READ: %d", conn->err);
					core_close(ctx, conn);
					return DN_ERROR;
				}
				return DN_OK;
			}

			core_close(ctx, conn);
			return DN_ERROR;
		}
	}

	if (events & EVENT_WRITE) {
		status = core_send(ctx, conn);
		if (status != DN_OK || conn->done || conn->err) {
			if (conn->dyn_mode) {
				if (conn->err) {
					loga("conn err on dnode EVENT_WRITE: %d", conn->err);
					core_close(ctx, conn);
					return DN_ERROR;
				}
				return DN_OK;
			}

			core_close(ctx, conn);
			return DN_ERROR;
		}
	}

	return DN_OK;
}
示例#2
0
static void
core_core(struct context *ctx, struct conn *conn, uint32_t events)
{
    rstatus_t status;

    log_debug(LOG_VVERB, "event %04"PRIX32" on %c %d", events,
              conn->client ? 'c' : (conn->proxy ? 'p' : 's'), conn->sd);

    conn->events = events;

    /* error takes precedence over read | write */
    if (events & EPOLLERR) {
        core_error(ctx, conn);
        return;
    }

    /* read takes precedence over write */
    if (events & (EPOLLIN | EPOLLHUP)) {
        status = core_recv(ctx, conn);
        if (status != NC_OK || conn->done || conn->err) {
            core_close(ctx, conn);
            return;
        }
    }

    if (events & EPOLLOUT) {
        status = core_send(ctx, conn);
        if (status != NC_OK || conn->done || conn->err) {
            core_close(ctx, conn);
            return;
        }
    }
}
示例#3
0
static void
core_error(struct context *ctx, struct conn *conn)
{
	rstatus_t status;

	status = dn_get_soerror(conn->sd);
	if (status < 0) {
		if (!conn->dyn_mode) {
                        if (conn->client)
		                log_warn("get soerr on client %d failed, ignored: %s", conn->sd, strerror(errno));
			else if (conn->proxy)
				log_warn("get soerr on proxy %d failed, ignored: %s", conn->sd, strerror(errno));
			else
				log_warn("get soerr on storage server %d failed, ignored: %s", conn->sd, strerror(errno));
		} else {
			if (conn->dnode_client)
		                log_warn("get soerr on dnode client %d failed, ignored: %s", conn->sd, strerror(errno));
			else if (conn->dnode_server)
				log_warn("get soerr on dnode server %d failed, ignored: %s", conn->sd, strerror(errno));
			else
				log_warn("get soerr on peer %d failed, ignored: %s", conn->sd, strerror(errno));
		}
	}
	conn->err = errno;

	core_close(ctx, conn);
}
示例#4
0
int main(int argc, char** argv)
{
    if (argc < 2) {
        fprintf(stderr, "Usage: %s <trace file>\n", argv[0]);
        return EXIT_FAILURE;
    }

    char* trace_path = argv[argc - 1];

    if (!trace_read_open(trace_path)) {
        fprintf(stderr, "Can't open trace file '%s'.\n", trace_path);
        return EXIT_FAILURE;
    }

    uint32_t rdram_size;
    trace_read_header(&rdram_size);
    plugin_set_rdram_size(rdram_size);

    core_init(&config);

    retrace_frames();

    core_close();

    trace_read_close();

    return EXIT_SUCCESS;
}
示例#5
0
static void
core_timeout(struct context *ctx)
{
	for (;;) {
		struct msg *msg;
		struct conn *conn;
		int64_t now, then;

		msg = msg_tmo_min();
		if (msg == NULL) {
			ctx->timeout = ctx->max_timeout;
			return;
		}

		/* skip over req that are in-error or done */

		if (msg->error || msg->done) {
			msg_tmo_delete(msg);
			continue;
		}

		/*
		 * timeout expired req and all the outstanding req on the timing
		 * out server
		 */

		conn = msg->tmo_rbe.data;
		then = msg->tmo_rbe.key;

		now = dn_msec_now();
		if (now < then) {
			int delta = (int)(then - now);
			ctx->timeout = MIN(delta, ctx->max_timeout);
			return;
		}

        log_warn("req %"PRIu64" on %s %d timedout, timeout was %d", msg->id,
                 conn_get_type_string(conn), conn->sd, msg->tmo_rbe.timeout);

		msg_tmo_delete(msg);

		if (conn->dyn_mode) {
			if (conn->type == CONN_DNODE_PEER_SERVER) { //outgoing peer requests
		 	   struct server *server = conn->owner;
                if (conn->same_dc)
			        stats_pool_incr(ctx, server->owner, peer_timedout_requests);
                else
			        stats_pool_incr(ctx, server->owner, remote_peer_timedout_requests);
			}
		} else {
			if (conn->type == CONN_SERVER) { //storage server requests
			   stats_server_incr(ctx, conn->owner, server_dropped_requests);
			}
		}

		conn->err = ETIMEDOUT;

		core_close(ctx, conn);
	}
}
示例#6
0
static void
sess_destroyed (Event_Type et, Object *obj, Any_Type regarg, Any_Type callarg)
{
  Sess_Private_Data *priv;
  struct Conn_Info *ci;
  Sess *sess;
  int i, j, rd;

  assert (et == EV_SESS_DESTROYED && object_is_sess (obj));
  sess = (Sess *) obj;
  priv = SESS_PRIVATE_DATA (sess);

  for (i = 0; i < param.max_conns; ++i)
    {
      ci = priv->conn_info + i;

      if (ci->conn)
	core_close (ci->conn);

      rd = ci->rd;
      for (j = 0; j < ci->num_pending; ++j)
	{
	  call_dec_ref (ci->call[rd]);
	  rd = (rd + 1) % MAX_PIPED;
	}
    }
}
示例#7
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);
    }
}
示例#8
0
rstatus_t
core_core(void *arg, uint32_t events)
{
	rstatus_t status;
	struct conn *conn = arg;
	struct context *ctx = conn_to_ctx(conn);

	if (conn->dyn_mode) {
		log_debug(LOG_VVERB, "event %04"PRIX32" on d_%c %d", events,
				conn->dnode_client ? 'c' : (conn->dnode_server ? 's' : 'p'), conn->sd);
	} else {
		log_debug(LOG_VVERB, "event %04"PRIX32" on %c %d", events,
				conn->client ? 'c' : (conn->proxy ? 'p' : 's'), conn->sd);
	}

	conn->events = events;

	/* error takes precedence over read | write */
	if (events & EVENT_ERR) {
		core_error(ctx, conn);
		return DN_ERROR;
	}

	/* read takes precedence over write */
	if (events & EVENT_READ) {
		status = core_recv(ctx, conn);
		if (status != DN_OK || conn->done || conn->err) {
			core_close(ctx, conn);
			return DN_ERROR;
		}
	}


	if (events & EVENT_WRITE) {
		status = core_send(ctx, conn);
		if (status != DN_OK || conn->done || conn->err) {
			core_close(ctx, conn);
			return DN_ERROR;
		}
	}


	return DN_OK;
}
示例#9
0
static void
core_core(void *arg, uint32_t evflags)
{
    rstatus_t status;
    struct conn *conn = (struct conn *) arg;
    struct context *ctx;

    

    if ((conn->proxy) || (conn->client)) {
        ctx = ((struct server_pool *) (conn -> owner)) -> ctx;
    } else { 
        ctx = ((struct server_pool *) (((struct server *) (conn -> owner)) -> owner )) -> ctx;
    }

    log_debug(LOG_VVERB, "event %04"PRIX32" on %c %d", evflags,
              conn->client ? 'c' : (conn->proxy ? 'p' : 's'), conn->sd);

    conn->events = evflags;

    /* error takes precedence over read | write */
    if (evflags & EV_ERR) {
        core_error(ctx, conn);
        return;
    }

    /* read takes precedence over write */
    if (evflags & EV_READ) {
        status = core_recv(ctx, conn);
        if (status != NC_OK || conn->done || conn->err) {
            core_close(ctx, conn);
            return;
        }
    }

    if (evflags & EV_WRITE) {
        status = core_send(ctx, conn);
        if (status != NC_OK || conn->done || conn->err) {
            core_close(ctx, conn);
            return;
        }
    }
}
示例#10
0
static void
core_error(struct context *ctx, struct conn *conn)
{
	rstatus_t status;

	status = dn_get_soerror(conn->sd);
	if (status < 0) {
	log_warn("get soerr on %s client %d failed, ignored: %s",
             conn_get_type_string(conn), conn->sd, strerror(errno));
	}
	conn->err = errno;

	core_close(ctx, conn);
}
示例#11
0
static void
core_error(struct context *ctx, struct conn *conn)
{
    rstatus_t status;
    char type = conn->client ? 'c' : (conn->proxy ? 'p' : 's');

    status = nc_get_soerror(conn->sd);
    if (status < 0) {
        log_warn("get soerr on %c %d failed, ignored: %s", type, conn->sd,
                  strerror(errno));
    }
    conn->err = errno;

    core_close(ctx, conn);
}
示例#12
0
static void
core_timeout(struct context *ctx)
{
	for (;;) {
		struct msg *msg;
		struct conn *conn;
		int64_t now, then;

		msg = msg_tmo_min();
		if (msg == NULL) {
			ctx->timeout = ctx->max_timeout;
			return;
		}

		/* skip over req that are in-error or done */

		if (msg->error || msg->done) {
			msg_tmo_delete(msg);
			continue;
		}

		/*
		 * timeout expired req and all the outstanding req on the timing
		 * out server
		 */

		conn = msg->tmo_rbe.data;
		then = msg->tmo_rbe.key;

		now = dn_msec_now();
		if (now < then) {
			int delta = (int)(then - now);
			ctx->timeout = MIN(delta, ctx->max_timeout);
			return;
		}

		log_debug(LOG_INFO, "req %"PRIu64" on s %d timedout", msg->id, conn->sd);

		msg_tmo_delete(msg);

		if (conn->dyn_mode)
			return;  //don't close dyn connection in this case

		conn->err = ETIMEDOUT;

		core_close(ctx, conn);
	}
}
示例#13
0
static void
call_done (Event_Type et, Object *obj, Any_Type regarg, Any_Type callarg)
{
  Conn_Private_Data *cpriv;
  struct Conn_Info *ci;
  Sess *sess;
  Conn *conn;
  Call *call;

  assert (et == EV_CALL_RECV_STOP && object_is_call (obj));
  call = (Call *) obj;
  conn = call->conn;
  cpriv = CONN_PRIVATE_DATA (conn);
  sess = cpriv->sess;
  ci = cpriv->ci;

  ci->is_successful = 1;	/* conn has received at least one reply */

  /* remove the call from the conn_info structure */
  assert (ci->call[ci->rd] == call && ci->num_pending > 0 && ci->num_sent > 0);
  ci->call[ci->rd] = 0;
  ci->rd = (ci->rd + 1) % MAX_PIPED;
  --ci->num_pending;
  --ci->num_sent;

  /* if the reply status matches the failure status, the session has
     failed */
  if (param.failure_status && call->reply.status == param.failure_status)
    {
      if (param.retry_on_failure)
	session_issue_call (sess, call);
      else
	sess_failure (sess);
    }

  call_dec_ref (call);

  if (param.http_version < 0x10001)
    {
      /* Rather than waiting for the connection to close on us, we
	 close it pro-actively (this is what a pre-1.1 browser would
	 do.  */
      core_close (ci->conn);
      ci->conn = 0;
    }
}
示例#14
0
static void
core_close_cleanup (void *ignore)
{
  core_close (0/*ignored*/);
}
示例#15
0
EXPORT void CALL RomClosed (void)
{
    core_close();
}
示例#16
0
文件: corelow.c 项目: ibuclaw/gdb
static void
core_close_cleanup (void *ignore)
{
  core_close (NULL);
}
示例#17
0
rstatus_t
core_core(void *arg, uint32_t events)
{
	rstatus_t status;
	struct conn *conn = arg;
	struct context *ctx = conn_to_ctx(conn);


	/*
	if (!conn->dyn_mode) {
		if (conn->client && !conn->proxy) {
         struct server_pool *sp = conn->owner;
         log_debug(LOG_VERB, "Client           : '%.*s'", sp->name);
		} else if (!conn->client && !conn->proxy) {
			struct server *server = conn->owner;
			log_debug(LOG_VERB, "Storage server           : '%.*s'", server->name);
		} else {
			struct server_pool *sp = conn->owner;
			log_debug(LOG_VERB, "Proxy           : '%.*s'", sp->name);
		}
	} else {
      if (conn->dnode_client && !conn->dnode_server) {
      	struct server_pool *sp = conn->owner;
      	log_debug(LOG_VERB, "Dnode client           : '%.*s'", sp->name);
      } else if (!conn->dnode_client && !conn->dnode_server) {
			struct server *server = conn->owner;
			log_debug(LOG_VERB, "Dnode peer           : '%.*s'", server->name);
      } else {
			struct server_pool *sp = conn->owner;
			log_debug(LOG_VERB, "Dnode server           : '%.*s'", sp->name);
      }
	}
	 */

	if (conn->dyn_mode) {
		log_debug(LOG_VVERB, "event %04"PRIX32" on d_%c %d", events,
				conn->dnode_client ? 'c' : (conn->dnode_server ? 's' : 'p'), conn->sd);
	} else {
		log_debug(LOG_VVERB, "event %04"PRIX32" on %c %d", events,
				conn->client ? 'c' : (conn->proxy ? 'p' : 's'), conn->sd);
	}

	conn->events = events;

	/* error takes precedence over read | write */
	if (events & EVENT_ERR) {
		if (conn->err && conn->dyn_mode) {
			loga("conn err on dnode EVENT_ERR: %d", conn->err);
		}
		core_error(ctx, conn);

		return DN_ERROR;
	}

	/* read takes precedence over write */
	if (events & EVENT_READ) {
		status = core_recv(ctx, conn);

		if (status != DN_OK || conn->done || conn->err) {
			if (conn->dyn_mode) {
				if (conn->err) {
					loga("conn err on dnode EVENT_READ: %d", conn->err);
					core_close(ctx, conn);
					return DN_ERROR;
				}
				return DN_OK;
			}

			core_close(ctx, conn);
			return DN_ERROR;
		}
	}

	if (events & EVENT_WRITE) {
		status = core_send(ctx, conn);
		if (status != DN_OK || conn->done || conn->err) {
			if (conn->dyn_mode) {
				if (conn->err) {
					loga("conn err on dnode EVENT_WRITE: %d", conn->err);
					core_close(ctx, conn);
					return DN_ERROR;
				}
				return DN_OK;
			}

			core_close(ctx, conn);
			return DN_ERROR;
		}
	}

	return DN_OK;
}