klishd.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. #define _GNU_SOURCE
  2. #include <stdlib.h>
  3. #include <stdint.h>
  4. #include <stdio.h>
  5. #include <string.h>
  6. #include <assert.h>
  7. #include <signal.h>
  8. #include <syslog.h>
  9. #include <unistd.h>
  10. #include <errno.h>
  11. #include <sys/types.h>
  12. #include <sys/stat.h>
  13. #include <fcntl.h>
  14. #include <sys/socket.h>
  15. #include <sys/un.h>
  16. #include <sys/fsuid.h>
  17. #include <sys/wait.h>
  18. #include <poll.h>
  19. #include <time.h>
  20. #include <faux/faux.h>
  21. #include <faux/str.h>
  22. #include <faux/argv.h>
  23. #include <faux/ini.h>
  24. #include <faux/log.h>
  25. #include <faux/sched.h>
  26. #include <faux/sysdb.h>
  27. #include <faux/net.h>
  28. #include <faux/list.h>
  29. #include <faux/conv.h>
  30. #include <faux/file.h>
  31. #include <faux/eloop.h>
  32. #include <faux/error.h>
  33. #include <klish/ktp.h>
  34. #include <klish/ktp_session.h>
  35. #include <klish/kscheme.h>
  36. #include <klish/ischeme.h>
  37. #include <klish/kcontext.h>
  38. #include <klish/ksession.h>
  39. #include <klish/kdb.h>
  40. #include <klish/kpargv.h>
  41. #include "private.h"
  42. // Local static functions
  43. static int create_listen_unix_sock(const char *path);
  44. static kscheme_t *load_all_dbs(const char *dbs,
  45. faux_ini_t *global_config, faux_error_t *error);
  46. static bool_t clear_scheme(kscheme_t *scheme, faux_error_t *error);
  47. // Main loop events
  48. static bool_t stop_loop_ev(faux_eloop_t *eloop, faux_eloop_type_e type,
  49. void *associated_data, void *user_data);
  50. static bool_t refresh_config_ev(faux_eloop_t *eloop, faux_eloop_type_e type,
  51. void *associated_data, void *user_data);
  52. static bool_t client_ev(faux_eloop_t *eloop, faux_eloop_type_e type,
  53. void *associated_data, void *user_data);
  54. static bool_t listen_socket_ev(faux_eloop_t *eloop, faux_eloop_type_e type,
  55. void *associated_data, void *user_data);
  56. static bool_t wait_for_child_ev(faux_eloop_t *eloop, faux_eloop_type_e type,
  57. void *associated_data, void *user_data);
  58. //static bool_t sched_once(faux_eloop_t *eloop, faux_eloop_type_e type,
  59. // void *associated_data, void *user_data);
  60. //static bool_t sched_periodic(faux_eloop_t *eloop, faux_eloop_type_e type,
  61. // void *associated_data, void *user_data);
  62. static bool_t fd_stall_cb(ktpd_session_t *session, void *user_data);
  63. /** @brief Main function
  64. */
  65. int main(int argc, char **argv)
  66. {
  67. int retval = -1;
  68. struct options *opts = NULL;
  69. int pidfd = -1;
  70. int logoptions = 0;
  71. faux_eloop_t *eloop = NULL;
  72. int listen_unix_sock = -1;
  73. ktpd_session_t *ktpd_session = NULL;
  74. kscheme_t *scheme = NULL;
  75. faux_error_t *error = faux_error_new();
  76. faux_ini_t *config = NULL;
  77. int client_fd = -1;
  78. // struct timespec delayed = { .tv_sec = 10, .tv_nsec = 0 };
  79. // struct timespec period = { .tv_sec = 3, .tv_nsec = 0 };
  80. // Parse command line options
  81. opts = opts_init();
  82. if (opts_parse(argc, argv, opts))
  83. goto err;
  84. // Initialize syslog
  85. logoptions = LOG_CONS;
  86. if (opts->foreground)
  87. logoptions |= LOG_PERROR;
  88. openlog(LOG_NAME, logoptions, opts->log_facility);
  89. if (!opts->verbose)
  90. setlogmask(LOG_UPTO(LOG_INFO));
  91. // Parse config file
  92. syslog(LOG_DEBUG, "Parse config file: %s\n", opts->cfgfile);
  93. if (!access(opts->cfgfile, R_OK)) {
  94. if (!(config = config_parse(opts->cfgfile, opts)))
  95. goto err;
  96. } else if (opts->cfgfile_userdefined) {
  97. // User defined config must be found
  98. fprintf(stderr, "Error: Can't find config file %s\n",
  99. opts->cfgfile);
  100. goto err;
  101. }
  102. // DEBUG: Show options
  103. opts_show(opts);
  104. syslog(LOG_INFO, "Start daemon.\n");
  105. // Fork the daemon
  106. if (!opts->foreground) {
  107. // Daemonize
  108. syslog(LOG_DEBUG, "Daemonize\n");
  109. if (daemon(0, 0) < 0) {
  110. syslog(LOG_ERR, "Can't daemonize\n");
  111. goto err;
  112. }
  113. // Write pidfile
  114. syslog(LOG_DEBUG, "Write PID file: %s\n", opts->pidfile);
  115. if ((pidfd = open(opts->pidfile,
  116. O_WRONLY | O_CREAT | O_EXCL | O_TRUNC,
  117. S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0) {
  118. syslog(LOG_WARNING, "Can't open pidfile %s: %s\n",
  119. opts->pidfile, strerror(errno));
  120. } else {
  121. char str[20];
  122. snprintf(str, sizeof(str), "%u\n", getpid());
  123. str[sizeof(str) - 1] = '\0';
  124. if (write(pidfd, str, strlen(str)) < 0)
  125. syslog(LOG_WARNING, "Can't write to %s: %s\n",
  126. opts->pidfile, strerror(errno));
  127. close(pidfd);
  128. }
  129. }
  130. // Load scheme
  131. if (!(scheme = load_all_dbs(opts->dbs, config, error))) {
  132. fprintf(stderr, "Scheme errors:\n");
  133. goto err;
  134. }
  135. // Listen socket
  136. syslog(LOG_DEBUG, "Create listen UNIX socket: %s\n", opts->unix_socket_path);
  137. listen_unix_sock = create_listen_unix_sock(opts->unix_socket_path);
  138. if (listen_unix_sock < 0)
  139. goto err;
  140. syslog(LOG_DEBUG, "Listen socket %d", listen_unix_sock);
  141. // Event loop
  142. eloop = faux_eloop_new(NULL);
  143. // Signals
  144. faux_eloop_add_signal(eloop, SIGINT, stop_loop_ev, NULL);
  145. faux_eloop_add_signal(eloop, SIGTERM, stop_loop_ev, NULL);
  146. faux_eloop_add_signal(eloop, SIGQUIT, stop_loop_ev, NULL);
  147. faux_eloop_add_signal(eloop, SIGHUP, refresh_config_ev, opts);
  148. faux_eloop_add_signal(eloop, SIGCHLD, wait_for_child_ev, NULL);
  149. // Listen socket. Waiting for new connections
  150. faux_eloop_add_fd(eloop, listen_unix_sock, POLLIN,
  151. listen_socket_ev, &client_fd);
  152. // Scheduled events
  153. // faux_eloop_add_sched_once_delayed(eloop, &delayed, 1, sched_once, NULL);
  154. // faux_eloop_add_sched_periodic_delayed(eloop, 2, sched_periodic, NULL, &period, FAUX_SCHED_INFINITE);
  155. // Main loop
  156. faux_eloop_loop(eloop);
  157. faux_eloop_free(eloop);
  158. retval = 0;
  159. err:
  160. // Print errors
  161. if (faux_error_len(error) > 0)
  162. faux_error_show(error);
  163. faux_error_free(error);
  164. // Close listen socket
  165. if (listen_unix_sock >= 0)
  166. close(listen_unix_sock);
  167. // Finish listen daemon if it's not forked service process.
  168. if (client_fd < 0) {
  169. // Free scheme
  170. clear_scheme(scheme, error);
  171. // Free command line options
  172. opts_free(opts);
  173. faux_ini_free(config);
  174. // Remove pidfile
  175. if (pidfd >= 0) {
  176. if (unlink(opts->pidfile) < 0) {
  177. syslog(LOG_ERR, "Can't remove pid-file %s: %s\n",
  178. opts->pidfile, strerror(errno));
  179. }
  180. }
  181. syslog(LOG_INFO, "Stop daemon.\n");
  182. return retval;
  183. }
  184. // ATTENTION: It's a forked service process
  185. retval = -1; // Pessimism for service process
  186. // Re-Initialize syslog
  187. openlog(LOG_SERVICE_NAME, logoptions, opts->log_facility);
  188. if (!opts->verbose)
  189. setlogmask(LOG_UPTO(LOG_INFO));
  190. ktpd_session = ktpd_session_new(client_fd, scheme, NULL);
  191. assert(ktpd_session);
  192. if (!ktpd_session) {
  193. syslog(LOG_ERR, "Can't create KTPd session\n");
  194. close(client_fd);
  195. goto err_client;
  196. }
  197. // ktpd_session_set_stall_cb(ktpd_session, fd_stall_cb, eloop);
  198. // faux_eloop_add_fd(eloop, new_conn, POLLIN, client_ev, clients);
  199. syslog(LOG_DEBUG, "New connection %d\n", client_fd);
  200. // Event loop
  201. eloop = faux_eloop_new(NULL);
  202. // Signals
  203. faux_eloop_add_signal(eloop, SIGINT, stop_loop_ev, NULL);
  204. faux_eloop_add_signal(eloop, SIGTERM, stop_loop_ev, NULL);
  205. faux_eloop_add_signal(eloop, SIGQUIT, stop_loop_ev, NULL);
  206. // FDs
  207. ktpd_session_set_stall_cb(ktpd_session, fd_stall_cb, eloop);
  208. faux_eloop_add_fd(eloop, client_fd, POLLIN, client_ev, ktpd_session);
  209. // Main service loop
  210. faux_eloop_loop(eloop);
  211. faux_eloop_free(eloop);
  212. retval = 0;
  213. err_client:
  214. ktpd_session_free(ktpd_session);
  215. // Free scheme
  216. clear_scheme(scheme, error);
  217. // Free command line options
  218. opts_free(opts);
  219. faux_ini_free(config);
  220. return retval;
  221. }
  222. static bool_t load_db(kscheme_t *scheme, const char *db_name,
  223. faux_ini_t *config, faux_error_t *error)
  224. {
  225. kdb_t *db = NULL;
  226. const char *sofile = NULL;
  227. assert(scheme);
  228. if (!scheme)
  229. return BOOL_FALSE;
  230. assert(db_name);
  231. if (!db_name)
  232. return BOOL_FALSE;
  233. // DB.libxml2.so = <so filename>
  234. if (config)
  235. sofile = faux_ini_find(config, "so");
  236. db = kdb_new(db_name, sofile);
  237. assert(db);
  238. if (!db)
  239. return BOOL_FALSE;
  240. kdb_set_ini(db, config);
  241. kdb_set_error(db, error);
  242. // Load DB plugin
  243. if (!kdb_load_plugin(db)) {
  244. faux_error_sprintf(error,
  245. "DB \"%s\": Can't load DB plugin", db_name);
  246. kdb_free(db);
  247. return BOOL_FALSE;
  248. }
  249. // Check plugin API version
  250. if ((kdb_major(db) != KDB_MAJOR) ||
  251. (kdb_minor(db) != KDB_MINOR)) {
  252. faux_error_sprintf(error,
  253. "DB \"%s\": Plugin's API version is %u.%u, need %u.%u",
  254. db_name,
  255. kdb_major(db), kdb_minor(db),
  256. KDB_MAJOR, KDB_MINOR);
  257. kdb_free(db);
  258. return BOOL_FALSE;
  259. }
  260. // Init plugin
  261. if (kdb_has_init_fn(db) && !kdb_init(db)) {
  262. faux_error_sprintf(error,
  263. "DB \"%s\": Can't init DB plugin", db_name);
  264. kdb_free(db);
  265. return BOOL_FALSE;
  266. }
  267. // Load scheme
  268. if (!kdb_has_load_fn(db) || !kdb_load_scheme(db, scheme)) {
  269. faux_error_sprintf(error,
  270. "DB \"%s\": Can't load scheme from DB plugin", db_name);
  271. kdb_fini(db);
  272. kdb_free(db);
  273. return BOOL_FALSE;
  274. }
  275. // Fini plugin
  276. if (kdb_has_fini_fn(db) && !kdb_fini(db)) {
  277. faux_error_sprintf(error,
  278. "DB \"%s\": Can't fini DB plugin", db_name);
  279. kdb_free(db);
  280. return BOOL_FALSE;
  281. }
  282. kdb_free(db);
  283. return BOOL_TRUE;
  284. }
  285. static kscheme_t *load_all_dbs(const char *dbs,
  286. faux_ini_t *global_config, faux_error_t *error)
  287. {
  288. kscheme_t *scheme = NULL;
  289. faux_argv_t *dbs_argv = NULL;
  290. faux_argv_node_t *iter = NULL;
  291. const char *db_name = NULL;
  292. bool_t retcode = BOOL_TRUE;
  293. kcontext_t *context = NULL;
  294. assert(dbs);
  295. if (!dbs)
  296. return NULL;
  297. scheme = kscheme_new();
  298. assert(scheme);
  299. if (!scheme)
  300. return NULL;
  301. dbs_argv = faux_argv_new();
  302. assert(dbs_argv);
  303. if (!dbs_argv) {
  304. kscheme_free(scheme);
  305. return NULL;
  306. }
  307. if (faux_argv_parse(dbs_argv, dbs) <= 0) {
  308. kscheme_free(scheme);
  309. faux_argv_free(dbs_argv);
  310. return NULL;
  311. }
  312. // For each DB
  313. iter = faux_argv_iter(dbs_argv);
  314. while ((db_name = faux_argv_each(&iter))) {
  315. faux_ini_t *config = NULL; // Sub-config for current DB
  316. char *prefix = NULL;
  317. prefix = faux_str_mcat(&prefix, "DB.", db_name, ".", NULL);
  318. if (config)
  319. config = faux_ini_extract_subini(global_config, prefix);
  320. if (!load_db(scheme, db_name, config, error))
  321. retcode = BOOL_FALSE;
  322. faux_ini_free(config);
  323. faux_str_free(prefix);
  324. }
  325. faux_argv_free(dbs_argv);
  326. // Something went wrong while loading DBs
  327. if (!retcode) {
  328. kscheme_free(scheme);
  329. return NULL;
  330. }
  331. // Prepare scheme
  332. context = kcontext_new(KCONTEXT_PLUGIN_INIT);
  333. retcode = kscheme_prepare(scheme, context, error);
  334. kcontext_free(context);
  335. if (!retcode) {
  336. kscheme_free(scheme);
  337. faux_error_sprintf(error, "Scheme preparing errors.\n");
  338. return NULL;
  339. }
  340. /*
  341. // Debug
  342. {
  343. kdb_t *deploy_db = NULL;
  344. // Deploy (for testing purposes)
  345. deploy_db = kdb_new("ischeme", NULL);
  346. kdb_load_plugin(deploy_db);
  347. kdb_init(deploy_db);
  348. kdb_deploy_scheme(deploy_db, scheme);
  349. kdb_fini(deploy_db);
  350. kdb_free(deploy_db);
  351. }
  352. */
  353. return scheme;
  354. }
  355. static bool_t clear_scheme(kscheme_t *scheme, faux_error_t *error)
  356. {
  357. kcontext_t *context = NULL;
  358. if (!scheme)
  359. return BOOL_TRUE; // It's not an error
  360. context = kcontext_new(KCONTEXT_PLUGIN_FINI);
  361. kscheme_fini(scheme, context, error);
  362. kcontext_free(context);
  363. kscheme_free(scheme);
  364. return BOOL_TRUE;
  365. }
  366. /** @brief Create listen socket
  367. *
  368. * Previously removes old socket's file from filesystem. Note daemon must check
  369. * for already working daemon to don't duplicate.
  370. *
  371. * @param [in] path Socket path within filesystem.
  372. * @return Socket descriptor of < 0 on error.
  373. */
  374. static int create_listen_unix_sock(const char *path)
  375. {
  376. int sock = -1;
  377. int opt = 1;
  378. struct sockaddr_un laddr = {};
  379. assert(path);
  380. if (!path)
  381. return -1;
  382. if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
  383. syslog(LOG_ERR, "Can't create socket: %s\n", strerror(errno));
  384. goto err;
  385. }
  386. if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt))) {
  387. syslog(LOG_ERR, "Can't set socket options: %s\n", strerror(errno));
  388. goto err;
  389. }
  390. // Remove old (lost) socket's file
  391. unlink(path);
  392. laddr.sun_family = AF_UNIX;
  393. strncpy(laddr.sun_path, path, USOCK_PATH_MAX);
  394. laddr.sun_path[USOCK_PATH_MAX - 1] = '\0';
  395. if (bind(sock, (struct sockaddr *)&laddr, sizeof(laddr))) {
  396. syslog(LOG_ERR, "Can't bind socket %s: %s\n", path, strerror(errno));
  397. goto err;
  398. }
  399. if (listen(sock, 128)) {
  400. unlink(path);
  401. syslog(LOG_ERR, "Can't listen on socket %s: %s\n", path, strerror(errno));
  402. goto err;
  403. }
  404. return sock;
  405. err:
  406. if (sock >= 0)
  407. close(sock);
  408. return -1;
  409. }
  410. /** @brief Stop main event loop.
  411. */
  412. static bool_t stop_loop_ev(faux_eloop_t *eloop, faux_eloop_type_e type,
  413. void *associated_data, void *user_data)
  414. {
  415. // Happy compiler
  416. eloop = eloop;
  417. type = type;
  418. associated_data = associated_data;
  419. user_data = user_data;
  420. return BOOL_FALSE; // Stop Event Loop
  421. }
  422. /** @brief Wait for child processes (service processes).
  423. */
  424. static bool_t wait_for_child_ev(faux_eloop_t *eloop, faux_eloop_type_e type,
  425. void *associated_data, void *user_data)
  426. {
  427. int wstatus = 0;
  428. pid_t child_pid = -1;
  429. // Wait for any child process. Doesn't block.
  430. while ((child_pid = waitpid(-1, &wstatus, WNOHANG)) > 0) {
  431. if (WIFSIGNALED(wstatus)) {
  432. syslog(LOG_ERR, "Service process %d was terminated "
  433. "by signal: %d",
  434. child_pid, WTERMSIG(wstatus));
  435. } else {
  436. syslog(LOG_ERR, "Service process %d was terminated: %d",
  437. child_pid, WEXITSTATUS(wstatus));
  438. }
  439. }
  440. // Happy compiler
  441. eloop = eloop;
  442. type = type;
  443. associated_data = associated_data;
  444. user_data = user_data;
  445. return BOOL_TRUE;
  446. }
  447. /** @brief Re-read config file.
  448. *
  449. * This function can refresh klishd options but plugins (dbs for example) are
  450. * already inited and there is no way to re-init them on-the-fly.
  451. */
  452. static bool_t refresh_config_ev(faux_eloop_t *eloop, faux_eloop_type_e type,
  453. void *associated_data, void *user_data)
  454. {
  455. struct options *opts = (struct options *)user_data;
  456. faux_ini_t *ini = NULL;
  457. if (access(opts->cfgfile, R_OK) == 0) {
  458. syslog(LOG_DEBUG, "Re-reading config file \"%s\"\n", opts->cfgfile);
  459. if (!(ini = config_parse(opts->cfgfile, opts)))
  460. syslog(LOG_ERR, "Error while config file parsing.\n");
  461. } else if (opts->cfgfile_userdefined) {
  462. syslog(LOG_ERR, "Can't find config file \"%s\"\n", opts->cfgfile);
  463. }
  464. faux_ini_free(ini); // No way to use it later
  465. // Happy compiler
  466. eloop = eloop;
  467. type = type;
  468. associated_data = associated_data;
  469. return BOOL_TRUE;
  470. }
  471. static bool_t fd_stall_cb(ktpd_session_t *session, void *user_data)
  472. {
  473. faux_eloop_t *eloop = (faux_eloop_t *)user_data;
  474. assert(session);
  475. assert(eloop);
  476. faux_eloop_include_fd_event(eloop, ktpd_session_fd(session), POLLOUT);
  477. return BOOL_TRUE;
  478. }
  479. /** @brief Event on listen socket. New remote client.
  480. */
  481. static bool_t listen_socket_ev(faux_eloop_t *eloop, faux_eloop_type_e type,
  482. void *associated_data, void *user_data)
  483. {
  484. int new_conn = -1;
  485. faux_eloop_info_fd_t *info = (faux_eloop_info_fd_t *)associated_data;
  486. pid_t child_pid = -1;
  487. assert(user_data);
  488. new_conn = accept(info->fd, NULL, NULL);
  489. if (new_conn < 0) {
  490. syslog(LOG_ERR, "Can't accept() new connection");
  491. return BOOL_TRUE;
  492. }
  493. // Fork new instance for newly connected client
  494. child_pid = fork();
  495. if (child_pid < 0) {
  496. close(new_conn);
  497. syslog(LOG_ERR, "Can't fork service process for client");
  498. return BOOL_TRUE;
  499. }
  500. // Parent
  501. if (child_pid > 0) {
  502. close(new_conn); // It's needed by child but not for parent
  503. syslog(LOG_ERR, "Service process for client was forked: %d",
  504. child_pid);
  505. return BOOL_TRUE;
  506. }
  507. // Child (forked service process)
  508. // Pass new ktpd_session to main programm
  509. *((int *)user_data) = new_conn;
  510. type = type; // Happy compiler
  511. eloop = eloop;
  512. // Return BOOL_FALSE to break listen parent loop. Child will create its
  513. // own loop then.
  514. return BOOL_FALSE;
  515. }
  516. static bool_t client_ev(faux_eloop_t *eloop, faux_eloop_type_e type,
  517. void *associated_data, void *user_data)
  518. {
  519. faux_eloop_info_fd_t *info = (faux_eloop_info_fd_t *)associated_data;
  520. ktpd_session_t *ktpd_session = (ktpd_session_t *)user_data;
  521. assert(ktpd_session);
  522. // Write data
  523. if (info->revents & POLLOUT) {
  524. faux_eloop_exclude_fd_event(eloop, info->fd, POLLOUT);
  525. if (!ktpd_session_async_out(ktpd_session)) {
  526. // Someting went wrong
  527. faux_eloop_del_fd(eloop, info->fd);
  528. syslog(LOG_ERR, "Problem with async output");
  529. }
  530. }
  531. // Read data
  532. if (info->revents & POLLIN) {
  533. if (!ktpd_session_async_in(ktpd_session)) {
  534. // Someting went wrong
  535. faux_eloop_del_fd(eloop, info->fd);
  536. syslog(LOG_ERR, "Problem with async input");
  537. }
  538. }
  539. // EOF
  540. if (info->revents & POLLHUP) {
  541. faux_eloop_del_fd(eloop, info->fd);
  542. syslog(LOG_DEBUG, "Close connection %d", info->fd);
  543. return BOOL_FALSE; // Stop event loop
  544. }
  545. type = type; // Happy compiler
  546. return BOOL_TRUE;
  547. }
  548. /*
  549. static bool_t sched_once(faux_eloop_t *eloop, faux_eloop_type_e type,
  550. void *associated_data, void *user_data)
  551. {
  552. faux_eloop_info_sched_t *info = (faux_eloop_info_sched_t *)associated_data;
  553. printf("Once %d\n", info->ev_id);
  554. // Happy compiler
  555. eloop = eloop;
  556. type = type;
  557. associated_data = associated_data;
  558. user_data = user_data;
  559. return BOOL_TRUE;
  560. }
  561. */
  562. /*
  563. static bool_t sched_periodic(faux_eloop_t *eloop, faux_eloop_type_e type,
  564. void *associated_data, void *user_data)
  565. {
  566. faux_eloop_info_sched_t *info = (faux_eloop_info_sched_t *)associated_data;
  567. printf("Periodic %d\n", info->ev_id);
  568. // Happy compiler
  569. eloop = eloop;
  570. type = type;
  571. associated_data = associated_data;
  572. user_data = user_data;
  573. return BOOL_TRUE;
  574. }
  575. */