From 7e24fb277d736afb9f796d7904caeb5156a5870b Mon Sep 17 00:00:00 2001 From: chirsFisher Date: Mon, 15 Nov 2021 18:56:06 +0800 Subject: [PATCH 1/2] fix: fix issue#4 --- rdcp.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rdcp.c b/rdcp.c index 4448b85..e234009 100644 --- a/rdcp.c +++ b/rdcp.c @@ -1090,6 +1090,7 @@ static int rdcp_test_client(struct rdcp_cb *cb) struct ibv_send_wr *bad_wr; int size; long total_size = 0; + struct stat filebuf; if (!cb->use_null) { cb->fd = open(cb->metadata.src_path, O_RDONLY); @@ -1098,14 +1099,17 @@ static int rdcp_test_client(struct rdcp_cb *cb) perror("Couldn't open file"); goto out; } - cb->fp = fdopen(cb->fd, "rb"); - fseek(cb->fp, 0, SEEK_END); - cb->metadata.size = ftell(cb->fp); + // cb->fp = fdopen(cb->fd, "rb"); + // fseek(cb->fp, 0, SEEK_END); + // cb->metadata.size = ftell(cb->fp); + stat(cb->metadata.src_path, &filebuf); + cb->metadata.size = filebuf.st_size; + if (cb->metadata.size <= 0) { perror("size error"); goto out; } - fseek(cb->fp, 0, SEEK_SET); + // fseek(cb->fp, 0, SEEK_SET); } else { cb->metadata.size = 0; } From a2253c35c7646dbd96ca86d4567ce719f5419de6 Mon Sep 17 00:00:00 2001 From: chirsFisher Date: Mon, 15 Nov 2021 20:11:25 +0800 Subject: [PATCH 2/2] fix:fix issue#8 --- rdcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdcp.c b/rdcp.c index e234009..ab25e52 100644 --- a/rdcp.c +++ b/rdcp.c @@ -1179,7 +1179,7 @@ static int rdcp_test_client(struct rdcp_cb *cb) VERBOSE_LOG(1, "done\n"); out: - fclose(cb->fp); + // fclose(cb->fp); cb->fd = -1; return (cb->state == DISCONNECTED) ? 0 : ret;