From 308842ef190a5fc28feb8e4856814be484d0bc2f Mon Sep 17 00:00:00 2001 From: Beginner <70857188+Beginner-Go@users.noreply.github.com> Date: Wed, 2 Feb 2022 12:01:01 +0800 Subject: [PATCH] shellsync: cleanup package (#8812) Co-authored-by: AmadeusGhost <42570690+AmadeusGhost@users.noreply.github.com> --- package/network/services/shellsync/Makefile | 6 +++--- .../services/shellsync/src/shellsync.c | 20 ++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/package/network/services/shellsync/Makefile b/package/network/services/shellsync/Makefile index dcbce1d21..08bc5c11e 100644 --- a/package/network/services/shellsync/Makefile +++ b/package/network/services/shellsync/Makefile @@ -8,7 +8,7 @@ include $(INCLUDE_DIR)/package.mk define Package/shellsync CATEGORY:=Utilities - TITLE:=shellsync + TITLE:=Sync shell scripts DEPENDS:=+libpthread +kmod-macvlan endef @@ -18,7 +18,8 @@ define Build/Prepare endef define Package/shellsync/description -A tool to sync different shell scripts.Based on syncppp patch by morfast. +A tool to sync different shell scripts. +Based on syncppp patch by morfast. endef define Build/Compile @@ -30,5 +31,4 @@ define Package/shellsync/install $(INSTALL_BIN) $(PKG_BUILD_DIR)/shellsync $(1)/usr/bin endef - $(eval $(call BuildPackage,shellsync)) diff --git a/package/network/services/shellsync/src/shellsync.c b/package/network/services/shellsync/src/shellsync.c index 4aef1e9ba..ba9e2100a 100644 --- a/package/network/services/shellsync/src/shellsync.c +++ b/package/network/services/shellsync/src/shellsync.c @@ -4,20 +4,23 @@ > Mail: gch981213@gmail.com > Created Time: 2014年11月06日 星期四 19时15分30秒 ************************************************************************/ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include + #define SEM_BLOCK_NAME "SYNCSHELL_block" #define SEM_COUNT_NAME "SYNCSHELL_count" + int wait_timeout; + int sync_wait(int nproc) { int flags; int value; - sem_t *block; + sem_t *block; sem_t *count; struct timespec ts; @@ -32,7 +35,6 @@ int sync_wait(int nproc) } ts.tv_sec += wait_timeout; - flags = O_RDWR | O_CREAT; block = sem_open(SEM_BLOCK_NAME, flags, 0644, 0); count = sem_open(SEM_COUNT_NAME, flags, 0644, 0); @@ -50,6 +52,7 @@ int sync_wait(int nproc) return -1; } printf("%d processes have arrived, waiting for the left %d\n", value, nproc-value); + if (value >= nproc) { while (nproc-1 > 0) { if (sem_post(block) < 0) { @@ -67,7 +70,6 @@ int sync_wait(int nproc) } return -1; } - } sem_close(count);