Commit: 239392a90e60209dd824539069615cde6da65e10
Parent: cfe2e822cbba455bafc91e4d149899fd8b9986a1
Author: Randy Palamar
Date: Thu, 27 Feb 2025 09:16:51 -0700
lib: unix: don't unlink beamformer data pipe
Since the library didn't create the pipe it shouldn't remove it
when the beamformer isn't expecting it. This fixes a bug with
trying to use send_data() after doing a beamform_data_synchronized()
Diffstat:
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/helpers/ogl_beamformer_lib.c b/helpers/ogl_beamformer_lib.c
@@ -109,11 +109,11 @@ os_disconnect_pipe(Pipe p)
}
static void
-os_close_pipe(Pipe* p)
+os_close_pipe(iptr *file, char *name)
{
- close(p->file);
- unlink(p->name);
- p->file = INVALID_FILE;
+ if (file) close(*file);
+ if (name) unlink(name);
+ *file = INVALID_FILE;
}
static b32
@@ -189,10 +189,10 @@ os_disconnect_pipe(Pipe p)
}
static void
-os_close_pipe(Pipe *p)
+os_close_pipe(iptr *file, char *name)
{
- CloseHandle(p->file);
- p->file = INVALID_FILE;
+ if (file) CloseHandle(*file);
+ *file = INVALID_FILE;
}
static b32
@@ -322,7 +322,7 @@ send_raw_data(char *pipe_name, char *shm_name, void *data, u32 data_size)
result = written == data_size;
if (!result) {
warning_msg("failed to write data to pipe: retrying...");
- os_close_pipe(&g_pipe);
+ os_close_pipe(&g_pipe.file, 0);
os_release_shared_memory((iptr)g_bp, sizeof(*g_bp));
g_bp = 0;
g_pipe = os_open_named_pipe(pipe_name);
@@ -409,6 +409,6 @@ beamform_data_synchronized(char *pipe_name, char *shm_name, i16 *data, uv2 data_
}
os_disconnect_pipe(export_pipe);
- os_close_pipe(&export_pipe);
- os_close_pipe(&g_pipe);
+ os_close_pipe(&export_pipe.file, export_pipe.name);
+ os_close_pipe(&g_pipe.file, 0);
}