aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2010-04-01 12:18:59 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2010-04-01 12:18:59 +0000
commitbdfbd8a34c5873f567181f92a2f09c69492e9ac3 (patch)
tree50167f0adcd72e02682b382297726b53e23df6a3
parente232cf2ce858fd84cddae6a5d231ff46e7d5e1d0 (diff)
check whether queue is !NULL before pushing/popping
svn path=/trunk/externals/iem/iemnet/; revision=13345
-rw-r--r--iemnet_data.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/iemnet_data.c b/iemnet_data.c
index 5dc7ee5..72e0344 100644
--- a/iemnet_data.c
+++ b/iemnet_data.c
@@ -204,7 +204,9 @@ int queue_push(
) {
t_node* tail;
t_node* n=NULL;
- int size=_this->size;
+ int size=-1;
+ if(_this) {
+ size=_this->size;
if(NULL == data) return size;
//fprintf(stderr, "pushing %d bytes\n", data->size);
@@ -224,21 +226,22 @@ int queue_push(
_this->size+=data->size;
size=_this->size;
-
//fprintf(stderr, "pushed %d bytes\n", data->size);
pthread_mutex_unlock(&_this->mtx);
pthread_cond_signal(&_this->cond);
-
+ }
return size;
}
t_iemnet_chunk* queue_pop_block(
t_iemnet_queue* const _this
) {
+
t_node* head=0;
t_iemnet_chunk*data=0;
- pthread_mutex_lock(&_this->mtx);
+ if(_this) {
+ pthread_mutex_lock(&_this->mtx);
while (! (head = _this->head)) {
if(_this->done) {
pthread_mutex_unlock(&_this->mtx);
@@ -262,6 +265,7 @@ t_iemnet_chunk* queue_pop_block(
freebytes(head, sizeof(t_node));
head=NULL;
}
+ }
return data;
}
@@ -270,6 +274,7 @@ t_iemnet_chunk* queue_pop_noblock(
) {
t_node* head=0;
t_iemnet_chunk*data=0;
+ if(_this) {
pthread_mutex_lock(&_this->mtx);
if (! (head = _this->head)) {
// empty head
@@ -289,6 +294,7 @@ t_iemnet_chunk* queue_pop_noblock(
freebytes(head, sizeof(t_node));
head=NULL;
}
+ }
return data;
}