项目作者: iqiyi

项目描述 :
The high performance coroutine library for Linux/FreeBSD/MacOS/Windows, supporting select/poll/epoll/kqueue/iocp/windows GUI
高级语言: C
项目地址: git://github.com/iqiyi/libfiber.git
创建时间: 2018-02-09T13:46:05Z
项目社区:https://github.com/iqiyi/libfiber

开源协议:GNU Lesser General Public License v3.0

下载


The high performance coroutine library, supporting Linux/BSD/Mac/Windows

中文说明

1 About

The libfiber project comes from the coroutine module of the acl project in lib_fiber directory of which. It can be used on OS platforms including Linux, FreeBSD, macOS, and Windows, which supports select, poll, epoll, kqueue, iocp, and even Windows GUI messages for different platform. With libfiber, you can write network application services having the high performance and large concurrent more easily than the traditional asynchronous framework with event-driven model. What’s more, with the help of libfiber, you can even write network module of the Windows GUI application written by MFC, wtl or other GUI framework on Windows in coroutine way. That’s really amazing.

2 Which IO events are supported ?

The libfiber supports many events including select/poll/epoll/kqueue/iocp, and Windows GUI messages.

Platform Event type
Linux select, poll, epoll, io-uring
BSD select, poll, kqueue
Mac select, poll, kqueue
Windows select, poll, iocp, GUI Message

3 SAMPLES

