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

Function thread_run

lib_protocol/samples/httpd/main.c:22–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20}
21
22static void thread_run(void *arg)
23{
24 CONN *conn = (CONN*) arg;
25 ACL_VSTREAM *client = conn->stream;
26 const char *reply_200 = "HTTP/1.1 200 OK\r\n"
27 "Server: nginx/0.6.32\r\n"
28 "Date: Tue, 29 Dec 2009 02:18:25 GMT\r\n"
29 "Content-Type: text/html\r\n"
30 "Content-Length: 43\r\n"
31 "Last-Modified: Mon, 16 Nov 2009 02:18:14 GMT\r\n"
32 "Connection: keep-alive\r\n"
33 "Accept-Ranges: bytes\r\n\r\n"
34 "<html>\n"
35 "<body>\n"
36 "hello world!\n"
37 "</body>\n"
38 "</html>\n";
39 int ret, keep_alive;
40 char buf[4096];
41
42 while (0) {
43 ret = read(ACL_VSTREAM_SOCK(client), buf, sizeof(buf));
44 if (ret == ACL_VSTREAM_EOF)
45 break;
46 ret = acl_vstream_writen(client, reply_200, strlen(reply_200));
47 if (ret == ACL_VSTREAM_EOF)
48 break;
49 }
50
51 while (0) {
52 ret = acl_vstream_read(client, buf, sizeof(buf));
53 if (ret == ACL_VSTREAM_EOF)
54 break;
55 ret = acl_vstream_writen(client, reply_200, strlen(reply_200));
56 if (ret == ACL_VSTREAM_EOF)
57 break;
58 }
59
60 while (0) {
61 /*
62 HTTP_REQ *req;
63 */
64 HTTP_HDR_REQ *hdr_req = http_hdr_req_new();
65
66 ret = http_hdr_req_get_sync(hdr_req, client, 300);
67 if (ret < 0) {
68 http_hdr_req_free(hdr_req);
69 break;
70 }
71 if (http_hdr_req_parse(hdr_req) < 0) {
72 http_hdr_req_free(hdr_req);
73 printf("parse error\n");
74 break;
75 }
76
77 /*
78 keep_alive = hdr_req->hdr.keep_alive;
79

Callers 2

thread_mainFunction · 0.70
run_serverFunction · 0.70

Calls 12

acl_vstream_writenFunction · 0.85
acl_vstream_readFunction · 0.85
http_hdr_req_newFunction · 0.85
http_hdr_req_get_syncFunction · 0.85
http_hdr_req_freeFunction · 0.85
http_hdr_req_parseFunction · 0.85
http_req_newFunction · 0.85
http_req_body_get_syncFunction · 0.85
http_req_freeFunction · 0.85
acl_vstream_closeFunction · 0.85
acl_pthread_selfFunction · 0.85
readFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…