klishd.c 16 KB

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