Fix seg fault while running cuda tests. Don't set the alarm while running unittests, inside cuda-packet-batcher.c. Will result in a seg while the sig handler for ALRM in invoked

remotes/origin/master-1.0.x
Anoop Saldanha 16 years ago committed by Victor Julien
parent 3536ba7348
commit 3a0dadc0f3

@ -86,6 +86,8 @@ static uint32_t buffer_packet_threshhold = 2400;
* processing on the GPU */
static int queue_buffer = 0;
static int unittest_mode = 0;
/**
* \internal
* \brief The SIG_ALRM handler. We will set the "queue_buffer" flag thus
@ -484,8 +486,13 @@ TmEcode SCCudaPBThreadInit(ThreadVars *tv, void *initdata, void **data)
/* set the SIG_ALRM handler */
SCCudaPBSetBatcherAlarmTimeHandler();
/* Set the alarm time limit during which the batcher thread would buffer packets */
alarm(SC_CUDA_PB_BATCHER_ALARM_TIME);
/* if we are running unittests, don't set the alarm handler. It will only
* cause a seg fault if the tests take too long */
if (!unittest_mode) {
/* Set the alarm time limit during which the batcher thread would
* buffer packets */
alarm(SC_CUDA_PB_BATCHER_ALARM_TIME);
}
return TM_ECODE_OK;
}
@ -514,7 +521,11 @@ TmEcode SCCudaPBBatchPackets(ThreadVars *tv, Packet *p, void *data, PacketQueue
"buffer and reseting the alarm");
queue_buffer = 0;
SCCudaPBQueueBuffer(data);
alarm(SC_CUDA_PB_BATCHER_ALARM_TIME);
/* if we are running unittests, don't set the alarm handler. It will only
* cause a seg fault if the tests take too long */
if (!unittest_mode) {
alarm(SC_CUDA_PB_BATCHER_ALARM_TIME);
}
}
/* this is possible, since we are using a custom slot function that calls this
@ -674,7 +685,11 @@ TmEcode SCCudaPBBatchPackets(ThreadVars *tv, Packet *p, void *data, PacketQueue
"time limit. Buffering the packet buffer and reseting the "
"alarm.", buffer_packet_threshhold);
SCCudaPBQueueBuffer(tctx);
alarm(SC_CUDA_PB_BATCHER_ALARM_TIME);
/* if we are running unittests, don't set the alarm handler. It will only
* cause a seg fault if the tests take too long */
if (!unittest_mode) {
alarm(SC_CUDA_PB_BATCHER_ALARM_TIME);
}
}
return TM_ECODE_OK;
@ -842,6 +857,11 @@ void SCCudaPBKillBatchingPackets(void)
return;
}
void SCCudaPBRunningTests(int status)
{
unittest_mode = status;
}
/***********************************Unittests**********************************/
#ifdef UNITTESTS
@ -991,6 +1011,7 @@ int SCCudaPBTest01(void)
result &= (dq->len == 0);
dq = &data_queues[tmq_inq->id];
result &= (dq->len == 10);
SCCudaPBRunningTests(1);
SCCudaPBThreadInit(&tv_cuda_PB, de_ctx, (void *)&tctx);
SCCudaPBSetBufferPacketThreshhold(sizeof(strings)/sizeof(char *));
@ -1216,6 +1237,7 @@ int SCCudaPBTest02(void)
result &= (dq->len == 0);
dq = &data_queues[tmq_inq->id];
result &= (dq->len == 10);
SCCudaPBRunningTests(1);
SCCudaPBThreadInit(&tv_cuda_PB, de_ctx, (void *)&tctx);
result = 1;

@ -137,6 +137,8 @@ void TmModuleCudaPacketBatcherRegister(void);
void *SCCudaPBTmThreadsSlot1(void *);
void SCCudaPBRunningTests(int);
#endif /* __SC_CUDA_SUPPORT__ */
#endif /* __CUDA_PACKET_BATCHER_H__ */

@ -2520,6 +2520,7 @@ static int B2gCudaTest02(void)
dq = &data_queues[tmq_inq->id];
result &= (dq->len == 10);
SCCudaPBRunningTests(1);
/* init the TM thread */
SCCudaPBThreadInit(&tv, de_ctx, (void *)&pb_tctx);
SCCudaPBSetBufferPacketThreshhold(no_of_pkts);
@ -2819,6 +2820,7 @@ static int B2gCudaTest03(void)
dq = &data_queues[tmq_inq->id];
result &= (dq->len == 10);
SCCudaPBRunningTests(1);
/* init the TM thread */
SCCudaPBThreadInit(&tv, de_ctx, (void *)&pb_tctx);
SCCudaPBSetBufferPacketThreshhold(no_of_pkts);

Loading…
Cancel
Save