mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 03:40:04 +02:00
formatting
This commit is contained in:
parent
c6921bf954
commit
a3062a5e00
@ -2,11 +2,11 @@
|
|||||||
#include "clogger.h"
|
#include "clogger.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <pthread.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/ipc.h>
|
#include <sys/ipc.h>
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#define SHM_NAME "sls_server_shared_memory"
|
#define SHM_NAME "sls_server_shared_memory"
|
||||||
#define SHM_VERSION 0x200625
|
#define SHM_VERSION 0x200625
|
||||||
@ -46,24 +46,23 @@ void sharedMemory_print() {
|
|||||||
|
|
||||||
int sharedMemory_create(int port) {
|
int sharedMemory_create(int port) {
|
||||||
// if shm existed, delete old shm and create again
|
// if shm existed, delete old shm and create again
|
||||||
shmFd =
|
shmFd = shmget(SHM_KEY + port, MEM_SIZE, IPC_CREAT | IPC_EXCL | 0666);
|
||||||
shmget(SHM_KEY + port, MEM_SIZE, IPC_CREAT | IPC_EXCL | 0666);
|
|
||||||
if (shmFd == -1 && errno == EEXIST) {
|
if (shmFd == -1 && errno == EEXIST) {
|
||||||
// open existing one
|
// open existing one
|
||||||
shmFd = shmget(SHM_KEY + port, MEM_SIZE,
|
shmFd = shmget(SHM_KEY + port, MEM_SIZE, IPC_CREAT | 0666);
|
||||||
IPC_CREAT | 0666);
|
|
||||||
if (shmFd == -1) {
|
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;
|
return FAIL;
|
||||||
}
|
}
|
||||||
// delete existing one
|
// delete existing one
|
||||||
sharedMemory_remove();
|
sharedMemory_remove();
|
||||||
LOG(logWARNING,
|
LOG(logWARNING, ("Removed old shared memory with id 0x%x (%d)\n",
|
||||||
("Removed old shared memory with id 0x%x (%d)\n", SHM_KEY + port, SHM_KEY + port));
|
SHM_KEY + port, SHM_KEY + port));
|
||||||
|
|
||||||
// create it again with current structure
|
// create it again with current structure
|
||||||
shmFd = shmget(SHM_KEY + port, MEM_SIZE,
|
shmFd = shmget(SHM_KEY + port, MEM_SIZE, IPC_CREAT | IPC_EXCL | 0666);
|
||||||
IPC_CREAT | IPC_EXCL | 0666);
|
|
||||||
}
|
}
|
||||||
if (shmFd == -1) {
|
if (shmFd == -1) {
|
||||||
LOG(logERROR, ("Create shared memory failed: %s\n", strerror(errno)));
|
LOG(logERROR, ("Create shared memory failed: %s\n", strerror(errno)));
|
||||||
@ -82,7 +81,8 @@ int sharedMemory_create(int port) {
|
|||||||
int sharedMemory_initialize() {
|
int sharedMemory_initialize() {
|
||||||
shm->version = SHM_VERSION;
|
shm->version = SHM_VERSION;
|
||||||
if (pthread_mutex_init(&(shm->lock), NULL) != 0) {
|
if (pthread_mutex_init(&(shm->lock), NULL) != 0) {
|
||||||
LOG(logERROR, ("Failed to initialize pthread lock for shared memory\n"));
|
LOG(logERROR,
|
||||||
|
("Failed to initialize pthread lock for shared memory\n"));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
shm->scanStatus = IDLE;
|
shm->scanStatus = IDLE;
|
||||||
|
@ -109,8 +109,8 @@ int main(int argc, char *argv[]) {
|
|||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
sa.sa_flags = 0; // no flags
|
sa.sa_flags = 0; // no flags
|
||||||
sa.sa_handler = sigInterruptHandler; // handler function
|
sa.sa_handler = sigInterruptHandler; // handler function
|
||||||
sigemptyset(&sa.sa_mask); // dont block additional signals during invocation
|
sigemptyset(&sa.sa_mask); // dont block additional signals during
|
||||||
// of handler
|
// invocation of handler
|
||||||
if (sigaction(SIGINT, &sa, NULL) == -1) {
|
if (sigaction(SIGINT, &sa, NULL) == -1) {
|
||||||
LOG(logERROR, ("Could not set handler function for SIGINT"));
|
LOG(logERROR, ("Could not set handler function for SIGINT"));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user