int main(int argc, char **argv) { struct stat sb; int i; int p; if (stat(argv[1], &sb) == -1) { perror("stat"); exit(EXIT_SUCCESS); } my_putstr("Name: "); while (argv[1][i] != '\0') { if (argv[1][i] == '/') argv[1][i] = i + 1; i = i + 1; } while (argv[1][p] != '\0') { my_putchar(argv[1][p]); p = p + 1; } info_read(argv[1], sb); return (0); }
S32 LLCurl::Multi::process() { if(!isValid()) { return 0 ; } waitToComplete() ; if (getState() != STATE_COMPLETED) { return 0; } CURLMsg* msg; int msgs_in_queue; S32 processed = 0; while ((msg = info_read(&msgs_in_queue))) { ++processed; if (msg->msg == CURLMSG_DONE) { U32 response = 0; Easy* easy = NULL ; { LLMutexLock lock(mEasyMutexp) ; easy_active_map_t::iterator iter = mEasyActiveMap.find(msg->easy_handle); if (iter != mEasyActiveMap.end()) { easy = iter->second; } } if(easy) { response = easy->report(msg->data.result); removeEasy(easy); } else { response = 499; //*TODO: change to llwarns llerrs << "cleaned up curl request completed!" << llendl; } if (response >= 400) { // failure of some sort, inc mErrorCount for debugging and flagging multi for destruction ++mErrorCount; } } } setState(STATE_READY); return processed; }
static void pscom_openib_init(FILE *peer) { psoib_info_msg_t lmsg, rmsg; int rc; pscom.env.debug = arg_verbose; pscom_env_get_int(&pscom.env.debug, ENV_DEBUG); psoib_debug = pscom.env.debug; pscom_env_get_str(&psoib_hca, ENV_OPENIB_HCA); pscom_env_get_uint(&psoib_port, ENV_OPENIB_PORT); pscom_env_get_uint(&psoib_path_mtu, ENV_OPENIB_PATH_MTU); pscom_env_get_uint(&psoib_sendq_size, ENV_OPENIB_SENDQ_SIZE); pscom_env_get_uint(&psoib_recvq_size, ENV_OPENIB_RECVQ_SIZE); pscom_env_get_uint(&psoib_compq_size, ENV_OPENIB_COMPQ_SIZE); psoib_pending_tokens = psoib_pending_tokens_suggestion(); pscom_env_get_uint(&psoib_pending_tokens, ENV_OPENIB_PENDING_TOKENS); rc = psoib_init(); psoib_rc_check("psoib_init()", rc); mcon = psoib_con_create(); assert(mcon); rc = psoib_con_init(mcon, NULL, NULL); psoib_rc_check("psoib_con_init()", rc); psoib_con_get_info_msg(mcon, &lmsg); if (is_client) { info_write(peer, &lmsg); info_read(peer, &rmsg); } else { info_read(peer, &rmsg); info_write(peer, &lmsg); } rc = psoib_con_connect(mcon, &rmsg); psoib_rc_check("psoib_con_connect()", rc); }
// Usage: Call getRestult until it returns false (no more messages) bool LLCurlEasyRequest::getResult(CURLcode* result, LLCurl::TransferInfo* info) { if(!isValid()) { return false ; } if (!mMulti->isCompleted()) { //we're busy, try again later return false; } mMulti->setState(LLCurl::Multi::STATE_READY) ; if (!mEasy) { // Special case - we failed to initialize a curl_easy (can happen if too many open files) // Act as though the request failed to connect if (mResultReturned) { return false; } else { *result = CURLE_FAILED_INIT; mResultReturned = true; return true; } } // In theory, info_read might return a message with a status other than CURLMSG_DONE // In practice for all messages returned, msg == CURLMSG_DONE // Ignore other messages just in case while(1) { S32 q; CURLMsg* curlmsg = info_read(&q, info); if (curlmsg) { if (curlmsg->msg == CURLMSG_DONE) { *result = curlmsg->data.result; return true; } // else continue } else { return false; } } }
void config_start(char *config_path) { config_load(config_path); FILE *f = config_open(NULL, info_paths, "r"); log_msg("CONFIG", "%p", f); if (!f) { char *path = fs_expand_path(info_paths[0]); f = fopen(path, "w+"); if (f) fclose(f); free(path); return; } info_read(f); fclose(f); }
S32 LLCurl::Multi::process() { perform(); CURLMsg* msg; int msgs_in_queue; S32 processed = 0; while ((msg = info_read(&msgs_in_queue))) { ++processed; if (msg->msg == CURLMSG_DONE) { U32 response = 0; easy_active_map_t::iterator iter = mEasyActiveMap.find(msg->easy_handle); if (iter != mEasyActiveMap.end()) { Easy* easy = iter->second; response = easy->report(msg->data.result); removeEasy(easy); } else { response = 499; //*TODO: change to llwarns llerrs << "cleaned up curl request completed!" << llendl; } if (response >= 400) { // failure of some sort, inc mErrorCount for debugging and flagging multi for destruction ++mErrorCount; } } } return processed; }