Index: trunk/pbs_drmaa/log_reader.c
===================================================================
--- trunk/pbs_drmaa/log_reader.c	(revision 30)
+++ trunk/pbs_drmaa/log_reader.c	(revision 31)
@@ -217,6 +217,5 @@
 						fsd_log_debug(("WT - Date changed. Closing log file"));
 						self->date_changed = true;
-						fsd_free(line);
-						break;
+						goto cleanup;
 					 }
 
@@ -235,6 +234,5 @@
 							else
 							 {
-								fsd_free(line);
-								break; /*we are interested only in the above log messages */
+								goto cleanup; /*we are interested only in the above log messages */
 							 }
 						 }
@@ -247,6 +245,5 @@
 							if (strncmp(field_token, "Job", 3) != 0)
 							 {
-								fsd_free(line);
-								break; /* we are interested only in job events */
+								goto cleanup; /* we are interested only in job events */
 							 }
 						 }
@@ -254,22 +251,23 @@
 						 {
 							const char *event_jobid = field_token;
-
-							TRY
-							 {
-								job = self->session->get_job( self->session, event_jobid );
-
-								if( job )
-								 {
-									fsd_log_debug(("WT - Found job event: %s", event_jobid));
-								 }
-								else
-								 {
-									fsd_log_debug(("WT - Unknown job: %s", event_jobid)); /* Not a DRMAA job */
-									fsd_free(line);
-									break;
-								 }
-							 }
-							END_TRY
-						 }
+							
+							if (!isdigit(event_jobid[0]))
+							 {
+								fsd_log_debug(("WT - Invalid job: %s", event_jobid)); 
+								goto cleanup;
+							 }
+
+							job = self->session->get_job( self->session, event_jobid );
+
+							if( job )
+							 {
+								fsd_log_debug(("WT - Found job event: %s", event_jobid));
+							 }
+							else
+							 {
+								fsd_log_debug(("WT - Unknown job: %s", event_jobid)); /* Not a DRMAA job */
+								goto cleanup;
+							 }
+					 	 }
 						else if (field_id == PBSDRMAA_FLD_ID_MSG)
 						 {
@@ -287,5 +285,5 @@
 								char *p_queue = NULL;
 
-								fsd_log_info(("WT - Detected queued of job %s", job->job_id));
+								fsd_log_info(("WT - Detected queuing of job %s", job->job_id));
 
 								if ((p_queue = strstr(msg,"queue =")) == NULL)
@@ -351,10 +349,8 @@
 								else
 								 {
-									job->release( job );
-									fsd_free(line);
-									break; /* job was started, ignore, wait for Exit_status message */
+									goto cleanup; /* job was started, ignore, wait for Exit_status message */
 								 }
 							 }
-							else if (event_type == pbsdrmaa_event_0010 && strncmp(msg, "Exit_status=", 12))
+							else if (event_type == pbsdrmaa_event_0010 && (strncmp(msg, "Exit_status=", 12) == 0))
 							 {
 							/* Completed:
@@ -375,5 +371,5 @@
 									if (strncmp(token, "Exit_status=", 12) == 0)
 									 {
-										token[12] = '\0';
+										token[11] = '\0';
 										attribs = pbsdrmaa_add_attr(attribs, token, token + 12);
 										fsd_log_info(("WT - Completion of job %s (Exit_status=%s) detected after %d seconds", job->job_id, token+12, (int)(time(NULL) - timestamp_time_t) ));
@@ -381,20 +377,20 @@
 									else if (strncmp(token, "resources_used.cput=", 20) == 0)
 									 {
-										token[20] = '\0';
+										token[19] = '\0';
 										attribs = pbsdrmaa_add_attr(attribs, token, token + 20);
 									 }
 									else if (strncmp(token, "resources_used.mem=", 19) == 0)
 									 {
-										token[19] = '\0';
+										token[18] = '\0';
 										attribs = pbsdrmaa_add_attr(attribs, token, token + 19);
 									 }
 									else if (strncmp(token, "resources_used.vmem=", 20) == 0)
 									 {
-										token[20] = '\0';
+										token[19] = '\0';
 										attribs = pbsdrmaa_add_attr(attribs, token, token + 20);
 									 }
 									else if (strncmp(token, "resources_used.walltime=", 24) == 0)
 									 {
-										token[24] = '\0';
+										token[23] = '\0';
 										attribs = pbsdrmaa_add_attr(attribs, token, token + 24);
 									 }
@@ -412,7 +408,5 @@
 							else
 							{
-								job->release( job );
-								fsd_free(line);
-								break; /* ignore other job events*/
+								goto cleanup; /* ignore other job events*/
 							}
 
@@ -445,8 +439,4 @@
 							fsd_cond_broadcast( &self->session->wait_condition );
 
-							if ( job )
-								job->release( job );
-
-							fsd_free(line); /* TODO free on exception */
 						 }
 						else
@@ -455,4 +445,10 @@
 						 }
 					 }
+				cleanup:
+					fsd_free(line); /* TODO what about exceptions */		
+					if ( job )
+						job->release( job );
+
+
 
 				 } /* end of while getline loop */
@@ -470,5 +466,5 @@
 					timeout_tv.tv_sec = 1;
 					timeout_tv.tv_usec = 0;
-
+					fsd_log_debug(("Polling log file for %d seconds", timeout_tv.tv_sec));
 					/* ignore return value - the next get line call will handle IO errors */
 					(void)select(1, &log_fds, NULL, NULL, &timeout_tv);
@@ -534,5 +530,5 @@
 				
 	retry:
-		if ((self->fhandle = fopen(log_path,"")) == NULL && (num_tries > DRMAA_WAIT_THREAD_MAX_TRIES || self->first_open))
+		if ((self->fhandle = fopen(log_path,"r")) == NULL && (num_tries > DRMAA_WAIT_THREAD_MAX_TRIES || self->first_open))
 		 {
 			fsd_log_error(("Can't open log file. Verify pbs_home. Running standard wait_thread."));
Index: trunk/configure.ac
===================================================================
--- trunk/configure.ac	(revision 24)
+++ trunk/configure.ac	(revision 31)
@@ -143,5 +143,4 @@
 	localtime_r \
 	memset \
-	mkstemp \
 	setenv \
 	strcasecmp \
