[2/3] img-cache: Drop unnecessary accept_proxy_to_cache

Submitted by Radostin Stoyanov on Jan. 29, 2019, 5:37 p.m.

Details

Message ID 20190129173747.30092-2-rstoyanov1@gmail.com
State Accepted
Series "Series without cover letter"
Commit b1522cd12852421dda0b4d013613997918a2f945
Headers show

Commit Message

Radostin Stoyanov Jan. 29, 2019, 5:37 p.m.
The function accept_proxy_to_cache() is a wrapper around accept().
Use accept() directly instead.

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
---
 criu/img-cache.c | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/img-cache.c b/criu/img-cache.c
index 2177afa88..1e6f79ad0 100644
--- a/criu/img-cache.c
+++ b/criu/img-cache.c
@@ -8,20 +8,6 @@ 
 #include "cr_options.h"
 #include "util.h"
 
-int accept_proxy_to_cache(int sockfd)
-{
-	struct sockaddr_in cli_addr;
-	socklen_t clilen = sizeof(cli_addr);
-	int proxy_fd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
-
-	if (proxy_fd < 0) {
-		pr_perror("Unable to accept remote image connection from image proxy");
-		return -1;
-	}
-
-	return proxy_fd;
-}
-
 int image_cache(bool background, char *local_cache_path, unsigned short cache_write_port)
 {
 	pr_info("Proxy to Cache Port %d, CRIU to Cache Path %s\n",
@@ -38,9 +24,12 @@  int image_cache(bool background, char *local_cache_path, unsigned short cache_wr
 			return -1;
 		}
 		// Wait to accept connection from proxy.
-		proxy_to_cache_fd = accept_proxy_to_cache(proxy_to_cache_fd);
-		if (proxy_to_cache_fd < 0)
+		proxy_to_cache_fd = accept(proxy_to_cache_fd, NULL, 0);
+		if (proxy_to_cache_fd < 0) {
+			pr_perror("Unable to accept remote image connection"
+				  " from image proxy");
 			return -1; // TODO - should close other sockets.
+		}
 	}
 
 	pr_info("Cache is connected to Proxy through fd %d\n", proxy_to_cache_fd);