sys_request_client.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. /**
  2. * @file sys_request_client.c
  3. * @author Ambroz Bizjak <ambrop7@gmail.com>
  4. *
  5. * @section LICENSE
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. Neither the name of the author nor the
  15. * names of its contributors may be used to endorse or promote products
  16. * derived from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  22. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *
  29. * @section DESCRIPTION
  30. *
  31. * Synopsis:
  32. * sys.request_client(string connect_addr)
  33. *
  34. * Description:
  35. * Connects to a request server (sys.request_server()).
  36. * Goes up when the connection, and dies with error when it is broken.
  37. * When requested to die, dies immediately, breaking the connection.
  38. *
  39. * The connect address should be in the same format as for the socket module.
  40. * In particular, it must be in one of the following forms:
  41. * - {"tcp", {"ipv4", ipv4_address, port_number}},
  42. * - {"tcp", {"ipv6", ipv6_address, port_number}},
  43. * - {"unix", socket_path}.
  44. *
  45. * Synopsis:
  46. * sys.request_client::request(request_data, string reply_handler, string finished_handler, list args)
  47. *
  48. * Description:
  49. * Sends a request to the server and dispatches replies to the provided handlers.
  50. *
  51. * The 'request_data' argument is sent as part of the request and is used by the server
  52. * to determine what to do with the request.
  53. *
  54. * When a reply is received, a new template process is created from 'reply_handler' to process the
  55. * reply. This process can access the reply data sent by the server using '_reply.data'.
  56. * Similarly, if the server finishes the request, a process is created from 'finished_handler'.
  57. * In both cases, the process can access objects as seen from the request statement via "_caller".
  58. * Termination of these processes is initiated immediately after they completes. They are created
  59. * synchronously - if a reply or a finished message arrives before a previous process is has
  60. * finished, it is queued. Once the finished message has been processed by 'finished_handler', no
  61. * more processes will be created.
  62. *
  63. * When the request statement is requested to terminate, it initiates termination of the current
  64. * handler process and waits for it to terminate (if any is running), and then dies.
  65. * If the corresponding client statement dies after being requested to die, or as a result of
  66. * an error, the request statement will not react to this. It will dispatch any pending messages
  67. * and then proceed to do nothing. In this case, if a finished message was not received, it will
  68. * not be dispatched.
  69. *
  70. * The request statement may however die at any time due to errors. In this case, it will
  71. * initiate termination of the current process and wait for it to terminate (if any) before dying.
  72. *
  73. * The request protocol and the server allow the client the abort requests at any time, and to
  74. * have the client notified only after the request has been completely aborted (i.e. the handler
  75. * process of sys.request_server() has deinitialized completely). This client implementation will
  76. * automatically request abortion of active requests when the request statement is requested
  77. * to die. However, the request statement will not wait for the abortion to finish before dying.
  78. * This means, for instance, that if you initialize a request statement right after having
  79. * deinitiazed it, the requests may overlap on the server side.
  80. */
  81. #include <stdlib.h>
  82. #include <string.h>
  83. #include <inttypes.h>
  84. #include <limits.h>
  85. #include <misc/offset.h>
  86. #include <structure/LinkedList0.h>
  87. #include <structure/LinkedList1.h>
  88. #include <ncd/extra/NCDRequestClient.h>
  89. #include <ncd/extra/address_utils.h>
  90. #include <ncd/module_common.h>
  91. #include <generated/blog_channel_ncd_sys_request_client.h>
  92. #define CSTATE_CONNECTING 1
  93. #define CSTATE_CONNECTED 2
  94. #define RRSTATE_SENDING_REQUEST 1
  95. #define RRSTATE_READY 2
  96. #define RRSTATE_GONE_BAD 3
  97. #define RRSTATE_GONE_GOOD 4
  98. #define RPSTATE_NONE 1
  99. #define RPSTATE_WORKING 2
  100. #define RPSTATE_TERMINATING 3
  101. #define RDSTATE_NONE 1
  102. #define RDSTATE_DYING 2
  103. #define RDSTATE_DYING_ERROR 3
  104. struct instance {
  105. NCDModuleInst *i;
  106. NCDRequestClient client;
  107. LinkedList0 requests_list;
  108. int state;
  109. };
  110. struct request_instance {
  111. NCDModuleInst *i;
  112. NCDValRef reply_handler;
  113. NCDValRef finished_handler;
  114. NCDValRef args;
  115. struct instance *client;
  116. NCDRequestClientRequest request;
  117. LinkedList0Node requests_list_node;
  118. LinkedList1 replies_list;
  119. NCDModuleProcess process;
  120. int process_is_finished;
  121. NCDValMem process_reply_mem;
  122. NCDValRef process_reply_data;
  123. int rstate;
  124. int pstate;
  125. int dstate;
  126. };
  127. struct reply {
  128. LinkedList1Node replies_list_node;
  129. NCDValMem mem;
  130. NCDValRef val;
  131. };
  132. static void client_handler_error (struct instance *o);
  133. static void client_handler_connected (struct instance *o);
  134. static void request_handler_sent (struct request_instance *o);
  135. static void request_handler_reply (struct request_instance *o, NCDValMem reply_mem, NCDValRef reply_value);
  136. static void request_handler_finished (struct request_instance *o, int is_error);
  137. static void request_process_handler_event (NCDModuleProcess *process, int event);
  138. static int request_process_func_getspecialobj (NCDModuleProcess *process, NCD_string_id_t name, NCDObject *out_object);
  139. static int request_process_caller_obj_func_getobj (const NCDObject *obj, NCD_string_id_t name, NCDObject *out_object);
  140. static int request_process_reply_obj_func_getvar (const NCDObject *obj, NCD_string_id_t name, NCDValMem *mem, NCDValRef *out);
  141. static void request_gone (struct request_instance *o, int is_bad);
  142. static void request_terminate_process (struct request_instance *o);
  143. static void request_die (struct request_instance *o, int is_error);
  144. static void request_free_reply (struct request_instance *o, struct reply *r, int have_value);
  145. static int request_init_reply_process (struct request_instance *o, NCDValMem reply_mem, NCDValSafeRef reply_data);
  146. static int request_init_finished_process (struct request_instance *o);
  147. static void instance_free (struct instance *o, int with_error);
  148. static void request_instance_free (struct request_instance *o, int with_error);
  149. enum {STRING_REPLY, STRING_DATA};
  150. static const char *strings[] = {
  151. "_reply", "data", NULL
  152. };
  153. static void client_handler_error (struct instance *o)
  154. {
  155. ModuleLog(o->i, BLOG_ERROR, "client error");
  156. // free instance
  157. instance_free(o, 1);
  158. }
  159. static void client_handler_connected (struct instance *o)
  160. {
  161. ASSERT(o->state == CSTATE_CONNECTING)
  162. // signal up
  163. NCDModuleInst_Backend_Up(o->i);
  164. // set state connected
  165. o->state = CSTATE_CONNECTED;
  166. }
  167. static void request_handler_sent (struct request_instance *o)
  168. {
  169. ASSERT(o->rstate == RRSTATE_SENDING_REQUEST)
  170. // signal up
  171. NCDModuleInst_Backend_Up(o->i);
  172. // set rstate ready
  173. o->rstate = RRSTATE_READY;
  174. }
  175. static void request_handler_reply (struct request_instance *o, NCDValMem reply_mem, NCDValRef reply_value)
  176. {
  177. ASSERT(o->rstate == RRSTATE_READY)
  178. // queue reply if process is running
  179. if (o->pstate != RPSTATE_NONE) {
  180. struct reply *r = malloc(sizeof(*r));
  181. if (!r) {
  182. ModuleLog(o->i, BLOG_ERROR, "malloc failed");
  183. goto fail1;
  184. }
  185. r->mem = reply_mem;
  186. r->val = NCDVal_Moved(&r->mem, reply_value);
  187. LinkedList1_Append(&o->replies_list, &r->replies_list_node);
  188. return;
  189. }
  190. // start reply process
  191. if (!request_init_reply_process(o, reply_mem, NCDVal_ToSafe(reply_value))) {
  192. goto fail1;
  193. }
  194. return;
  195. fail1:
  196. NCDValMem_Free(&reply_mem);
  197. request_die(o, 1);
  198. }
  199. static void request_handler_finished (struct request_instance *o, int is_error)
  200. {
  201. ASSERT(o->rstate == RRSTATE_SENDING_REQUEST || o->rstate == RRSTATE_READY)
  202. ASSERT(is_error || o->rstate == RRSTATE_READY)
  203. if (is_error) {
  204. ModuleLog(o->i, BLOG_ERROR, "received error reply");
  205. goto fail;
  206. }
  207. // request gone good
  208. request_gone(o, 0);
  209. // start process for reporting finished, if possible
  210. if (o->pstate == RPSTATE_NONE) {
  211. if (!request_init_finished_process(o)) {
  212. goto fail;
  213. }
  214. }
  215. return;
  216. fail:
  217. request_die(o, 1);
  218. }
  219. static void request_process_handler_event (NCDModuleProcess *process, int event)
  220. {
  221. struct request_instance *o = UPPER_OBJECT(process, struct request_instance, process);
  222. ASSERT(o->pstate != RPSTATE_NONE)
  223. switch (event) {
  224. case NCDMODULEPROCESS_EVENT_UP: {
  225. ASSERT(o->pstate == RPSTATE_WORKING)
  226. // request process termination
  227. request_terminate_process(o);
  228. } break;
  229. case NCDMODULEPROCESS_EVENT_DOWN: {
  230. ASSERT(0)
  231. } break;
  232. case NCDMODULEPROCESS_EVENT_TERMINATED: {
  233. ASSERT(o->pstate == RPSTATE_TERMINATING)
  234. ASSERT(o->rstate != RRSTATE_SENDING_REQUEST)
  235. // free process
  236. NCDModuleProcess_Free(&o->process);
  237. // free reply data
  238. if (!o->process_is_finished) {
  239. NCDValMem_Free(&o->process_reply_mem);
  240. }
  241. // set process state none
  242. o->pstate = RPSTATE_NONE;
  243. // die finally if requested
  244. if (o->dstate == RDSTATE_DYING || o->dstate == RDSTATE_DYING_ERROR) {
  245. request_instance_free(o, o->dstate == RDSTATE_DYING_ERROR);
  246. return;
  247. }
  248. if (!LinkedList1_IsEmpty(&o->replies_list)) {
  249. // get first reply
  250. struct reply *r = UPPER_OBJECT(LinkedList1_GetFirst(&o->replies_list), struct reply, replies_list_node);
  251. // start reply process
  252. if (!request_init_reply_process(o, r->mem, NCDVal_ToSafe(r->val))) {
  253. goto fail;
  254. }
  255. // free reply
  256. request_free_reply(o, r, 0);
  257. }
  258. else if (o->rstate == RRSTATE_GONE_GOOD && !o->process_is_finished) {
  259. // start process for reporting finished
  260. if (!request_init_finished_process(o)) {
  261. goto fail;
  262. }
  263. }
  264. return;
  265. fail:
  266. request_die(o, 1);
  267. } break;
  268. }
  269. }
  270. static int request_process_func_getspecialobj (NCDModuleProcess *process, NCD_string_id_t name, NCDObject *out_object)
  271. {
  272. struct request_instance *o = UPPER_OBJECT(process, struct request_instance, process);
  273. ASSERT(o->pstate != RPSTATE_NONE)
  274. if (name == NCD_STRING_CALLER) {
  275. *out_object = NCDObject_Build(-1, o, NCDObject_no_getvar, request_process_caller_obj_func_getobj);
  276. return 1;
  277. }
  278. if (!o->process_is_finished && name == ModuleString(o->i, STRING_REPLY)) {
  279. *out_object = NCDObject_Build(-1, o, request_process_reply_obj_func_getvar, NCDObject_no_getobj);
  280. return 1;
  281. }
  282. return 0;
  283. }
  284. static int request_process_caller_obj_func_getobj (const NCDObject *obj, NCD_string_id_t name, NCDObject *out_object)
  285. {
  286. struct request_instance *o = NCDObject_DataPtr(obj);
  287. ASSERT(o->pstate != RPSTATE_NONE)
  288. return NCDModuleInst_Backend_GetObj(o->i, name, out_object);
  289. }
  290. static int request_process_reply_obj_func_getvar (const NCDObject *obj, NCD_string_id_t name, NCDValMem *mem, NCDValRef *out)
  291. {
  292. struct request_instance *o = NCDObject_DataPtr(obj);
  293. ASSERT(o->pstate != RPSTATE_NONE)
  294. ASSERT(!o->process_is_finished)
  295. if (name == ModuleString(o->i, STRING_DATA)) {
  296. *out = NCDVal_NewCopy(mem, o->process_reply_data);
  297. return 1;
  298. }
  299. return 0;
  300. }
  301. static void request_gone (struct request_instance *o, int is_bad)
  302. {
  303. ASSERT(o->rstate != RRSTATE_GONE_BAD)
  304. ASSERT(o->rstate != RRSTATE_GONE_GOOD)
  305. // remove from requests list
  306. LinkedList0_Remove(&o->client->requests_list, &o->requests_list_node);
  307. // free request
  308. NCDRequestClientRequest_Free(&o->request);
  309. // set state over
  310. o->rstate = (is_bad ? RRSTATE_GONE_BAD : RRSTATE_GONE_GOOD);
  311. }
  312. static void request_terminate_process (struct request_instance *o)
  313. {
  314. ASSERT(o->pstate == RPSTATE_WORKING)
  315. // request process termination
  316. NCDModuleProcess_Terminate(&o->process);
  317. // set process state terminating
  318. o->pstate = RPSTATE_TERMINATING;
  319. }
  320. static void request_die (struct request_instance *o, int is_error)
  321. {
  322. // if we have no process, die right away, else we have to wait for process to terminate
  323. if (o->pstate == RPSTATE_NONE) {
  324. request_instance_free(o, is_error);
  325. return;
  326. }
  327. // release request
  328. if (o->rstate != RRSTATE_GONE_BAD && o->rstate != RRSTATE_GONE_GOOD) {
  329. request_gone(o, 1);
  330. }
  331. // initiate process termination, if needed
  332. if (o->pstate != RPSTATE_TERMINATING) {
  333. request_terminate_process(o);
  334. }
  335. // set dstate
  336. o->dstate = (is_error ? RDSTATE_DYING_ERROR : RDSTATE_DYING);
  337. }
  338. static void request_free_reply (struct request_instance *o, struct reply *r, int have_value)
  339. {
  340. // remove from replies list
  341. LinkedList1_Remove(&o->replies_list, &r->replies_list_node);
  342. // free value
  343. if (have_value) {
  344. NCDValMem_Free(&r->mem);
  345. }
  346. // free structure
  347. free(r);
  348. }
  349. static int request_init_reply_process (struct request_instance *o, NCDValMem reply_mem, NCDValSafeRef reply_data)
  350. {
  351. ASSERT(o->pstate == RPSTATE_NONE)
  352. // set parameters
  353. o->process_is_finished = 0;
  354. o->process_reply_mem = reply_mem;
  355. o->process_reply_data = NCDVal_FromSafe(&o->process_reply_mem, reply_data);
  356. // init process
  357. if (!NCDModuleProcess_InitValue(&o->process, o->i, o->reply_handler, o->args, request_process_handler_event)) {
  358. ModuleLog(o->i, BLOG_ERROR, "NCDModuleProcess_Init failed");
  359. goto fail0;
  360. }
  361. // set special objects function
  362. NCDModuleProcess_SetSpecialFuncs(&o->process, request_process_func_getspecialobj);
  363. // set process state working
  364. o->pstate = RPSTATE_WORKING;
  365. return 1;
  366. fail0:
  367. return 0;
  368. }
  369. static int request_init_finished_process (struct request_instance *o)
  370. {
  371. ASSERT(o->pstate == RPSTATE_NONE)
  372. // set parameters
  373. o->process_is_finished = 1;
  374. // init process
  375. if (!NCDModuleProcess_InitValue(&o->process, o->i, o->finished_handler, o->args, request_process_handler_event)) {
  376. ModuleLog(o->i, BLOG_ERROR, "NCDModuleProcess_Init failed");
  377. goto fail0;
  378. }
  379. // set special objects function
  380. NCDModuleProcess_SetSpecialFuncs(&o->process, request_process_func_getspecialobj);
  381. // set process state working
  382. o->pstate = RPSTATE_WORKING;
  383. return 1;
  384. fail0:
  385. return 0;
  386. }
  387. static void func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
  388. {
  389. struct instance *o = vo;
  390. o->i = i;
  391. // check arguments
  392. NCDValRef connect_addr_arg;
  393. if (!NCDVal_ListRead(params->args, 1, &connect_addr_arg)) {
  394. ModuleLog(o->i, BLOG_ERROR, "wrong arity");
  395. goto fail0;
  396. }
  397. // read connect address
  398. struct BConnection_addr addr;
  399. if (!ncd_read_bconnection_addr(connect_addr_arg, &addr)) {
  400. ModuleLog(o->i, BLOG_ERROR, "wrong connect address");
  401. goto fail0;
  402. }
  403. // init client
  404. if (!NCDRequestClient_Init(&o->client, addr, i->params->iparams->reactor, o,
  405. (NCDRequestClient_handler_error)client_handler_error,
  406. (NCDRequestClient_handler_connected)client_handler_connected)) {
  407. ModuleLog(o->i, BLOG_ERROR, "NCDRequestClient_Init failed");
  408. goto fail0;
  409. }
  410. // init requests list
  411. LinkedList0_Init(&o->requests_list);
  412. // set state connecting
  413. o->state = CSTATE_CONNECTING;
  414. return;
  415. fail0:
  416. NCDModuleInst_Backend_DeadError(i);
  417. }
  418. static void instance_free (struct instance *o, int with_error)
  419. {
  420. // deal with requests
  421. LinkedList0Node *ln;
  422. while (ln = LinkedList0_GetFirst(&o->requests_list)) {
  423. struct request_instance *req = UPPER_OBJECT(ln, struct request_instance, requests_list_node);
  424. request_gone(req, 1);
  425. }
  426. // free client
  427. NCDRequestClient_Free(&o->client);
  428. if (with_error) {
  429. NCDModuleInst_Backend_DeadError(o->i);
  430. } else {
  431. NCDModuleInst_Backend_Dead(o->i);
  432. }
  433. }
  434. static void func_die (void *vo)
  435. {
  436. struct instance *o = vo;
  437. instance_free(o, 0);
  438. }
  439. static void request_func_new (void *vo, NCDModuleInst *i, const struct NCDModuleInst_new_params *params)
  440. {
  441. struct request_instance *o = vo;
  442. o->i = i;
  443. // check arguments
  444. NCDValRef request_data_arg;
  445. NCDValRef reply_handler_arg;
  446. NCDValRef finished_handler_arg;
  447. NCDValRef args_arg;
  448. if (!NCDVal_ListRead(params->args, 4, &request_data_arg, &reply_handler_arg, &finished_handler_arg, &args_arg)) {
  449. ModuleLog(o->i, BLOG_ERROR, "wrong arity");
  450. goto fail0;
  451. }
  452. if (!NCDVal_IsString(reply_handler_arg) || !NCDVal_IsString(finished_handler_arg) ||
  453. !NCDVal_IsList(args_arg)
  454. ) {
  455. ModuleLog(o->i, BLOG_ERROR, "wrong type");
  456. goto fail0;
  457. }
  458. o->reply_handler = reply_handler_arg;
  459. o->finished_handler = finished_handler_arg;
  460. o->args = args_arg;
  461. // get client
  462. struct instance *client = NCDModuleInst_Backend_GetUser((NCDModuleInst *)params->method_user);
  463. o->client = client;
  464. // check client state
  465. if (client->state != CSTATE_CONNECTED) {
  466. ModuleLog(o->i, BLOG_ERROR, "client is not connected");
  467. goto fail0;
  468. }
  469. // init request
  470. if (!NCDRequestClientRequest_Init(&o->request, &client->client, request_data_arg, o,
  471. (NCDRequestClientRequest_handler_sent)request_handler_sent,
  472. (NCDRequestClientRequest_handler_reply)request_handler_reply,
  473. (NCDRequestClientRequest_handler_finished)request_handler_finished)) {
  474. ModuleLog(o->i, BLOG_ERROR, "NCDRequestClientRequest_Init failed");
  475. goto fail0;
  476. }
  477. // add to requests list
  478. LinkedList0_Prepend(&client->requests_list, &o->requests_list_node);
  479. // init replies list
  480. LinkedList1_Init(&o->replies_list);
  481. // set state
  482. o->rstate = RRSTATE_SENDING_REQUEST;
  483. o->pstate = RPSTATE_NONE;
  484. o->dstate = RDSTATE_NONE;
  485. return;
  486. fail0:
  487. NCDModuleInst_Backend_DeadError(i);
  488. }
  489. static void request_instance_free (struct request_instance *o, int with_error)
  490. {
  491. ASSERT(o->pstate == RPSTATE_NONE)
  492. // free replies
  493. LinkedList1Node *ln;
  494. while (ln = LinkedList1_GetFirst(&o->replies_list)) {
  495. struct reply *r = UPPER_OBJECT(ln, struct reply, replies_list_node);
  496. request_free_reply(o, r, 1);
  497. }
  498. // release request
  499. if (o->rstate != RRSTATE_GONE_BAD && o->rstate != RRSTATE_GONE_GOOD) {
  500. request_gone(o, 1);
  501. }
  502. if (with_error) {
  503. NCDModuleInst_Backend_DeadError(o->i);
  504. } else {
  505. NCDModuleInst_Backend_Dead(o->i);
  506. }
  507. }
  508. static void request_func_die (void *vo)
  509. {
  510. struct request_instance *o = vo;
  511. request_die(o, 0);
  512. }
  513. static struct NCDModule modules[] = {
  514. {
  515. .type = "sys.request_client",
  516. .func_new2 = func_new,
  517. .func_die = func_die,
  518. .alloc_size = sizeof(struct instance)
  519. }, {
  520. .type = "sys.request_client::request",
  521. .func_new2 = request_func_new,
  522. .func_die = request_func_die,
  523. .alloc_size = sizeof(struct request_instance)
  524. }, {
  525. .type = NULL
  526. }
  527. };
  528. const struct NCDModuleGroup ncdmodule_sys_request_client = {
  529. .modules = modules,
  530. .strings = strings
  531. };