X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=send_common.c;h=90242d5c9b5ccb125617004e16fbf9b64d5484f6;hp=24b14ab8ed50b90c956fc6578199f8a4da3f2c4e;hb=f0b8296a0635e74aaa58767e513eed226504ec34;hpb=7e611b37e41f0ec7ec6d3173b7e88ed5b9b3a276 diff --git a/send_common.c b/send_common.c index 24b14ab8..90242d5c 100644 --- a/send_common.c +++ b/send_common.c @@ -44,12 +44,12 @@ */ void shutdown_client(struct sender_client *sc, struct sender_status *ss) { - PARA_INFO_LOG("shutting down %s on fd %d\n", sc->name, sc->fd); - free(sc->name); if (!process_is_command_handler()) { + PARA_INFO_LOG("shutting down %s on fd %d\n", sc->name, sc->fd); close(sc->fd); del_close_on_fork_list(sc->fd); } + free(sc->name); cq_destroy(sc->cq); list_del(&sc->node); free(sc->private_data); @@ -136,9 +136,9 @@ void init_sender_status(struct sender_status *ss, } ss->default_port = default_port; - INIT_LIST_HEAD(&ss->client_list); + init_list_head(&ss->client_list); /* Initialize an access control list */ - INIT_LIST_HEAD(&ss->acl); + init_list_head(&ss->acl); for (i = 0; i < lls_opt_given(acl_opt_result); i++) { const char *arg = lls_string_val(i, acl_opt_result); char addr[16]; @@ -154,6 +154,25 @@ void init_sender_status(struct sender_status *ss, ss->default_deny = default_deny; } +/** + * Deallocate all resources allocated in \ref init_sender_status(). + * + * \param ss The structure whose components should be freed. + * + * This frees the dynamically allocated parts of the structure which was + * initialized by an earlier call to \ref init_sender_status(). It does *not* + * call free(ss), though. + */ +void free_sender_status(const struct sender_status *ss) +{ + int i; + + free(ss->listen_fds); + FOR_EACH_LISTEN_FD(i, ss) + free(ss->listen_addresses[i]); + free(ss->listen_addresses); +} + /** * Return a string containing the current status of a sender. *