MCPcopy Create free account
hub / github.com/acl-dev/acl / run

Method run

lib_acl_cpp/samples/check_trigger/http_job.cpp:19–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17}
18
19void* http_job::run()
20{
21 char addr[256];
22 if (acl::http_utils::get_addr(url_, addr, sizeof(addr)) == false)
23 {
24 logger_error("invalid url: %s", url_.c_str());
25 return NULL;
26 }
27
28 char* domain = addr, *ptr = strchr(domain, ':');
29 int port;
30 if (ptr == NULL)
31 port = 80;
32 else
33 {
34 *ptr++ = 0;
35 port = atoi(ptr);
36 }
37
38 std::vector<acl::string> ips;
39
40 struct timeval begin, end;
41
42 gettimeofday(&begin, NULL);
43
44 // ��ѯ������ IP �б�
45 if (dns_lookup(domain, ips) == false)
46 {
47 delete this;
48 return NULL;
49 }
50
51 gettimeofday(&end, NULL);
52
53 // ���� DNS �IJ�ѯ��ʱ
54 double spent = util::stamp_sub(&end, &begin);
55
56 std::vector<acl::thread*> threads;
57
58 // ���� IP ��ַ�б���ÿһ�� IP ����һ�� HTTP �ͻ����߳�
59 std::vector<acl::string>::const_iterator cit = ips.begin();
60 for (; cit != ips.end(); ++cit)
61 {
62 // ����������һ���̶߳���
63 acl::thread* thr = new http_thread(domain, (*cit).c_str(),
64 port, url_.c_str(), spent);
65 thr->set_detachable(false); // �����߳�Ϊ�Ƿ���״̬
66 thr->start();
67 threads.push_back(thr);
68 }
69
70 // �ȴ����� HTTP �����߳�ִ�����
71 std::vector<acl::thread*>::iterator it = threads.begin();
72 for (; it != threads.end(); ++it)
73 {
74 acl::thread* thr = (*it);
75 thr->wait();
76 delete thr;

Callers

nothing calls this directly

Calls 10

beginMethod · 0.80
get_addrFunction · 0.50
gettimeofdayFunction · 0.50
dns_lookupFunction · 0.50
stamp_subFunction · 0.50
c_strMethod · 0.45
endMethod · 0.45
startMethod · 0.45
push_backMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected