Exemplo n.º 1
0
static int processreq(int fd)
{
    lscgid_t cgi_req;
    int ret;

    ret = recv_req(fd, &cgi_req, 10);
    if (ret)
        cgiError(fd, ret);
    else
    {
        ret = execute_cgi(&cgi_req);
        if (ret)
            cgiError(fd, ret);
    }
    return ret;
}
Exemplo n.º 2
0
void data_store_csv::exchange_data() {
  double tm1 = get_time();
  std::stringstream err;

  //get indices I need for the next epoch, and start receives
  std::unordered_set<int> indices;
  get_indices(indices, m_rank);
  std::vector<El::mpi::Request<DataType>> recv_req(indices.size());

  m_my_minibatch_data.clear();
  size_t jj = 0;
  for (auto data_id : indices) {
    m_my_minibatch_data[data_id].resize(m_vector_size);
    int owner = get_index_owner(data_id);
    if (owner >= m_np or owner < 0) {
      err << __FILE__ << " " << __LINE__ << " :: "
          << " ERROR: bad rank for owner in nb_recv; owner: " << owner << " data_id: " << data_id << " jj: " << jj+1 << " of " << indices.size();
      throw lbann_exception(err.str());
    }
    m_comm->nb_tagged_recv<DataType>(m_my_minibatch_data[data_id].data(), m_vector_size, owner, data_id, recv_req[jj++], m_comm->get_trainer_comm());
  }

  //start sends to all processors
  std::vector<std::vector<El::mpi::Request<DataType>>> send_req(m_np);
  for (int p=0; p<m_np; p++) {
    get_my_indices(indices, p);
    send_req[p].resize(indices.size());
    jj = 0;
    for (auto data_id : indices) {
      if (m_data.find(data_id) == m_data.end()) {
        err << __FILE__ << " " << __LINE__ << " :: "
            << " m_data.find(" << data_id << ") failed.";
        throw lbann_exception(err.str());
      }
      if (m_data[data_id].size() != (size_t)m_vector_size) {
        err << __FILE__ << " " << __LINE__ << " :: "
            << " m_data[" << data_id << "].size = " << m_data[data_id].size()
            << " should be: " << m_vector_size << "; " << jj+1
            << " of " << indices.size()
            << " m_reader->get_role: " << m_reader->get_role();
        throw lbann_exception(err.str());
      }
      m_comm->nb_tagged_send<DataType>(m_data[data_id].data(), m_vector_size, p, data_id, send_req[p][jj++], m_comm->get_trainer_comm());
    }
  }

  //wait for sends to finish
  if (m_master) {
    for (size_t i=0; i<send_req.size(); i++) {
      m_comm->wait_all(send_req[i]);
    }
  }

  //wait for recvs to finish
  m_comm->wait_all(recv_req);

  if (m_master) {
    std::cerr << "TIME for data_store_csv::exchange_data(): "
             << get_time() - tm1 << "; role: " << m_reader->get_role() << "\n";
  }
}
Exemplo n.º 3
0
static int do_work(void * arg)
{
    lxmt_hdarg *harg = (lxmt_hdarg*)arg;
    int fd,ret;
    char buff[1024];
    h_parser_ctx ctx;

    //printf("begin\n");
    
    fd = harg->conn.fd;
    if(lx_set_timeo(fd,g_ctx->stimeo_milli,g_ctx->rtimeo_milli))
    {
        g_ctx->log.logerror(&g_ctx->log,"lx_set_timeo error,fd:%d",fd);
        ret = -1;
        goto end;
    }
    
    http_set_uri_sep(&ctx,'?','&','=');
    http_set_memory_msuit(&ctx,malloc,free,http_extend);
 
	if( http_ctx_init(&ctx,T_REQ,64)){
        g_ctx->log.logerror(&g_ctx->log,"init parser ctx error");
        ret = -1;goto end;
    }

    if(recv_req(fd,g_ctx->is_nostub,&ctx)){
        g_ctx->log.logerror(&g_ctx->log ,"recv_req error,fd:%d",fd);
        ret = -1; goto end;
    }
/*
    if(http_print_http(&ctx)){
        g_ctx->log.logerror(&g_ctx->log,"print_pare_info error");
        ret = -1;goto end;
    }
*/
    if(send_resp(fd,g_ctx->is_nostub,&ctx)){
        g_ctx->log.logerror(&g_ctx->log,"send resp error,fd:%d",fd);
        ret = -1; goto end;
    }
    
    if( !inet_ntop(AF_INET, (void *)&harg->conn.addr.sin_addr, buff,16) ){
        g_ctx->log.logerror(&g_ctx->log,"inet_ntop error");
        ret = -1;goto end;
    }
    if(getwidetime(time(NULL),buff +16,32) <=0){
        g_ctx->log.logerror(&g_ctx->log,"get_wide_time error");
        ret = -1;goto end;
    }
    g_ctx->log.loginfo(&g_ctx->log,"uri:%s,addr:%s:%d,start:%s,duration:%ld"
        ,http_get_uri(&ctx.info),buff,(int)ntohs(harg->conn.addr.sin_port),
        buff+16,get_inval_micros(&harg->conn.accept_time ,NULL));
    ret = 0;
    
end:
    if(fd != -1){
        if(ret != 0)
            g_ctx->log.logerror(&g_ctx->log,"error occur in do_work, fd:%d ,ret:%d",fd,ret);
        close(fd);
        fd = -1;
        harg->conn.fd = -1;
    }   
    http_ctx_cleanup(&ctx);
    free (arg); 
    //printf("end\n");
    return ret;
}
Exemplo n.º 4
0
void process_client(client_arg_t *args)
{
/*  The thread responsible for accepting a client connection
 *    and processing the request.
 *  The QUERY cmd is processed entirely by this thread.
 *  The MONITOR and CONNECT cmds are setup and then placed
 *    in the conf->objs list to be handled by mux_io().
 */
    int sd;
    server_conf_t *conf;
    req_t *req;

    /*  Free the tmp struct that was created by accept_client()
     *    in order to pass multiple args to this thread.
     */
    assert(args != NULL);
    sd = args->sd;
    conf = args->conf;
    free(args);

    DPRINTF((5, "Processing new client.\n"));

    x_pthread_detach(pthread_self());

    req = create_req();

    if (resolve_addr(conf, req, sd) < 0)
        goto err;
    if (recv_greeting(req) < 0)
        goto err;
    if (recv_req(req) < 0)
        goto err;
    if (query_consoles(conf, req) < 0)
        goto err;
    if (validate_req(req) < 0)
        goto err;

    /*  send_rsp() needs to know if the reset command is supported.
     *    Since it cannot check resetCmd in the server_conf struct,
     *    we set a flag in the request struct instead.
     */
    if (conf->resetCmd)
        req->enableReset = 1;

    switch(req->command) {
    case CONMAN_CMD_CONNECT:
        if (perform_connect_cmd(req, conf) < 0)
            goto err;
        break;
    case CONMAN_CMD_MONITOR:
        if (perform_monitor_cmd(req, conf) < 0)
            goto err;
        break;
    case CONMAN_CMD_QUERY:
        if (perform_query_cmd(req) < 0)
            goto err;
        break;
    default:
        log_msg(LOG_WARNING, "Received invalid command=%d from <%s@%s:%d>",
            req->command, req->user, req->fqdn, req->port);
        goto err;
    }
    return;

err:
    destroy_req(req);
    return;
}