avoid delivery threads active wait
authorMichal Voců <michal@ruk.cuni.cz>
Tue, 2 Nov 2010 08:01:29 +0000 (08:01 +0000)
committerMichal Voců <michal@ruk.cuni.cz>
Tue, 2 Nov 2010 08:01:29 +0000 (08:01 +0000)
org.glite.lb.logger/src/event_queue.c
org.glite.lb.logger/src/perftest_il.sh
org.glite.lb.logger/src/queue_thread.c

index 58bee20..ccc0a9f 100644 (file)
@@ -268,11 +268,9 @@ event_queue_get(struct event_queue *eq, struct queue_thread *me, struct server_m
   int found;
 
   assert(eq != NULL);
-  assert(msg != NULL);
 
   event_queue_lock(eq);
   if(me->jobid) {
-         free(me->jobid);
          me->jobid = NULL;
          me->current = NULL;
   }
@@ -301,11 +299,10 @@ event_queue_get(struct event_queue *eq, struct queue_thread *me, struct server_m
          }
          el = el->prev;
   } while(el != eq->head);
-  if(found) {
+  if(found && msg) {
          me->current = el;
-         me->jobid = strdup(el->msg->job_id_s);
+         me->jobid = el->msg->job_id_s;
          *msg = el->msg;
-  } else {
   }
   event_queue_unlock(eq);
 
@@ -393,6 +390,9 @@ event_queue_remove(struct event_queue *eq, struct queue_thread *me)
   if(eq->cur_len <= queue_size_low) {
          eq->throttling = 0;
   }
+  
+  me->current = NULL;
+  me->jobid = NULL;
 
   event_queue_unlock(eq);
   /* end of critical section */
index 2f906fc..c1039ff 100644 (file)
@@ -320,7 +320,7 @@ group_c_test_x ()
 
 group_c_test_d ()
 {
-    COMPONENT_ARGS="-p $parallel -i /tmp/perftest_il.pid -d  --lazy=10 --nosync --norecover $COMM_ARGS"
+    COMPONENT_ARGS="-p$parallel -i /tmp/perftest_il.pid -d  --lazy=10 --nosync --norecover $COMM_ARGS"
     echo -n "d)"
     run_test il $numjobs
     print_result
@@ -329,7 +329,7 @@ group_c_test_d ()
 
 group_c_test_e ()
 {
-    COMPONENT_ARGS="-p $parallel -i /tmp/perftest_il.pid -d $COMM_ARGS"
+    COMPONENT_ARGS="-p$parallel -i /tmp/perftest_il.pid -d $COMM_ARGS"
     echo -n "e)"
     run_test il $numjobs
     print_result
index a4bc1dd..0aa0f87 100644 (file)
@@ -108,7 +108,7 @@ queue_thread(void *q)
 
                /* if there are no events, wait for them */
                ret = 0;
-               while (event_queue_empty(eq)
+               while ((event_queue_empty(eq) || event_queue_get(eq, me, NULL) == 0)
 #if defined(INTERLOGD_HANDLE_CMD) && defined(INTERLOGD_FLUSH)
                       && (eq->flushing != 1)
 #endif
@@ -142,7 +142,6 @@ queue_thread(void *q)
                                event_queue_cond_unlock(eq);
                                pthread_exit((void*)-1);
                        }
-                       /* sleep only once when there is no event available for this particular thread */
                }  /* END while(empty) */
     
 
@@ -157,8 +156,8 @@ queue_thread(void *q)
                        now = time(NULL);
                        event_queue_move_events(eq, NULL, cmp_expires, &now);
                }
-               if(!event_queue_empty(eq)) {
-
+               if(!event_queue_empty(eq) && event_queue_get(eq, me, NULL) != 0) {
+                 
                        /* deliver pending events */
                        glite_common_log(IL_LOG_CATEGORY, LOG_PRIORITY_DEBUG, 
                                         "  thread %x: attempting delivery to %s",
@@ -250,7 +249,6 @@ queue_thread(void *q)
 
                event_queue_lock(eq);
                if(me->jobid) {
-                       free(me->jobid); 
                        me->jobid = NULL;
                        me->current = NULL;
                }