Exemplo n.º 1
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;
        }
    }
}
Exemplo n.º 2
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;
}
Exemplo n.º 3
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;
}
Exemplo n.º 4
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;
        }
    }
}
Exemplo n.º 5
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;
}