Fixes, print on error
This commit is contained in:
parent
fcea494450
commit
59fc8d81a5
3 changed files with 11 additions and 4 deletions
|
@ -16,7 +16,7 @@ OBS_MODULE_USE_DEFAULT_LOCALE("unix-socket-control", "en-US")
|
||||||
bool obs_module_load(void) {
|
bool obs_module_load(void) {
|
||||||
init_unix_socket_handler(&global_unix_socket_handler);
|
init_unix_socket_handler(&global_unix_socket_handler);
|
||||||
|
|
||||||
return is_unix_socket_handler_valid(global_unix_socket_handler) ? true : false;
|
return is_unix_socket_handler_valid(&global_unix_socket_handler) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void obs_module_unload(void) {
|
void obs_module_unload(void) {
|
||||||
|
|
11
src/socket.c
11
src/socket.c
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
// standard library includes
|
// standard library includes
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
// unix includes
|
// unix includes
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -122,6 +123,7 @@ void init_unix_socket_handler(UnixSocketHandler *handler) {
|
||||||
handler->socket_descriptor = socket(AF_UNIX, SOCK_SEQPACKET, 0);
|
handler->socket_descriptor = socket(AF_UNIX, SOCK_SEQPACKET, 0);
|
||||||
if (handler->socket_descriptor == -1) {
|
if (handler->socket_descriptor == -1) {
|
||||||
handler->flags = 0xFFFFFFFFFFFFFFFF;
|
handler->flags = 0xFFFFFFFFFFFFFFFF;
|
||||||
|
fprintf(stderr, "ERROR: unix-socket-control: Failed to create socket!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,6 +132,7 @@ void init_unix_socket_handler(UnixSocketHandler *handler) {
|
||||||
close(handler->socket_descriptor);
|
close(handler->socket_descriptor);
|
||||||
handler->socket_descriptor = -1;
|
handler->socket_descriptor = -1;
|
||||||
handler->flags = 0xFFFFFFFFFFFFFFFF;
|
handler->flags = 0xFFFFFFFFFFFFFFFF;
|
||||||
|
fprintf(stderr, "ERROR: unix-socket-control: Failed to set socket non-blocking!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +148,7 @@ void init_unix_socket_handler(UnixSocketHandler *handler) {
|
||||||
close(handler->socket_descriptor);
|
close(handler->socket_descriptor);
|
||||||
handler->socket_descriptor = -1;
|
handler->socket_descriptor = -1;
|
||||||
handler->flags = 0xFFFFFFFFFFFFFFFF;
|
handler->flags = 0xFFFFFFFFFFFFFFFF;
|
||||||
|
fprintf(stderr, "ERROR: unix-socket-control: Failed to bind socket to filename!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,6 +158,7 @@ void init_unix_socket_handler(UnixSocketHandler *handler) {
|
||||||
handler->socket_descriptor = -1;
|
handler->socket_descriptor = -1;
|
||||||
unlink(handler->socket_filename);
|
unlink(handler->socket_filename);
|
||||||
handler->flags = 0xFFFFFFFFFFFFFFFF;
|
handler->flags = 0xFFFFFFFFFFFFFFFF;
|
||||||
|
fprintf(stderr, "ERROR: unix-socket-control: Failed to set socket listen!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,6 +170,7 @@ void init_unix_socket_handler(UnixSocketHandler *handler) {
|
||||||
handler->socket_descriptor = -1;
|
handler->socket_descriptor = -1;
|
||||||
unlink(handler->socket_filename);
|
unlink(handler->socket_filename);
|
||||||
handler->flags = 0xFFFFFFFFFFFFFFFF;
|
handler->flags = 0xFFFFFFFFFFFFFFFF;
|
||||||
|
fprintf(stderr, "ERROR: unix-socket-control: Failed to init mutex!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,6 +184,7 @@ void init_unix_socket_handler(UnixSocketHandler *handler) {
|
||||||
unlink(handler->socket_filename);
|
unlink(handler->socket_filename);
|
||||||
mtx_destroy(handler->mutex);
|
mtx_destroy(handler->mutex);
|
||||||
handler->flags = 0xFFFFFFFFFFFFFFFF;
|
handler->flags = 0xFFFFFFFFFFFFFFFF;
|
||||||
|
fprintf(stderr, "ERROR: unix-socket-control: Failed to init thread!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,6 +218,6 @@ void cleanup_unix_socket_handler(UnixSocketHandler *handler) {
|
||||||
handler->flags = 0xFFFFFFFFFFFFFFFF;
|
handler->flags = 0xFFFFFFFFFFFFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_unix_socket_handler_valid(UnixSocketHandler handler) {
|
int is_unix_socket_handler_valid(const UnixSocketHandler *handler) {
|
||||||
return handler.flags == 0xFFFFFFFFFFFFFFFF ? 0 : 1;
|
return handler->flags == 0xFFFFFFFFFFFFFFFF ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,6 @@ typedef struct UnixSocketHandler {
|
||||||
|
|
||||||
void init_unix_socket_handler(UnixSocketHandler *handler);
|
void init_unix_socket_handler(UnixSocketHandler *handler);
|
||||||
void cleanup_unix_socket_handler(UnixSocketHandler *handler);
|
void cleanup_unix_socket_handler(UnixSocketHandler *handler);
|
||||||
int is_unix_socket_handler_valid(UnixSocketHandler handler);
|
int is_unix_socket_handler_valid(const UnixSocketHandler *handler);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue