From: Andre Noll Date: Tue, 31 Dec 2013 15:44:24 +0000 (+0000) Subject: Remove client_disconnect(). X-Git-Tag: v0.5.3~23 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=d1c8428d048631addb89bbb6bd17ade6398dbb89;ds=sidebyside Remove client_disconnect(). Everything this function does can be done as well when the task terminates by returning negative in ->post_select(). This also avoids to leak the stream cipher structure of the previous connection when running in interactive mode. 1,032 bytes in 1 blocks are definitely lost in loss record 61 of 85 at 0x402994A: malloc (vg_replace_malloc.c:263) by 0x804C689: para_malloc (string.c:71) by 0x804FF87: sc_new (crypt.c:268) by 0x804E204: client_post_select (client_common.c:370) by 0x804D203: schedule (sched.c:59) by 0x804A2E7: main (client.c:500) 1,032 bytes in 1 blocks are definitely lost in loss record 62 of 85 at 0x402994A: malloc (vg_replace_malloc.c:263) by 0x804C689: para_malloc (string.c:71) by 0x804FF87: sc_new (crypt.c:268) by 0x804E217: client_post_select (client_common.c:371) by 0x804D203: schedule (sched.c:59) by 0x804A2E7: main (client.c:500) --- diff --git a/client.c b/client.c index c1ef5217..b39a8b01 100644 --- a/client.c +++ b/client.c @@ -114,7 +114,6 @@ static int execute_client_command(const char *cmd, char **result) schedule(&command_sched); *result = exec_task.result_buf; btr_remove_node(&exec_task.btrn); - client_disconnect(ct); ret = 1; out: btr_remove_node(&exec_task.btrn); @@ -444,7 +443,6 @@ static int client_i9e_line_handler(char *line) { int ret; - client_disconnect(ct); PARA_DEBUG_LOG("line: %s\n", line); ret = make_client_argv(line); if (ret <= 0) diff --git a/client.h b/client.h index 82dbc033..e304f092 100644 --- a/client.h +++ b/client.h @@ -52,7 +52,6 @@ struct client_task { char **features; }; -void client_disconnect(struct client_task *ct); void client_close(struct client_task *ct); int client_parse_config(int argc, char *argv[], struct client_task **ct_ptr, int *loglevel); diff --git a/client_common.c b/client_common.c index 900d3653..8212abb1 100644 --- a/client_common.c +++ b/client_common.c @@ -32,44 +32,17 @@ /** The size of the receiving buffer. */ #define CLIENT_BUFSIZE 4000 -/** - * Close the connection to para_server and deallocate per-command resources. - * - * \param ct The client task. - * - * This frees all resources of the current command but keeps the configuration - * in \p ct->conf. - * - * \sa \ref client_close(). - */ -void client_disconnect(struct client_task *ct) -{ - if (!ct) - return; - if (ct->scc.fd >= 0) - close(ct->scc.fd); - free_argv(ct->features); - ct->features = NULL; - sc_free(ct->scc.recv); - ct->scc.recv = NULL; - sc_free(ct->scc.send); - ct->scc.send = NULL; - btr_remove_node(&ct->btrn[0]); - btr_remove_node(&ct->btrn[1]); -} - /** * Close the connection to para_server and free all resources. * * \param ct Pointer to the client data. * - * \sa \ref client_open(), \ref client_disconnect(). + * \sa \ref client_open(). */ void client_close(struct client_task *ct) { if (!ct) return; - client_disconnect(ct); free(ct->user); free(ct->config_file); free(ct->key_file); @@ -476,6 +449,16 @@ out: btr_remove_node(&ct->btrn[1]); if (ret != -E_SERVER_CMD_SUCCESS && ret != -E_SERVER_CMD_FAILURE) PARA_ERROR_LOG("%s\n", para_strerror(-ret)); + if (ct->scc.fd >= 0) { + close(ct->scc.fd); + ct->scc.fd = -1; + } + free_argv(ct->features); + ct->features = NULL; + sc_free(ct->scc.recv); + ct->scc.recv = NULL; + sc_free(ct->scc.send); + ct->scc.send = NULL; return ret; }