INT cd_multi(INT cmd, EQUIPMENT * pequipment) { INT status; switch (cmd) { case CMD_INIT: status = multi_init(pequipment); break; case CMD_EXIT: status = multi_exit(pequipment); break; case CMD_START: status = multi_start(pequipment); break; case CMD_STOP: status = multi_stop(pequipment); break; case CMD_IDLE: status = multi_idle(pequipment); break; default: cm_msg(MERROR, "Multimeter class driver", "Received unknown command %d", cmd); status = FE_ERR_DRIVER; break; } return status; }
void __init rte_cb_early_init (void) { v850e_intc_disable_irqs (); #ifdef CONFIG_RTE_CB_MULTI multi_init (); #endif }
int test(char *URL) { int stillRunning; CURLM* multiHandle = NULL; CURL* curl = NULL; int res = 0; global_init(CURL_GLOBAL_ALL); multi_init(multiHandle); easy_init(curl); easy_setopt(curl, CURLOPT_USERPWD, libtest_arg2); easy_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE, "curl_client_key.pub"); easy_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE, "curl_client_key"); easy_setopt(curl, CURLOPT_UPLOAD, 1L); easy_setopt(curl, CURLOPT_VERBOSE, 1L); easy_setopt(curl, CURLOPT_URL, URL); easy_setopt(curl, CURLOPT_INFILESIZE, (long)5); multi_add_handle(multiHandle, curl); /* this tests if removing an easy handle immediately after multi perform has been called succeeds or not. */ fprintf(stderr, "curl_multi_perform()...\n"); multi_perform(multiHandle, &stillRunning); fprintf(stderr, "curl_multi_perform() succeeded\n"); fprintf(stderr, "curl_multi_remove_handle()...\n"); res = (int) curl_multi_remove_handle(multiHandle, curl); if(res) fprintf(stderr, "curl_multi_remove_handle() failed, " "with code %d\n", res); else fprintf(stderr, "curl_multi_remove_handle() succeeded\n"); test_cleanup: /* undocumented cleanup sequence - type UB */ curl_easy_cleanup(curl); curl_multi_cleanup(multiHandle); curl_global_cleanup(); return res; }
int test(char *URL) { CURLM *multi = NULL; int res = 0; char *address = libtest_arg2; char *port = libtest_arg3; char *path = URL; char dns_entry[256]; int i; int count = 2; msnprintf(dns_entry, sizeof(dns_entry), "testserver.example.com:%s:%s", port, address); start_test_timing(); global_init(CURL_GLOBAL_ALL); multi_init(multi); for(i = 1; i <= count; i++) { char target_url[256]; msnprintf(target_url, sizeof(target_url), "http://testserver.example.com:%s/%s%04d", port, path, i); /* second request must succeed like the first one */ res = do_one_request(multi, target_url, dns_entry); if(res) goto test_cleanup; if(i < count) sleep(DNS_TIMEOUT + 1); } test_cleanup: curl_multi_cleanup(multi); curl_global_cleanup(); return (int) res; }
int test(char *URL) { int res = 0; CURLM *m = NULL; (void)URL; global_init(CURL_GLOBAL_ALL); multi_init(m); test_cleanup: /* proper cleanup sequence - type PB */ curl_multi_cleanup(m); curl_global_cleanup(); printf("We are done\n"); return res; }
void DllLibCurlGlobal::easy_aquire(const char *protocol, const char *hostname, CURL_HANDLE** easy_handle, CURLM** multi_handle) { assert(easy_handle != NULL); CSingleLock lock(m_critSection); VEC_CURLSESSIONS::iterator it; for(it = m_sessions.begin(); it != m_sessions.end(); it++) { if( !it->m_busy ) { /* allow reuse of requester is trying to connect to same host */ /* curl will take care of any differences in username/password */ if( it->m_protocol.compare(protocol) == 0 && it->m_hostname.compare(hostname) == 0) { it->m_busy = true; if(easy_handle) { if(!it->m_easy) it->m_easy = easy_init(); *easy_handle = it->m_easy; } if(multi_handle) { if(!it->m_multi) it->m_multi = multi_init(); *multi_handle = it->m_multi; } return; } } } SSession session = {}; session.m_idletimestamp = 0; session.m_busy = true; session.m_protocol = protocol; session.m_hostname = hostname; session.m_multi = session.m_easy = NULL; /* count up global interface counter */ Load(); if(easy_handle) { session.m_easy = easy_init(); *easy_handle = session.m_easy; } if(multi_handle) { session.m_multi = multi_init(); *multi_handle = session.m_multi; } m_sessions.push_back(session); CLog::Log(LOGDEBUG, "%s - Created session to %s://%s\n", __FUNCTION__, protocol, hostname); return; }
int test(char *URL) { CURL *handle = NULL; CURL *duphandle = NULL; CURLM *mhandle = NULL; int res = 0; int still_running = 0; start_test_timing(); global_init(CURL_GLOBAL_ALL); easy_init(handle); easy_setopt(handle, CURLOPT_URL, URL); easy_setopt(handle, CURLOPT_WILDCARDMATCH, 1L); easy_setopt(handle, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(handle); if(res) goto test_cleanup; res = curl_easy_perform(handle); if(res) goto test_cleanup; duphandle = curl_easy_duphandle(handle); if(!duphandle) goto test_cleanup; curl_easy_cleanup(handle); handle = duphandle; multi_init(mhandle); multi_add_handle(mhandle, handle); multi_perform(mhandle, &still_running); abort_on_test_timeout(); while(still_running) { struct timeval timeout; fd_set fdread; fd_set fdwrite; fd_set fdexcep; int maxfd = -99; timeout.tv_sec = 0; timeout.tv_usec = 100000L; /* 100 ms */ FD_ZERO(&fdread); FD_ZERO(&fdwrite); FD_ZERO(&fdexcep); multi_fdset(mhandle, &fdread, &fdwrite, &fdexcep, &maxfd); /* At this point, maxfd is guaranteed to be greater or equal than -1. */ select_test(maxfd + 1, &fdread, &fdwrite, &fdexcep, &timeout); abort_on_test_timeout(); multi_perform(mhandle, &still_running); abort_on_test_timeout(); } test_cleanup: /* undocumented cleanup sequence - type UA */ curl_multi_cleanup(mhandle); curl_easy_cleanup(handle); curl_global_cleanup(); return res; }
int test(char *URL) { int res = 0; CURL *curl = NULL; int running; CURLM *m = NULL; start_test_timing(); global_init(CURL_GLOBAL_ALL); easy_init(curl); easy_setopt(curl, CURLOPT_URL, URL); easy_setopt(curl, CURLOPT_VERBOSE, 1L); easy_setopt(curl, CURLOPT_PROXY, libtest_arg2); easy_setopt(curl, CURLOPT_PROXYTYPE, (long)CURLPROXY_SOCKS4); multi_init(m); multi_add_handle(m, curl); fprintf(stderr, "Start at URL 0\n"); for(;;) { struct timeval interval; fd_set rd, wr, exc; int maxfd = -99; interval.tv_sec = 1; interval.tv_usec = 0; multi_perform(m, &running); abort_on_test_timeout(); if(!running) break; /* done */ FD_ZERO(&rd); FD_ZERO(&wr); FD_ZERO(&exc); multi_fdset(m, &rd, &wr, &exc, &maxfd); /* At this point, maxfd is guaranteed to be greater or equal than -1. */ select_test(maxfd + 1, &rd, &wr, &exc, &interval); abort_on_test_timeout(); } test_cleanup: /* undocumented cleanup sequence - type UB */ curl_easy_cleanup(curl); curl_multi_cleanup(m); curl_global_cleanup(); return res; }
int test(char *URL) { CURL *c = NULL; CURLM *m = NULL; int res = 0; int running; start_test_timing(); global_init(CURL_GLOBAL_ALL); easy_init(c); easy_setopt(c, CURLOPT_PROXY, libtest_arg2); /* set in first.c */ easy_setopt(c, CURLOPT_URL, URL); easy_setopt(c, CURLOPT_USERPWD, "test:ing"); easy_setopt(c, CURLOPT_PROXYUSERPWD, "test:ing"); easy_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1L); easy_setopt(c, CURLOPT_HEADER, 1L); easy_setopt(c, CURLOPT_VERBOSE, 1L); multi_init(m); multi_add_handle(m, c); for(;;) { struct timeval interval; fd_set rd, wr, exc; int maxfd = -99; interval.tv_sec = 1; interval.tv_usec = 0; multi_perform(m, &running); abort_on_test_timeout(); if(!running) break; /* done */ FD_ZERO(&rd); FD_ZERO(&wr); FD_ZERO(&exc); multi_fdset(m, &rd, &wr, &exc, &maxfd); /* At this point, maxfd is guaranteed to be greater or equal than -1. */ select_test(maxfd + 1, &rd, &wr, &exc, &interval); abort_on_test_timeout(); } test_cleanup: /* proper cleanup sequence - type PA */ curl_multi_remove_handle(m, c); curl_multi_cleanup(m); curl_easy_cleanup(c); curl_global_cleanup(); return res; }
/** * Main event loop for OpenVPN in UDP server mode. * @ingroup eventloop * * This function implements OpenVPN's main event loop for UDP server mode. * At this time, OpenVPN does not yet support multithreading. This * function's name is therefore slightly misleading. * * @param top - Top-level context structure. */ static void tunnel_server_udp_single_threaded (struct context *top) { struct multi_context multi; top->mode = CM_TOP; context_clear_2 (top); /* initialize top-tunnel instance */ init_instance_handle_signals (top, top->es, CC_HARD_USR1_TO_HUP); if (IS_SIG (top)) return; /* initialize global multi_context object */ multi_init (&multi, top, false, MC_SINGLE_THREADED); /* initialize our cloned top object */ multi_top_init (&multi, top, true); /* initialize management interface */ init_management_callback_multi (&multi); /* finished with initialization */ initialization_sequence_completed (top, ISC_SERVER); /* --mode server --proto udp */ /* per-packet event loop */ while (true) { perf_push (PERF_EVENT_LOOP); /* set up and do the io_wait() */ multi_get_timeout (&multi, &multi.top.c2.timeval); io_wait (&multi.top, p2mp_iow_flags (&multi)); MULTI_CHECK_SIG (&multi); /* check on status of coarse timers */ multi_process_per_second_timers (&multi); /* timeout? */ if (multi.top.c2.event_set_status == ES_TIMEOUT) { multi_process_timeout (&multi, MPP_PRE_SELECT|MPP_CLOSE_ON_SIGNAL); } else { /* process I/O */ multi_process_io_udp (&multi); MULTI_CHECK_SIG (&multi); } perf_pop (); } /* shut down management interface */ uninit_management_callback_multi (&multi); /* save ifconfig-pool */ multi_ifconfig_pool_persist (&multi, true); /* tear down tunnel instance (unless --persist-tun) */ multi_uninit (&multi); multi_top_free (&multi); close_instance (top); }