3.1 One server sample with C API

  1. // fiber_server.c
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <assert.h>
  5. #include "fiber/lib_fiber.h"
  6. #include "patch.h" // in the samples' path
  7. static size_t __stack_size = 128000;
  8. static const char *__listen_ip = "127.0.0.1";
  9. static int __listen_port = 9001;
  10. // Set read/write timeout with setsockopt API.
  11. static int set_timeout(SOCKET fd, int opt, int timeo) {
  12. # if defined(_WIN32) || defined(_WIN64)
  13. timeout *= 1000; // From seconds to millisecond.
  14. if (setsockopt(fd, SOL_SOCKET, opt, (const char*) &timeo, sizeof(timeo)) < 0) {
  15. printf("setsockopt error=%s, timeout=%d, opt=%d, fd=%d\r\n",
  16. strerror(errno), timeo, opt, (int) fd);
  17. return -1;
  18. }
  19. # else // Must be Linux or __APPLE__.
  20. struct timeval tm;
  21. tm.tv_sec = timeo;
  22. tm.tv_usec = 0;
  23. if (setsockopt(fd, SOL_SOCKET, opt, &tm, sizeof(tm)) < 0) {
  24. printf("setsockopt error=%s, timeout=%d, opt=%d, fd=%d\r\n",
  25. strerror(errno), timeo, opt, (int) fd);
  26. return -1;
  27. }
  28. # endif
  29. return 0;
  30. }
  31. static int set_rw_timeout(SOCKET fd, int timeo) {
  32. if (set_timeout(fd, SO_RCVTIMEO, timeo) == -1
  33. || set_timeout(fd, SO_SNDTIMEO, timeo) == -1) {
  34. return -1;
  35. }
  36. return 0;
  37. }
  38. static void fiber_client(ACL_FIBER *fb, void *ctx) {
  39. SOCKET *pfd = (SOCKET *) ctx;
  40. char buf[8192];
  41. // Set the socket's read/write timeout.
  42. set_rw_timeout(*pfd, 10);
  43. while (1) {
  44. #ifdef _WIN32
  45. int ret = acl_fiber_recv(*pfd, buf, sizeof(buf), 0);
  46. #else
  47. int ret = recv(*pfd, buf, sizeof(buf), 0);
  48. #endif
  49. if (ret == 0) {
  50. break;
  51. } else if (ret < 0) {
  52. if (acl_fiber_last_error() == FIBER_EINTR) {
  53. continue;
  54. }
  55. break;
  56. }
  57. #ifdef _WIN32
  58. if (acl_fiber_send(*pfd, buf, ret, 0) < 0) {
  59. #else
  60. if (send(*pfd, buf, ret, 0) < 0) {
  61. #endif
  62. break;
  63. }
  64. }
  65. socket_close(*pfd);
  66. free(pfd);
  67. }
  68. static void fiber_accept(ACL_FIBER *fb, void *ctx) {
  69. const char *addr = (const char *) ctx;
  70. SOCKET lfd = socket_listen(__listen_ip, __listen_port);
  71. assert(lfd >= 0);
  72. for (;;) {
  73. SOCKET *pfd, cfd = socket_accept(lfd);
  74. if (cfd == INVALID_SOCKET) {
  75. printf("accept error %s\r\n", acl_fiber_last_serror());
  76. break;
  77. }
  78. pfd = (SOCKET *) malloc(sizeof(SOCKET));
  79. *pfd = cfd;
  80. // create and start one fiber to handle the client socket IO
  81. acl_fiber_create(fiber_client, pfd, __stack_size);
  82. }
  83. socket_close(lfd);
  84. exit (0);
  85. }
  86. // FIBER_EVENT_KERNEL represents the event type on
  87. // Linux(epoll), BSD(kqueue), Mac(kqueue), Windows(iocp)
  88. // FIBER_EVENT_POLL: poll on Linux/BSD/Mac/Windows
  89. // FIBER_EVENT_SELECT: select on Linux/BSD/Mac/Windows
  90. // FIBER_EVENT_WMSG: Win GUI message on Windows
  91. // acl_fiber_create/acl_fiber_schedule_with are in `lib_fiber.h`.
  92. // socket_listen/socket_accept/socket_close are in patch.c of the samples' path.
  93. int main(void) {
  94. int event_mode = FIBER_EVENT_KERNEL;
  95. #ifdef _WIN32
  96. socket_init();
  97. #endif
  98. // create one fiber to accept connections
  99. acl_fiber_create(fiber_accept, NULL, __stack_size);
  100. // start the fiber schedule process
  101. acl_fiber_schedule_with(event_mode);
  102. #ifdef _WIN32
  103. socket_end();
  104. #endif
  105. return 0;
  106. }

3.2 One client sample with C API

  1. // fiber_client.c
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <assert.h>
  6. #include "fiber/lib_fiber.h"
  7. #include "patch.h" // in the samples' path
  8. static const char *__server_ip = "127.0.0.1";
  9. static int __server_port = 9001;
  10. // socket_init/socket_end/socket_connect/socket_close are in patch.c of the samples path
  11. static void fiber_client(ACL_FIBER *fb, void *ctx) {
  12. SOCKET cfd = socket_connect(__server_ip, __server_port);
  13. const char *s = "hello world\r\n";
  14. char buf[8192];
  15. int i, ret;
  16. if (cfd == INVALID_SOCKET) {
  17. return;
  18. }
  19. for (i = 0; i < 1024; i++) {
  20. #ifdef _WIN32
  21. if (acl_fiber_send(cfd, s, strlen(s), 0) <= 0) {
  22. #else
  23. if (send(cfd, s, strlen(s), 0) <= 0) {
  24. #endif
  25. printf("send error %s\r\n", acl_fiber_last_serror());
  26. break;
  27. }
  28. #ifdef _WIN32
  29. ret = acl_fiber_recv(cfd, buf, sizeof(buf), 0);
  30. #else
  31. ret = recv(cfd, buf, sizeof(buf), 0);
  32. #endif
  33. if (ret <= 0) {
  34. break;
  35. }
  36. }
  37. #ifdef _WIN32
  38. acl_fiber_close(cfd);
  39. #else
  40. close(cfd);
  41. #endif
  42. }
  43. int main(void) {
  44. int event_mode = FIBER_EVENT_KERNEL;
  45. size_t stack_size = 128000;
  46. int i;
  47. #ifdef _WIN32
  48. socket_init();
  49. #endif
  50. for (i = 0; i < 100; i++) {
  51. acl_fiber_create(fiber_client, NULL, stack_size);
  52. }
  53. acl_fiber_schedule_with(event_mode);
  54. #ifdef _WIN32
  55. socket_end();
  56. #endif
  57. return 0;
  58. }

3.3 Resolve domain address in coroutine

The rfc1035 for DNS has been implement in libfiber, so you can call gethostbyname or getaddrinfo to get the givent domain’s IP addresses in coroutine.

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <netdb.h>
  5. #include "fiber/lib_fiber.h"
  6. static void lookup(ACL_FIBER *fiber, void *ctx) {
  7. char *name = (char *) ctx;
  8. struct addrinfo hints, *res0;
  9. int ret;
  10. (void) fiber; // avoid compiler warning
  11. memset(&hints, 0, sizeof(hints));
  12. hints.ai_family = PF_UNSPEC;
  13. hints.ai_socktype = SOCK_STREAM;
  14. hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG;
  15. ret = getaddrinfo(name, "80", &hints, &res0);
  16. free(name);
  17. if (ret != 0) {
  18. printf("getaddrinfo error %s\r\n", gai_strerror(ret));
  19. } else {
  20. printf("getaddrinfo ok\r\n");
  21. freeaddrinfo(res0);
  22. }
  23. }
  24. int main(void) {
  25. char *name1 = strdup("www.iqiyi.com");
  26. char *name2 = strdup("www.baidu.com");
  27. acl_fiber_create(lookup, name1, 128000);
  28. acl_fiber_create(lookup, name2, 128000);
  29. acl_fiber_schedule();
  30. return 0;
  31. }

3.4 Create fiber with standard C++ API

You can create one coroutine with standard C++ API in libfiber:

  1. #include <cstdio>
  2. #include "fiber/libfiber.hpp"
  3. class myfiber : public acl::fiber {
  4. public:
  5. myfiber() {}
  6. private:
  7. ~myfiber() {}
  8. protected:
  9. // @override from acl::fiber
  10. void run() {
  11. printf("hello world!\r\n");
  12. delete this;
  13. }
  14. };
  15. int main() {
  16. for (int i = 0; i < 10; i++) {
  17. acl::fiber* fb = new myfiber();
  18. fb->start();
  19. }
  20. acl::fiber::schedule();
  21. return 0;
  22. }

3.5 Create fiber with C++1x API

You can also create one coroutine with c++11 API in libfiber:

  1. #include <cstdio>
  2. #include "fiber/libfiber.hpp"
  3. #include "fiber/go_fiber.hpp"
  4. static void fiber_routine(int i) {
  5. printf("hi, i=%d, curr fiber=%u\r\n", i, acl::fiber::self());
  6. }
  7. int main() {
  8. for (int i = 0; i < 10; i++) {
  9. go[=] {
  10. fiber_routine(i);
  11. };
  12. }
  13. acl::fiber::schedule();
  14. return 0;
  15. }

3.6 Create shared stack fiber

You can create fiber in shared stack mode to decrease the memory’s size.

  1. #include <cstdio>
  2. #include <cstdlib>
  3. #include <memory>
  4. #include "fiber/go_fiber.hpp"
  5. void test_shared_stack() {
  6. std::shared_ptr<int> count(new int);
  7. for (int i = 0; i < 10; i++) {
  8. go_share(1024)[count] {
  9. (*count)++;
  10. };
  11. }
  12. acl::fiber::schedule();
  13. printf("At last the count is %d\r\n", *count);
  14. }

3.7 Sync between fibers and threads

fiber_mutex can be used to sync between different fibers and threads:

  1. #include <thread>
  2. #include "fiber/go_fiber.hpp"
  3. #include "fiber/fiber_mutex.hpp"
  4. void test_mutex() {
  5. // Create one fiber mutex can be shared between different fibers and threads.
  6. std::shared_ptr<acl::fiber_mutex> mutex(new acl::fiber_mutex);
  7. // Create one fiber to use fiber mutex.
  8. go[mutex] {
  9. mutex->lock();
  10. ::sleep(1);
  11. mutex->unlock();
  12. };
  13. // Create one thread to use fiber mutex.
  14. std::thread([mutex] {
  15. mutex->lock();
  16. ::sleep(1);
  17. mutex->unlock();
  18. }).detach();
  19. // Create one thread and one fiber in it to use fiber mutex.
  20. std::thread([mutex] {
  21. go[mutex] {
  22. mutex->lock();
  23. ::sleep(1);
  24. mutex->unlock();
  25. };
  26. acl::fiber::schedule();
  27. }).detach();
  28. // Start the current thread's schedule.
  29. acl::fiber::schedule();
  30. }

3.8 Transfer objects through box

You can use fiber_tbox or fiber_tbox2 to transfer objs between different fibers and threads:

  1. #include <memory>
  2. #include <thread>
  3. #include "fiber/fiber_tbox.hpp"
  4. class myobj {
  5. public:
  6. myobj() = default;
  7. ~myobj() = default;
  8. void run() { printf("hello world!\r\n"); }
  9. };
  10. void test_tbox() {
  11. std::shared_ptr<acl::fiber_tbox<myobj>> box(new acl::fiber_tbox<myobj>);
  12. go[box] {
  13. myobj *o = box->pop();
  14. o->run();
  15. delete o;
  16. };
  17. go[box] {
  18. myobj *o = new myobj;
  19. box->push(o);
  20. };
  21. go[box] {
  22. myobj *o = box->pop();
  23. o->run();
  24. delete o;
  25. };
  26. std::thread thread([box] {
  27. myobj *o = new myobj;
  28. box->push(o);
  29. });
  30. thread.detach();
  31. }

3.9 Using wait_group to wait for the others done

You can use wait_group to wait for the other tasks:

  1. #include "fiber/go_fiber.hpp"
  2. #include "fiber/wait_group.hpp"
  3. void wait_others() {
  4. acl::wait_group wg;
  5. wg.add(2);
  6. std::thread thr([&wg]{
  7. ::sleep(1);
  8. wg.done();
  9. });
  10. thr.detach();
  11. go[&wg] {
  12. ::sleep(1);
  13. wg.done();
  14. };
  15. wg.wait();
  16. }

3.10 Using fiber_pool to execute different tasks

You can use fiber_pool to run multiple tasks with high performance:

  1. #include <cstdio>
  2. #include <cstdlib>
  3. #include <acl-lib/acl_cpp/lib_acl.hpp>
  4. #include <acl-lib/fiber/libfiber.hpp>
  5. static void mytest(acl::wait_group& sync, int i) {
  6. printf("Task %d is running\n", i);
  7. sync.done();
  8. }
  9. int main() {
  10. // Create one fiber pool with min=1, max=20, idle=30s, buf=500, stack=64000.
  11. acl::fiber_pool pool(1, 20, 30, 500, 64000, false);
  12. acl::wait_group sync;
  13. int i = 0;
  14. sync.add(1);
  15. // Run the first task.
  16. pool.exec([&sync, i]() {
  17. printf("Task %d is running\n", i);
  18. sync.done();
  19. });
  20. i++;
  21. sync.add(1);
  22. // Run the second task.
  23. pool.exec([&sync](int i) {
  24. printf("Task %d is running\n", i);
  25. sync.done();
  26. }, i);
  27. i++;
  28. sync.add(1);
  29. // Run the third task.
  30. pool.exec(mytest, std::ref(sync), i);
  31. // Create one fiber to wait for all tasks done and stop the fiber pool.
  32. go[&sync, &pool] {
  33. sync.wait();
  34. pool.stop();
  35. };
  36. acl::fiber::schedule();
  37. return 0;
  38. }

3.11 Wait for the result from a thread

  1. #include <cstdio>
  2. #include <unistd.h>
  3. #include "fiber/go_fiber.hpp"
  4. static void fiber_routine(int i) {
  5. go_wait[&] { // running in another thread
  6. i += 100;
  7. ::usleep(10000);
  8. };
  9. printf("i is %d\r\n", i);
  10. }
  11. int main() {
  12. // create ten fibers
  13. for (int i = 0; i < 10; i++) {
  14. go[=] {
  15. fiber_routine(i);
  16. };
  17. }
  18. acl::fiber::schedule();
  19. return 0;
  20. }

3.12 Http server supporting http url route

One http server written with libfiber and http module of acl supports http handler route which is in http server.

  1. #include <acl-lib/acl_cpp/lib_acl.hpp> // must before http_server.hpp
  2. #include <acl-lib/fiber/http_server.hpp>
  3. static char *var_cfg_debug_msg;
  4. static acl::master_str_tbl var_conf_str_tab[] = {
  5. { "debug_msg", "test_msg", &var_cfg_debug_msg },
  6. { 0, 0, 0 }
  7. };
  8. static int var_cfg_io_timeout;
  9. static acl::master_int_tbl var_conf_int_tab[] = {
  10. { "io_timeout", 120, &var_cfg_io_timeout, 0, 0 },
  11. { 0, 0 , 0 , 0, 0 }
  12. };
  13. int main(d) {
  14. acl::acl_cpp_init();
  15. acl::http_server server;
  16. // set the configure variables
  17. server.set_cfg_int(var_conf_int_tab)
  18. .set_cfg_str(var_conf_str_tab);
  19. // set http handler route
  20. server.Get("/", [](acl::HttpRequest&, acl::HttpResponse& res) {
  21. acl::string buf("hello world1!\r\n");
  22. res.setContentLength(buf.size());
  23. return res.write(buf.c_str(), buf.size());
  24. }).Post("/ok", [](acl::HttpRequest& req, acl::HttpResponse& res) {
  25. acl::string buf;
  26. req.getBody(buf);
  27. res.setContentLength(buf.size());
  28. return res.write(buf.c_str(), buf.size());
  29. }).Get("/json", [&](acl::HttpRequest&, acl::HttpResponse& res) {
  30. acl::json json;
  31. acl::json_node& root = json.get_root();
  32. root.add_number("code", 200)
  33. .add_text("status", "+ok")
  34. .add_child("data",
  35. json.create_node()
  36. .add_text("name", "value")
  37. .add_bool("success", true)
  38. .add_number("number", 200));
  39. return res.write(json);
  40. });
  41. // start the server in alone mode
  42. server.run_alone("0.0.0.0|8194, 127.0.0.1|8195", "./httpd.cf");
  43. return 0;
  44. }

3.13 Windows GUI sample

There is one Windows GUI sample with libfiber in directory. The screenshot is here

The server coroutine and client coroutine are all running in the same thread as the GUI, so you can operate the GUI object in server and client coroutine without worrying about the memory collision problem. And you can write network process with sequence way, other than asynchronus callback way which is so horrible. With the libfirber for Windows GUI, the asynchronous API like CAsyncSocket should be discarded. The network APIs are intergrated with the Windows GUI seamlessly because the libfiber using GUI message pump as event driven internal.

3.14 More SAMPLES

You can get more samples in samples, which use many APIs in acl project library.

4 BUILDING

4.1 On Unix

  1. $cd libfiber
  2. $make
  3. $cd samples
  4. $make

The simple Makefile shown below:

  1. fiber_server: fiber_server.c
  2. gcc -o fiber_server fiber_server.c patch.c -I{path_of_fiber_header} -L{path_of_fiber_lib) -lfiber -ldl -lpthread
  3. fiber_client: fiber_client.c
  4. gcc -o fiber_client fiber_client.c patch.c -I{path_of_fiber_header} -L{path_of_fiber_lib) -lfiber -ldl -lpthread

4.2 On Windows

You can open the fiber_vc2012.sln/ fiber_vc2013.sln/c/fiber_vc2015.sln with vc2019, and build the libfiber library and the samples included.

5 Benchmark

The picture below show the IOPS (io echo per-second) benchmark written by libfiber, comparing with the samples writen by libmill, golang and libco. The samples written by libmill and libco are in directory, the sample written by golang is in here, and the sample written by libfiber is in server sample directory. The testing client is in here from the acl project.

Benchmark

6 API support

6.1 Base API

  • acl_fiber_create
  • acl_fiber_self
  • acl_fiber_status
  • acl_fiber_kill
  • acl_fiber_killed
  • acl_fiber_signal
  • acl_fiber_yield
  • acl_fiber_ready
  • acl_fiber_switch
  • acl_fiber_schedule_init
  • acl_fiber_schedule
  • acl_fiber_schedule_with
  • acl_fiber_scheduled
  • acl_fiber_schedule_stop
  • acl_fiber_set_specific
  • acl_fiber_get_specific
  • acl_fiber_delay
  • acl_fiber_last_error
  • acl_fiber_last_serror

6.2 IO API

  • acl_fiber_recv
  • acl_fiber_recvfrom
  • acl_fiber_read
  • acl_fiber_readv
  • acl_fiber_recvmsg
  • acl_fiber_write
  • acl_fiber_writev
  • acl_fiber_send
  • acl_fiber_sendto
  • acl_fiber_sendmsg
  • acl_fiber_select
  • acl_fiber_poll
  • acl_fiber_close

6.3 Net API

  • acl_fiber_socket
  • acl_fiber_listen
  • acl_fiber_accept
  • acl_fiber_connect
  • acl_fiber_gethostbyname_r
  • acl_fiber_getaddrinfo
  • acl_fiber_freeaddrinfo

6.4 Channel API

  • acl_channel_create
  • acl_channel_free
  • acl_channel_send
  • acl_channel_send_nb
  • acl_channel_recv
  • acl_channel_recv_nb
  • acl_channel_sendp
  • acl_channel_recvp
  • acl_channel_sendp_nb
  • acl_channel_recvp_nb
  • acl_channel_sendul
  • acl_channel_recvul
  • acl_channel_sendul_nb
  • acl_channel_recvul_nb

6.5 Sync API

ACL_FIBER_MUTEX

  • acl_fiber_mutex_create
  • acl_fiber_mutex_free
  • acl_fiber_mutex_lock
  • acl_fiber_mutex_trylock
  • acl_fiber_mutex_unlock

ACL_FIBER_RWLOCK

  • acl_fiber_rwlock_create
  • acl_fiber_rwlock_free
  • acl_fiber_rwlock_rlock
  • acl_fiber_rwlock_tryrlock
  • acl_fiber_rwlock_wlock
  • acl_fiber_rwlock_trywlock
  • acl_fiber_rwlock_runlock
  • acl_fiber_rwlock_wunlock

ACL_FIBER_EVENT

  • acl_fiber_event_create
  • acl_fiber_event_free
  • acl_fiber_event_wait
  • acl_fiber_event_trywait
  • acl_fiber_event_notify

ACL_FIBER_SEM

  • acl_fiber_sem_create
  • acl_fiber_sem_free
  • acl_fiber_sem_wait
  • acl_fiber_sem_post
  • acl_fiber_sem_num

7 About API Hook

On Linux/BSD/Mac, many IO and Net APIs are hooked. So you can just use the System standard APIs in your applications with libfiber, the hooked APIs will be replaced with libfiber APIs. In this case, you can coroutine your DB application with mysql driven and change nothing in mysql driven.
The standard APIs been hooked are shown below:

  • close
  • sleep
  • read
  • readv
  • recv
  • recvfrom
  • recvmsg
  • write
  • writev
  • send
  • sendto
  • sendmsg
  • sendfile64
  • socket
  • listen
  • accept
  • connect
  • select
  • poll
  • epoll: epoll_create, epoll_ctl, epoll_wait
  • gethostbyname(_r)
  • getaddrinfo/freeaddrinfo

8 FAQ

  1. Is the coroutine schedule in multi-threads?
    No. The coroutine schedule of libfiber is in one single thread. But you can start multiple threads that one thread has one schedule process.
  2. How are the multi-cores of CPU used?
    multiple threads can be started with its own coroutine schedule, each thread can ocpupy one CPU.
  3. How does different threads mutex in coroutine schedule status?
    Even though the OS system mutex APIs, such as pthread_mutex_t’s APIs can be used, the ACL_FIBER_EVENT’s APIs are recommended. It’s safety when the OS system mutex APIs are used in short time without recursive invocation. But its unsafely using system mutex APIs in this case: One coroutine A1 of thread A had locked the thread-mutex-A, the coroutine A2 of thread A wanted to lock the thread-mutex-B which had been locked by one coroutine B1 of thread B, when the coroutine B2 of thread B wanted to lock the thread-mutex-A, thread deadlock happened! So, the coroutine mutex for threads and coroutines named ACL_FIBER_EVENT’s APIs of libfiber were created, which can be used to make critical region between multiple coroutines in different threads(multiple continues in the same thread or not; it can also be used for different threads without coroutines).
  4. Should the mysql-driven source codes be changed when used with libfiber?
    In UNIX OS, the System IO APIs are hooked by libfiber, so nothing should be changed in mysql-driven.
  5. How to avoid make the mysqld overloaded when many coroutines started?
    The ACL_FIBER_SEM’s APIs can be used to protect the mysqld being overloaded by many connections of many coroutines. These APIs can limit the connections number to the mysqld from coroutines.
  6. Does the DNS domain resolving block the coroutine schedule?
    No, because the System domain-resolving APIs such as gethostbyname(_r) and getaddrinfo are also hooked in libfiber.