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

Function fiber_accept

lib_fiber/samples-c++/https_server/main.cpp:80–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80static void fiber_accept(ACL_FIBER *, void *ctx)
81{
82 const char* addr = (const char* ) ctx;
83 acl::server_socket server;
84 ACL_FIBER_ATTR attr;
85
86 acl_fiber_attr_init(&attr);
87
88 if (__shared_stack) {
89 acl_fiber_attr_setstacksize(&attr, 4096);
90 acl_fiber_attr_setsharestack(&attr, 1);
91 }
92
93 ssl_init(*__ssl_conf, __ssl_crt, __ssl_key);
94
95 if (!server.open(addr)) {
96 printf("open %s error\r\n", addr);
97 exit (1);
98 } else {
99 printf(">>> listen %s ok\r\n", addr);
100 }
101
102 while (true) {
103 acl::socket_stream* client = server.accept();
104 if (client == NULL) {
105 printf("accept failed: %s\r\n", acl::last_serror());
106 break;
107 }
108
109 client->set_rw_timeout(__rw_timeout);
110 printf("accept one: %d\r\n", client->sock_handle());
111 if (__shared_stack) {
112 acl_fiber_create2(&attr, http_server, client);
113 } else {
114 acl_fiber_create(http_server, client, STACK_SIZE);
115 }
116 }
117
118 exit (0);
119}
120
121static void usage(const char* procname)
122{

Callers

nothing calls this directly

Calls 11

acl_fiber_attr_initFunction · 0.85
acl_fiber_create2Function · 0.85
set_rw_timeoutMethod · 0.80
ssl_initFunction · 0.70
last_serrorFunction · 0.50
acl_fiber_createFunction · 0.50
openMethod · 0.45
acceptMethod · 0.45
sock_handleMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…