示例#1
0
文件: cint.c 项目: lemlang/loglan82
    int main(int argc, char **argv) {

        initiate(argc, argv); /* initialize executor */
        #ifndef BASIC
        socket_setup();
        network_socket = socket_connect();
        #endif
        runsys(); /* initialize running system */
        if (has_network_socket()) {
            request_id();
            GraphRes = get_graph_res();
            graph_setstatus();
            if (GraphRes < 0) exit(12);
            if (remote) send_ready();
        }

        setjmp (contenv); /* set label for continue long jump */
        while (TRUE) { /* repeat until exit() is called */
            get_internal();
            schedule(); /* reschedule current process */
            if (ready != 0) {
                decode(); /* fetch instruction */
                execute(); /* and execute it */
            }
        }
        return 0;
    } /* end main */
示例#2
0
文件: flow.cpp 项目: Botrix/pentago
// Optionally compress an output block and send it
void flow_t::send_output(line_details_t* const line, const int b) {
  const auto block = line->pre.line.block(b);
  const auto owner_and_id = output_blocks.partition->find_block(line->pre.line.section,block);
  const int owner = owner_and_id.x;
  const local_id_t owner_block_id = owner_and_id.y;
  const int tag = request_id(owner_block_id,line->pre.line.dimension);
  const auto event = line->pre.line.block_line_event(b);
  MPI_Request request;
#if PENTAGO_MPI_COMPRESS_OUTPUTS
  // Send compressed block
  thread_time_t time(output_send_kind,event);
  const auto compressed = line->compressed_output_block_data(b);
  CHECK(MPI_Isend((void*)compressed.data(),compressed.size(),MPI_BYTE,owner,tag,comms.output_comm,&request));
  PENTAGO_MPI_TRACE("send output %p: owner %d, owner block id %d, dimension %d, count %d, tag %d, event 0x%llx",line,owner,owner_block_id.id,line->pre.line.dimension,compressed.size(),tag,event);
#else
  // Send without compression
  thread_time_t time(output_send_kind,event);
  const auto block_data = line->output_block_data(b);
  CHECK(MPI_Isend((void*)block_data.data(),8*block_data.size(),MPI_LONG_LONG_INT,owner,tag,comms.output_comm,&request));
  PENTAGO_MPI_TRACE("send output %p: owner %d, owner block id %d, dimension %d, count %d, tag %d, event 0x%llx",line,owner,owner_block_id.id,line->pre.line.dimension,block_data.size(),tag,event);
#endif
  requests.add(request,curry(&flow_t::finish_output_send,this,line));
}
示例#3
0
bool CWRequest::ReceiveFromBridge(string sSessionID, string* pRequestID, bool* pSetResponseCookie, bool* pSecure, bool* pKeepAlive, bool bLongPolling, int iTimeoutMS, CWCallbackFunction pCallback, const void* pCallbackArg, int iCallbackIntervalMS, string* pErrorMessage)
{
    if(sSessionID == "")
    {
        if(pErrorMessage != NULL) *pErrorMessage = "session_id is empty.";
        return false;
    }

    Clear();

    // ---
    // read request id from queue
    // ---
    string queue_filename = "";
    if(bLongPolling)
    {
        queue_filename = TempDir() + sSessionID + ".queue_lp";

        // if no long polling request is waiting, return false
        int queue_size = 0;
        if(!FileExists(queue_filename, &queue_size))
            return false;

        if(queue_size <= 0)
            return false;
    }
    else
        queue_filename = TempDir() + sSessionID + ".queue";

    char* buffer = NULL;
    int buffer_size = 0;
    if(!PopData(queue_filename, (void**)&buffer, &buffer_size, iTimeoutMS, pCallback, pCallbackArg, iCallbackIntervalMS, pErrorMessage))
        return false;

    string request_id(buffer, buffer_size);
    free(buffer);

    // ---
    // read request from file
    // ---
    string request_filename = TempDir() + request_id + ".request";

    int fd = -1;
    int file_size = 0;
    if(!FileOpenExistingAndLock(request_filename, REQUEST_RECEIVE_TIMEOUT, &fd, &file_size, pErrorMessage))
        return false;

    // query
    if(!FileReadStringList(fd, Query, pErrorMessage))
    {
        FileUnlockAndClose(fd, NULL);
        return false;
    }

    // post
    if(!FileReadStringList(fd, Post, pErrorMessage))
    {
        FileUnlockAndClose(fd, NULL);
        return false;
    }

    // cookie
    if(!FileReadStringList(fd, Cookie, pErrorMessage))
    {
        FileUnlockAndClose(fd, NULL);
        return false;
    }

    // env
    if(!FileReadStringList(fd, Env, pErrorMessage))
    {
        FileUnlockAndClose(fd, NULL);
        return false;
    }

    // unlock file
    FileUnlockAndClose(fd, NULL);

    // delete file
    FileDelete(request_filename, NULL);

    if(Cookie->GetValue("session_id") != sSessionID)
    {
        Cookie->SetValue("session_id", sSessionID);
        *pSetResponseCookie = true;
    }
    else
        *pSetResponseCookie = false;

    if(Env->GetValue("HTTPS") == "on")
        *pSecure = true;
    else
        *pSecure = false;

    if(pKeepAlive != NULL) *pKeepAlive = GetValue("keep_alive") == "1" || GetValue("keep_alive") == "true";

    *pRequestID = request_id;

    return true;
}