From a3062a5e009940a9b65bcb849d2578e4f0b7fbdc Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 17 Jul 2020 07:19:19 +0200 Subject: [PATCH] formatting --- .../slsDetectorServer/src/sharedMemory.c | 28 +++++++++---------- .../slsDetectorServer/src/slsDetectorServer.c | 12 ++++---- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/slsDetectorServers/slsDetectorServer/src/sharedMemory.c b/slsDetectorServers/slsDetectorServer/src/sharedMemory.c index 7a227fb32..5e9e4f303 100644 --- a/slsDetectorServers/slsDetectorServer/src/sharedMemory.c +++ b/slsDetectorServers/slsDetectorServer/src/sharedMemory.c @@ -2,11 +2,11 @@ #include "clogger.h" #include +#include #include #include #include #include -#include #define SHM_NAME "sls_server_shared_memory" #define SHM_VERSION 0x200625 @@ -46,24 +46,23 @@ void sharedMemory_print() { int sharedMemory_create(int port) { // if shm existed, delete old shm and create again - shmFd = - shmget(SHM_KEY + port, MEM_SIZE, IPC_CREAT | IPC_EXCL | 0666); + shmFd = shmget(SHM_KEY + port, MEM_SIZE, IPC_CREAT | IPC_EXCL | 0666); if (shmFd == -1 && errno == EEXIST) { // open existing one - shmFd = shmget(SHM_KEY + port, MEM_SIZE, - IPC_CREAT | 0666); + shmFd = shmget(SHM_KEY + port, MEM_SIZE, IPC_CREAT | 0666); if (shmFd == -1) { - LOG(logERROR, ("c: open existing shared memory (to delete) failed: %s\n", strerror(errno))); + LOG(logERROR, + ("c: open existing shared memory (to delete) failed: %s\n", + strerror(errno))); return FAIL; } // delete existing one sharedMemory_remove(); - LOG(logWARNING, - ("Removed old shared memory with id 0x%x (%d)\n", SHM_KEY + port, SHM_KEY + port)); - + LOG(logWARNING, ("Removed old shared memory with id 0x%x (%d)\n", + SHM_KEY + port, SHM_KEY + port)); + // create it again with current structure - shmFd = shmget(SHM_KEY + port, MEM_SIZE, - IPC_CREAT | IPC_EXCL | 0666); + shmFd = shmget(SHM_KEY + port, MEM_SIZE, IPC_CREAT | IPC_EXCL | 0666); } if (shmFd == -1) { LOG(logERROR, ("Create shared memory failed: %s\n", strerror(errno))); @@ -81,10 +80,11 @@ int sharedMemory_create(int port) { int sharedMemory_initialize() { shm->version = SHM_VERSION; - if (pthread_mutex_init(&(shm->lock), NULL) != 0) { - LOG(logERROR, ("Failed to initialize pthread lock for shared memory\n")); + if (pthread_mutex_init(&(shm->lock), NULL) != 0) { + LOG(logERROR, + ("Failed to initialize pthread lock for shared memory\n")); return FAIL; - } + } shm->scanStatus = IDLE; shm->scanStop = 0; #ifdef VIRTUAL diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c index b5244ee46..981e8cca8 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c @@ -29,7 +29,7 @@ extern int phaseShift; void error(char *msg) { perror(msg); } -void sigInterruptHandler(int p) { +void sigInterruptHandler(int p) { sharedMemory_remove(); exit(-1); } @@ -107,12 +107,12 @@ int main(int argc, char *argv[]) { // Catch signal SIGINT to destroy shm properly struct sigaction sa; - sa.sa_flags = 0;// no flags - sa.sa_handler = sigInterruptHandler;// handler function - sigemptyset(&sa.sa_mask); // dont block additional signals during invocation - // of handler + sa.sa_flags = 0; // no flags + sa.sa_handler = sigInterruptHandler; // handler function + sigemptyset(&sa.sa_mask); // dont block additional signals during + // invocation of handler if (sigaction(SIGINT, &sa, NULL) == -1) { - LOG(logERROR,("Could not set handler function for SIGINT")); + LOG(logERROR, ("Could not set handler function for SIGINT")); } if (sharedMemory_create(portno) == FAIL) {