[sheepdog] [PATCH] sheep: retire sheep/sockfd_cache.c

Liu Yuan namei.unix at gmail.com
Wed Jul 31 11:59:12 CEST 2013


Now the bulk of its sockfd cache code is in the library, so no need to keep
a dedicated file for it.

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 sheep/Makefile.am    |    2 +-
 sheep/request.c      |   32 ++++++++++++++++++++++++++++++++
 sheep/sockfd_cache.c |   46 ----------------------------------------------
 3 files changed, 33 insertions(+), 47 deletions(-)
 delete mode 100644 sheep/sockfd_cache.c

diff --git a/sheep/Makefile.am b/sheep/Makefile.am
index ebb8587..fe4a938 100644
--- a/sheep/Makefile.am
+++ b/sheep/Makefile.am
@@ -26,7 +26,7 @@ sbin_PROGRAMS		= sheep
 
 sheep_SOURCES		= sheep.c group.c request.c gateway.c store.c vdi.c \
 			  journal.c ops.c recovery.c cluster/local.c \
-			  object_cache.c object_list_cache.c sockfd_cache.c \
+			  object_cache.c object_list_cache.c \
 			  plain_store.c config.c migrate.c md.c \
 			  cluster/shepherd.c
 
diff --git a/sheep/request.c b/sheep/request.c
index ed4b3aa..7f795fd 100644
--- a/sheep/request.c
+++ b/sheep/request.c
@@ -917,3 +917,35 @@ void local_req_init(void)
 		panic("failed to init local req efd");
 	register_event(sys->local_req_efd, local_req_handler, NULL);
 }
+
+int sheep_exec_req(const struct node_id *nid, struct sd_req *hdr, void *buf)
+{
+	struct sd_rsp *rsp = (struct sd_rsp *)hdr;
+	struct sockfd *sfd;
+	int ret;
+
+	assert(is_worker_thread());
+
+	sfd = sockfd_cache_get(nid);
+	if (!sfd)
+		return SD_RES_NETWORK_ERROR;
+
+	ret = exec_req(sfd->fd, hdr, buf, sheep_need_retry, hdr->epoch,
+		       MAX_RETRY_COUNT);
+	if (ret) {
+		sd_dprintf("remote node might have gone away");
+		sockfd_cache_del(nid, sfd);
+		return SD_RES_NETWORK_ERROR;
+	}
+	ret = rsp->result;
+	if (ret != SD_RES_SUCCESS)
+		sd_eprintf("failed %s", sd_strerror(ret));
+
+	sockfd_cache_put(nid, sfd);
+	return ret;
+}
+
+bool sheep_need_retry(uint32_t epoch)
+{
+	return sys_epoch() == epoch;
+}
diff --git a/sheep/sockfd_cache.c b/sheep/sockfd_cache.c
deleted file mode 100644
index 20bca58..0000000
--- a/sheep/sockfd_cache.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2012-2013 Taobao Inc.
- *
- * Liu Yuan <namei.unix at gmail.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License version
- * 2 as published by the Free Software Foundation.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "sheep_priv.h"
-
-int sheep_exec_req(const struct node_id *nid, struct sd_req *hdr, void *buf)
-{
-	struct sd_rsp *rsp = (struct sd_rsp *)hdr;
-	struct sockfd *sfd;
-	int ret;
-
-	assert(is_worker_thread());
-
-	sfd = sockfd_cache_get(nid);
-	if (!sfd)
-		return SD_RES_NETWORK_ERROR;
-
-	ret = exec_req(sfd->fd, hdr, buf, sheep_need_retry, hdr->epoch,
-		       MAX_RETRY_COUNT);
-	if (ret) {
-		sd_dprintf("remote node might have gone away");
-		sockfd_cache_del(nid, sfd);
-		return SD_RES_NETWORK_ERROR;
-	}
-	ret = rsp->result;
-	if (ret != SD_RES_SUCCESS)
-		sd_eprintf("failed %s", sd_strerror(ret));
-
-	sockfd_cache_put(nid, sfd);
-	return ret;
-}
-
-bool sheep_need_retry(uint32_t epoch)
-{
-	return sys_epoch() == epoch;
-}
-- 
1.7.9.5




More information about the sheepdog mailing list