From: hadaq Date: Fri, 20 Jul 2012 16:03:16 +0000 (+0000) Subject: removed signal blocking from TRB3 design, not needed anymore X-Git-Tag: v6.0~17 X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=d4038d89448f0acd99070a99805ffc07eff3e688;p=trbnettools.git removed signal blocking from TRB3 design, not needed anymore --- diff --git a/libtrbnet/trbnet.c b/libtrbnet/trbnet.c index 83fa017..9cf9d3c 100644 --- a/libtrbnet/trbnet.c +++ b/libtrbnet/trbnet.c @@ -1,11 +1,11 @@ #ifdef ETRAX -const char trbnet_version[] = "$Revision: 4.40 $ Local Etrax"; +const char trbnet_version[] = "$Revision: 4.41 $ Local Etrax"; #elif defined PEXOR -const char trbnet_version[] = "$Revision: 4.40 $ Local Pexor"; +const char trbnet_version[] = "$Revision: 4.41 $ Local Pexor"; #elif defined TRB3 -const char trbnet_version[] = "$Revision: 4.40 $ Local TRB3"; +const char trbnet_version[] = "$Revision: 4.41 $ Local TRB3"; #else -const char trbnet_version[] = "$Revision: 4.40 $ UNKNOWN, i.e. ERROR"; +const char trbnet_version[] = "$Revision: 4.41 $ UNKNOWN, i.e. ERROR"; #endif #include @@ -175,14 +175,16 @@ uint16_t sender_address = 0x5555; /* ---------------------------------------------------------------------- */ +#ifndef TRB3 + /* Used for blocking Signals */ static sigset_t blockSet; static sigset_t blockSetOld; /* Semaphore handling */ static int semid = -1; -#ifndef TRB3 static const key_t sem_key = 0x545242; + #endif unsigned int trb_debug = 0; @@ -1385,19 +1387,17 @@ static int lockPorts(int masterLock) -1, /* sem_op: decrement semaphore by 1, i.e. lock it */ SEM_UNDO /* sem_flg: remove lock if process gets killed */ }; - + if ((master_lock == 1) && (masterLock == 0)) { return 0; } -#endif - + /* Block Signals */ if (sigprocmask(SIG_BLOCK, &blockSet, &blockSetOld) == -1) { trb_errno = TRB_SEMAPHORE; return -1; } -#ifndef TRB3 /* Wait for semaphore and lock it */ if (semop(semid, &sops, 1) == -1) { /* Unblock signals */ @@ -1413,7 +1413,7 @@ static int lockPorts(int masterLock) #endif if (masterLock != 0) master_lock = 1; - + return 0; } @@ -1426,7 +1426,7 @@ static int unlockPorts(int masterLock) SEM_UNDO /* sem_flg: remove lock if process gets killed */ }; #endif - + if ((master_lock == 1) && (masterLock == 0)) { return 0; } @@ -1439,13 +1439,13 @@ static int unlockPorts(int masterLock) trb_errno = TRB_SEMAPHORE; return -1; } -#endif /* Unblock Signals */ if (sigprocmask(SIG_SETMASK, &blockSetOld, NULL) == -1) { trb_errno = TRB_SEMAPHORE; return -1; } +#endif return 0; } @@ -1453,14 +1453,14 @@ static int unlockPorts(int masterLock) static int init_semaphore() { - /* Set signal mask to block ALL signals */ - sigfillset(&blockSet); - sigemptyset(&blockSetOld); - #ifdef TRB3 return 0; #else + /* Set signal mask to block ALL signals */ + sigfillset(&blockSet); + sigemptyset(&blockSetOld); + /* Get / Create semaphore */ if ((semid = semget(sem_key, 1, IPC_CREAT | IPC_EXCL |