From 93e39de28f6262eea3736f672777ed5076f4e313 Mon Sep 17 00:00:00 2001 From: Asim Jamshed Date: Wed, 1 Mar 2017 19:07:54 +0900 Subject: [PATCH] - More fixes. --- apps/example/epserver.c | 4 ++++ apps/example/epwget.c | 2 +- mtcp/src/api.c | 4 ++++ mtcp/src/io_module.c | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/example/epserver.c b/apps/example/epserver.c index c759d94..d0c2f92 100644 --- a/apps/example/epserver.c +++ b/apps/example/epserver.c @@ -335,6 +335,7 @@ InitializeServerThread(int core) ctx->mctx = mtcp_create_context(core); if (!ctx->mctx) { TRACE_ERROR("Failed to create mtcp context!\n"); + free(ctx); return NULL; } @@ -351,6 +352,9 @@ InitializeServerThread(int core) ctx->svars = (struct server_vars *) calloc(MAX_FLOW_NUM, sizeof(struct server_vars)); if (!ctx->svars) { + mtcp_close(ctx->mctx, ctx->ep); + mtcp_destroy_context(ctx->mctx); + free(ctx); TRACE_ERROR("Failed to create server_vars struct!\n"); return NULL; } diff --git a/apps/example/epwget.c b/apps/example/epwget.c index 4f8d637..5db1ddc 100644 --- a/apps/example/epwget.c +++ b/apps/example/epwget.c @@ -712,7 +712,7 @@ main(int argc, char **argv) strncpy(url, strchr(argv[1], '/'), MAX_URL_LEN); } else { strncpy(host, argv[1], MAX_IP_STR_LEN); - strncpy(url, "/", 1); + strncpy(url, "/", 2); } daddr = inet_addr(host); diff --git a/mtcp/src/api.c b/mtcp/src/api.c index f65ac73..45adbbd 100644 --- a/mtcp/src/api.c +++ b/mtcp/src/api.c @@ -525,11 +525,15 @@ mtcp_listen(mctx_t mctx, int sockid, int backlog) listener->socket = &mtcp->smap[sockid]; if (pthread_cond_init(&listener->accept_cond, NULL)) { + /* errno set internally */ perror("pthread_cond_init of ctx->accept_cond\n"); + free(listener); return -1; } if (pthread_mutex_init(&listener->accept_lock, NULL)) { + /* errno set internally */ perror("pthread_mutex_init of ctx->accept_lock\n"); + free(listener); return -1; } diff --git a/mtcp/src/io_module.c b/mtcp/src/io_module.c index 6dc0088..ee6cbf3 100644 --- a/mtcp/src/io_module.c +++ b/mtcp/src/io_module.c @@ -141,7 +141,6 @@ SetInterfaceInfo(char* dev_name_list) } else { perror("SIOCGIFFLAGS"); } - close(sock); } num_queues = GetNumQueues(); if (num_queues <= 0) { @@ -152,6 +151,7 @@ SetInterfaceInfo(char* dev_name_list) TRACE_CONFIG("Too many NIC queues available.\n"); return -1; } + close(sock); } else if (current_iomodule_func == &dpdk_module_func) { #ifndef DISABLE_DPDK int cpu = CONFIG.num_cores;