threading: simplify thread name logic

pull/7242/head
Victor Julien 3 years ago
parent 93d5bce0aa
commit ce4e543719

@ -366,10 +366,7 @@ static void *StatsMgmtThread(void *arg)
{
ThreadVars *tv_local = (ThreadVars *)arg;
/* Set the thread name */
if (SCSetThreadName(tv_local->name) < 0) {
SCLogWarning(SC_ERR_THREAD_INIT, "Unable to set thread name");
}
SCSetThreadName(tv_local->name);
if (tv_local->thread_setup_flags != 0)
TmThreadSetupOptions(tv_local);
@ -449,10 +446,7 @@ static void *StatsWakeupThread(void *arg)
{
ThreadVars *tv_local = (ThreadVars *)arg;
/* Set the thread name */
if (SCSetThreadName(tv_local->name) < 0) {
SCLogWarning(SC_ERR_THREAD_INIT, "Unable to set thread name");
}
SCSetThreadName(tv_local->name);
if (tv_local->thread_setup_flags != 0)
TmThreadSetupOptions(tv_local);

@ -2815,7 +2815,7 @@ int InitGlobal(void) {
/* initialize the logging subsys */
SCLogInitLogModule(NULL);
(void)SCSetThreadName("Suricata-Main");
SCSetThreadName("Suricata-Main");
/* Ignore SIGUSR2 as early as possble. We redeclare interest
* once we're done launching threads. The goal is to either die

@ -274,7 +274,6 @@ enum {
SCLogDebug("Thread name is too long, truncating it..."); \
strlcpy(tname, n, 16); \
pthread_set_name_np(pthread_self(), tname); \
0; \
})
#elif defined __OpenBSD__ /* OpenBSD */
/** \todo Add implementation for OpenBSD */
@ -289,16 +288,15 @@ enum {
/**
* \brief Set the threads name
*/
#define SCSetThreadName(n) ({ \
char tname[THREAD_NAME_LEN + 1] = ""; \
if (strlen(n) > THREAD_NAME_LEN) \
SCLogDebug("Thread name is too long, truncating it..."); \
strlcpy(tname, n, THREAD_NAME_LEN); \
int ret = 0; \
if ((ret = prctl(PR_SET_NAME, tname, 0, 0, 0)) < 0) \
SCLogDebug("Error setting thread name \"%s\": %s", tname, strerror(errno)); \
ret; \
})
#define SCSetThreadName(n) \
({ \
char tname[THREAD_NAME_LEN + 1] = ""; \
if (strlen(n) > THREAD_NAME_LEN) \
SCLogDebug("Thread name is too long, truncating it..."); \
strlcpy(tname, n, THREAD_NAME_LEN); \
if (prctl(PR_SET_NAME, tname, 0, 0, 0) < 0) \
SCLogDebug("Error setting thread name \"%s\": %s", tname, strerror(errno)); \
})
#else
#define SCSetThreadName(n) (0)
#endif

@ -228,10 +228,7 @@ static void *TmThreadsSlotPktAcqLoop(void *td)
TmEcode r = TM_ECODE_OK;
TmSlot *slot = NULL;
/* Set the thread name */
if (SCSetThreadName(tv->name) < 0) {
SCLogWarning(SC_ERR_THREAD_INIT, "Unable to set thread name");
}
SCSetThreadName(tv->name);
if (tv->thread_setup_flags != 0)
TmThreadSetupOptions(tv);
@ -370,10 +367,7 @@ static void *TmThreadsSlotVar(void *td)
PacketPoolInit();//Empty();
/* Set the thread name */
if (SCSetThreadName(tv->name) < 0) {
SCLogWarning(SC_ERR_THREAD_INIT, "Unable to set thread name");
}
SCSetThreadName(tv->name);
if (tv->thread_setup_flags != 0)
TmThreadSetupOptions(tv);
@ -521,10 +515,7 @@ static void *TmThreadsManagement(void *td)
BUG_ON(s == NULL);
/* Set the thread name */
if (SCSetThreadName(tv->name) < 0) {
SCLogWarning(SC_ERR_THREAD_INIT, "Unable to set thread name");
}
SCSetThreadName(tv->name);
if (tv->thread_setup_flags != 0)
TmThreadSetupOptions(tv);

Loading…
Cancel
Save