Commit 28cbee4b authored by 's avatar

fix in mapiiipc_remote_init for closing open sockets in case of failures


git-svn-id: file:///home/svn/mapi/trunk@1380 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent f3ce8351
......@@ -635,6 +635,7 @@ int mapiipc_remote_init(struct host *h)
}
if (host==NULL) {
close(h->sockfd);
printf("ERROR: Could not determine address for host %s [%s:%d]\n", h->hostname, __FILE__, __LINE__);
return -1;
}
......@@ -645,16 +646,19 @@ int mapiipc_remote_init(struct host *h)
remoteaddr.sin_port = htons(h->port);
if (connect(h->sockfd, (struct sockaddr *)&remoteaddr, sizeof(remoteaddr)) < 0) {
close(h->sockfd);
printf("ERROR: connect failed (%s) [%s:%d]\n", strerror(errno), __FILE__, __LINE__);
return -1;
}
#ifdef DIMAPISSL
if (SSL_set_fd(h->con, h->sockfd) == 0) {
close(h->sockfd);
ERR_print_errors_fp(stderr);
return -1;
}
if (SSL_connect(h->con) <= 0) {
close(h->sockfd);
ERR_print_errors_fp(stderr);
return -1;
}
......
......@@ -633,6 +633,12 @@ int mapi_create_flow(const char *dev)
if (mapiipc_remote_init(h)<0) {
local_err = MCOM_SOCKET_ERROR;
printf("ERROR: Could not connect with host %s [%s:%d]\n", h->hostname, __FILE__, __LINE__);
flist_destroy(h->flows);
free(h->flows);
flist_destroy(h->functions);
free(h->functions);
free(h->hostname);
free(h);
pthread_spin_unlock(&hostlist_lock);
return -1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment