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 */ * processing on the GPU */
static int queue_buffer = 0; static int queue_buffer = 0;
static int unittest_mode = 0;
/** /**
* \internal * \internal
* \brief The SIG_ALRM handler. We will set the "queue_buffer" flag thus * \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 */ /* set the SIG_ALRM handler */
SCCudaPBSetBatcherAlarmTimeHandler(); SCCudaPBSetBatcherAlarmTimeHandler();
/* Set the alarm time limit during which the batcher thread would buffer packets */ /* 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); alarm(SC_CUDA_PB_BATCHER_ALARM_TIME);
}
return TM_ECODE_OK; return TM_ECODE_OK;
} }
@ -514,8 +521,12 @@ TmEcode SCCudaPBBatchPackets(ThreadVars *tv, Packet *p, void *data, PacketQueue
"buffer and reseting the alarm"); "buffer and reseting the alarm");
queue_buffer = 0; queue_buffer = 0;
SCCudaPBQueueBuffer(data); SCCudaPBQueueBuffer(data);
/* 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); alarm(SC_CUDA_PB_BATCHER_ALARM_TIME);
} }
}
/* this is possible, since we are using a custom slot function that calls this /* this is possible, since we are using a custom slot function that calls this
* function, even if it receives no packet from the packet queue */ * function, even if it receives no packet from the packet queue */
@ -674,8 +685,12 @@ TmEcode SCCudaPBBatchPackets(ThreadVars *tv, Packet *p, void *data, PacketQueue
"time limit. Buffering the packet buffer and reseting the " "time limit. Buffering the packet buffer and reseting the "
"alarm.", buffer_packet_threshhold); "alarm.", buffer_packet_threshhold);
SCCudaPBQueueBuffer(tctx); SCCudaPBQueueBuffer(tctx);
/* 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); alarm(SC_CUDA_PB_BATCHER_ALARM_TIME);
} }
}
return TM_ECODE_OK; return TM_ECODE_OK;
} }
@ -842,6 +857,11 @@ void SCCudaPBKillBatchingPackets(void)
return; return;
} }
void SCCudaPBRunningTests(int status)
{
unittest_mode = status;
}
/***********************************Unittests**********************************/ /***********************************Unittests**********************************/
#ifdef UNITTESTS #ifdef UNITTESTS
@ -991,6 +1011,7 @@ int SCCudaPBTest01(void)
result &= (dq->len == 0); result &= (dq->len == 0);
dq = &data_queues[tmq_inq->id]; dq = &data_queues[tmq_inq->id];
result &= (dq->len == 10); result &= (dq->len == 10);
SCCudaPBRunningTests(1);
SCCudaPBThreadInit(&tv_cuda_PB, de_ctx, (void *)&tctx); SCCudaPBThreadInit(&tv_cuda_PB, de_ctx, (void *)&tctx);
SCCudaPBSetBufferPacketThreshhold(sizeof(strings)/sizeof(char *)); SCCudaPBSetBufferPacketThreshhold(sizeof(strings)/sizeof(char *));
@ -1216,6 +1237,7 @@ int SCCudaPBTest02(void)
result &= (dq->len == 0); result &= (dq->len == 0);
dq = &data_queues[tmq_inq->id]; dq = &data_queues[tmq_inq->id];
result &= (dq->len == 10); result &= (dq->len == 10);
SCCudaPBRunningTests(1);
SCCudaPBThreadInit(&tv_cuda_PB, de_ctx, (void *)&tctx); SCCudaPBThreadInit(&tv_cuda_PB, de_ctx, (void *)&tctx);
result = 1; result = 1;

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

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

Loading…
Cancel
Save