Next: , Previous: , Up: Embedding API   [Contents][Index]


5.2.9 Coserver functions

This section describes the internal coserver interface of Serveez. Coservers are helper processes meant to perform blocking tasks. This is necessary because Serveez itself is single threaded. Each coserver is connected via a pair of pipes to the main thread of Serveez communicating over a simple text line protocol. Each request/response is separated by a newline character.

Function: int svz_foreach_coserver (svz_coserver_do_t *func, void *closure)

Call func for each coserver, passing additionally the second arg closure. If func returns a negative value, return immediately with that value (breaking out of the loop), otherwise, return 0.

Function: void svz_coserver_check (void)

Under woe32 check if there was any response from an active coserver. Moreover keep the coserver threads/processes alive. If one of the coservers dies due to buffer overrun or might be overloaded, start a new one.

Call this function whenever there is time, e.g., within the timeout of the select system call.

Function: void svz_coserver_destroy (int type)

Destroy specific coservers with the type type. All instances of this coserver type will be stopped.

Function: svz_coserver_t * svz_coserver_create (int type)

Create and return a single coserver with the given type type.

Function: const char * svz_coserver_type_name (const svz_coserver_t *coserver)

Return the type name of coserver.

Function: void svz_coserver_rdns_invoke (svz_address_t *addr, svz_coserver_handle_result_t cb, void *closure)

Enqueue a request for the reverse DNS coserver to resolve address addr, arranging for callback cb to be called with two args: the hostname (a string) and the opaque data closure.

Function: void svz_coserver_dns_invoke (char *host, svz_coserver_handle_result_t cb, void *closure)

Enqueue a request for the DNS coserver to resolve host, arranging for callback cb to be called with two args: the ip address in dots-and-numbers notation and the opaque data closure.

Function: void svz_coserver_ident_invoke (svz_socket_t *sock, svz_coserver_handle_result_t cb, void *closure)

Enqueue a request for the ident coserver to resolve the client identity at sock, arranging for callback cb to be called with two args: the identity (string) and the opaque data closure.

To make use of coservers, you need to start the coserver interface by calling svz_updn_all_coservers once before, and once after, entering the main server loop.

Function: int svz_updn_all_coservers (int direction)

If direction is non-zero, init coserver internals. Otherwise, finalize them. Return 0 if successful.

If direction is positive, init also starts one instance each of the builtin servers. If negative, it doesn’t.


Next: Codec functions, Previous: Socket management, Up: Embedding API   [Contents][Index]