This commit is contained in:
2026-05-03 17:17:13 +02:00
parent 69b0ee6d68
commit 30253aa5b5
3 changed files with 9 additions and 8 deletions
-3
View File
@@ -1,12 +1,9 @@
#include "ipc.h" #include "ipc.h"
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <errno.h> #include <errno.h>
#include <pthread.h> #include <pthread.h>
#include <sys/socket.h>
#include <sys/un.h> #include <sys/un.h>
static int make_server_socket(const char *path) static int make_server_socket(const char *path)
+4 -1
View File
@@ -2,6 +2,9 @@
#include <stdint.h> #include <stdint.h>
#include <pthread.h> #include <pthread.h>
#include <sys/socket.h>
#include <unistd.h>
#include <stdio.h>
#define IPC_SOCKET_PATH "/tmp/ipc_demo.sock" #define IPC_SOCKET_PATH "/tmp/ipc_demo.sock"
#define IPC_BACKLOG 1 #define IPC_BACKLOG 1
@@ -13,7 +16,7 @@ typedef struct {
volatile int running; volatile int running;
ipc_client_fn handler; ipc_client_fn handler;
pthread_t _tid; /* internal — do not touch */ pthread_t _tid; /* internal — do not touch */
const char* socket_path; char* socket_path;
} ipc_ctx_t; } ipc_ctx_t;
int create_ipc(ipc_ctx_t *ctx, ipc_client_fn handler, const char* socket_path); int create_ipc(ipc_ctx_t *ctx, ipc_client_fn handler, const char* socket_path);
void destroy_ipc(ipc_ctx_t *ctx); void destroy_ipc(ipc_ctx_t *ctx);
+5 -4
View File
@@ -482,10 +482,11 @@ static void *handle_client(void *arg) {
int main(int argc, char **argv) { int main(int argc, char **argv) {
printf("fm95 (an FM Processor by radio95) version 2.5\n"); printf("fm95 (an FM Processor by radio95) version 2.5\n");
ipc_ctx_t ctx = NULL; ipc_ctx_t ctx;
if(create_ipc(&ctx, handle_client, "/etc/fm95/ctl.socket") < 0) { ipc_ctx_t *pctx = &ctx;
if(create_ipc(pctx, handle_client, "/etc/fm95/ctl.socket") < 0) {
printf("Could not create IPC.\n"); printf("Could not create IPC.\n");
ctx = NULL; pctx = NULL;
} }
@@ -603,6 +604,6 @@ int main(int argc, char **argv) {
cleanup_audio_runtime(&runtime, config.options); cleanup_audio_runtime(&runtime, config.options);
break; break;
} }
if(ctx != NULL) destroy_ipc(&ctx); if(pctx != NULL) destroy_ipc(pctx);
return ret; return ret;
} }