| 32 | } |
| 33 | |
| 34 | int main(int argc, char* argv[]) { |
| 35 | |
| 36 | struct sigaction sigIntHandler; |
| 37 | sigIntHandler.sa_handler = SIG_IGN; |
| 38 | sigaction(SIGPIPE, &sigIntHandler, 0); // avoid the server crash when writing to a closed connection |
| 39 | sigIntHandler.sa_handler = CTRLC; |
| 40 | sigaction(SIGINT, &sigIntHandler, 0); |
| 41 | |
| 42 | // boost::thread* thTmp; |
| 43 | // boost::thread_attributes attrs; |
| 44 | // attrs.set_stack_size(THREAD_STACK_SIZE); |
| 45 | |
| 46 | int devCnt = 0; |
| 47 | cudaError_t exit_code = cudaGetDeviceCount(&devCnt); |
| 48 | if (exit_code != cudaSuccess) { |
| 49 | tool::Logging(LOG_ERROR, myName, "cudaGetDeviceCount failed: %s\n", cudaGetErrorName(exit_code)); |
| 50 | exit(EXIT_FAILURE); |
| 51 | } |
| 52 | |
| 53 | |
| 54 | connectionObj = new UCPConnection(false); |
| 55 | connectionObj->Listen(config_.GetServerIp(), config_.GetServerPort(), ServerEndpoint::CreateServerEp); |
| 56 | connectionObj->WaitConnection(&isClosed); |
| 57 | |
| 58 | cleanup(); |
| 59 | |
| 60 | // while(true) { |
| 61 | // ucp_conn_request_h conn_request = NULL; |
| 62 | // uint64_t client_id = 0; |
| 63 | // char* clientIP = NULL; |
| 64 | // char* clientPort = NULL; |
| 65 | // connectionObj->WaitConnection(&conn_request, &client_id, &clientIP, &clientPort); |
| 66 | |
| 67 | // // ucp_worker_h dataWorker; |
| 68 | // // connectionObj->InitWorker(&dataWorker); |
| 69 | // // both dataWorker and conn_request are pointers to the struct |
| 70 | // serverEndPointObj = new ServerEndpoint(connectionObj->CreateWorker(), conn_request, client_id, clientIP, clientPort); |
| 71 | |
| 72 | // thTmp = new boost::thread(attrs, boost::bind(&ServerEndpoint::Run, serverEndPointObj)); |
| 73 | // thList.emplace_back(thTmp); |
| 74 | // //serverEpList.push_back(serverEndPointObj); |
| 75 | // } |
| 76 | |
| 77 | // boost::thread CreateServeEp([&]() { |
| 78 | // UCPConnection_t conn; |
| 79 | // while (!isClosed) { |
| 80 | // if (q.wait_dequeue_timed(conn, std::chrono::seconds(2))) { // wakeup for every 2 seconds |
| 81 | // serverEndPointObj = new ServerEndpoint(connectionObj->CreateWorker(), conn); |
| 82 | // thTmp = new boost::thread(attrs, boost::bind(&ServerEndpoint::NewRun, serverEndPointObj)); |
| 83 | // thList.emplace_back(thTmp); |
| 84 | // } |
| 85 | // } |
| 86 | // }); |
| 87 | |
| 88 | // boost::thread WaitConn([&]() { |
| 89 | // while (!isClosed) { |
| 90 | // UCPConnection_t conn; |
| 91 | // connectionObj->WaitConnection(&conn, &isClosed); |
nothing calls this directly
no test coverage detected