#ifdef BUILD_UNIX_SOCKET
+static int RunModeUnixSocketSingle(void);
static int unix_manager_file_task_running = 0;
static int unix_manager_file_task_failed = 0;
}
#endif /* BUILD_UNIX_SOCKET */
+#ifdef BUILD_UNIX_SOCKET
/**
* \brief Single thread version of the Pcap file processing.
*/
-int RunModeUnixSocketSingle(void)
+static int RunModeUnixSocketSingle(void)
{
-#ifdef BUILD_UNIX_SOCKET
PcapCommand *pcapcmd = SCMalloc(sizeof(PcapCommand));
+ if (UnixManagerInit() != 0)
+ return 1;
+
if (unlikely(pcapcmd == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Can not allocate pcap command");
return 1;
pcapcmd->running = 0;
pcapcmd->currentfile = NULL;
- UnixManagerThreadSpawn(1);
-
- unix_socket_mode_is_running = 1;
-
UnixManagerRegisterCommand("pcap-file", UnixSocketAddPcapFile, pcapcmd, UNIX_CMD_TAKE_ARGS);
UnixManagerRegisterCommand("pcap-file-number", UnixSocketPcapFilesNumber, pcapcmd, 0);
UnixManagerRegisterCommand("pcap-file-list", UnixSocketPcapFilesList, pcapcmd, 0);
UnixManagerRegisterCommand("pcap-current", UnixSocketPcapCurrent, pcapcmd, 0);
UnixManagerRegisterBackgroundTask(UnixSocketPcapFilesCheck, pcapcmd);
-#endif
+
+ UnixManagerThreadSpawn(1);
+ unix_socket_mode_is_running = 1;
return 0;
}
+#endif
int RunModeUnixSocketIsActive(void)
{
#ifndef __RUNMODE_UNIX_SOCKET_H__
#define __RUNMODE_UNIX_SOCKET_H__
-int RunModeUnixSocketSingle(void);
void RunModeUnixSocketRegister(void);
const char *RunModeUnixSocketGetDefaultMode(void);
SCReturnInt(TM_ECODE_OK);
}
-typedef struct UnixManagerThreadData_ {
- int padding;
-} UnixManagerThreadData;
-
-static TmEcode UnixManagerThreadInit(ThreadVars *t, const void *initdata, void **data)
+int UnixManagerInit(void)
{
- UnixManagerThreadData *utd = SCCalloc(1, sizeof(*utd));
- if (utd == NULL)
- return TM_ECODE_FAILED;
-
if (UnixNew(&command) == 0) {
int failure_fatal = 0;
if (ConfGetBool("engine.init-failure-fatal", &failure_fatal) != 1) {
SCLogDebug("ConfGetBool could not load the value.");
}
- SCFree(utd);
if (failure_fatal) {
SCLogError(SC_ERR_INITIALIZATION,
"Unable to create unix command socket");
} else {
SCLogWarning(SC_ERR_INITIALIZATION,
"Unable to create unix command socket");
- return TM_ECODE_FAILED;
+ return -1;
}
}
UnixManagerRegisterCommand("remove-hostbit", UnixSocketHostbitRemove, &command, UNIX_CMD_TAKE_ARGS);
UnixManagerRegisterCommand("list-hostbit", UnixSocketHostbitList, &command, UNIX_CMD_TAKE_ARGS);
+ return 0;
+}
+
+typedef struct UnixManagerThreadData_ {
+ int padding;
+} UnixManagerThreadData;
+
+static TmEcode UnixManagerThreadInit(ThreadVars *t, const void *initdata, void **data)
+{
+ UnixManagerThreadData *utd = SCCalloc(1, sizeof(*utd));
+ if (utd == NULL)
+ return TM_ECODE_FAILED;
+
*data = utd;
return TM_ECODE_OK;
}
SCCtrlCondT unix_manager_ctrl_cond;
SCCtrlMutex unix_manager_ctrl_mutex;
+int UnixManagerInit(void);
void UnixManagerThreadSpawn(int mode);
void UnixSocketKillSocketThread(void);