Index: trunk/configure.ac
===================================================================
--- trunk/configure.ac	(revision 25)
+++ trunk/configure.ac	(revision 29)
@@ -1,3 +1,3 @@
-AC_INIT([PSNC DRMAA for SLURM], [1.0.5], [mamonski@man.poznan.pl], [slurm-drmaa])
+AC_INIT([PSNC DRMAA for SLURM], [1.0.6], [mamonski@man.poznan.pl], [slurm-drmaa])
 AC_PREREQ(2.59)
 AC_REVISION([$Id$])
@@ -23,6 +23,6 @@
 SLURM_DRMAA_MAJOR=1
 SLURM_DRMAA_MINOR=0
-SLURM_DRMAA_MICRO=5
-SLURM_DRMAA_VERSION_INFO=1:5:0
+SLURM_DRMAA_MICRO=6
+SLURM_DRMAA_VERSION_INFO=1:6:0
 AC_SUBST([SLURM_DRMAA_MAJOR])
 AC_SUBST([SLURM_DRMAA_MINOR])
Index: trunk/slurm_drmaa/job.c
===================================================================
--- trunk/slurm_drmaa/job.c	(revision 27)
+++ trunk/slurm_drmaa/job.c	(revision 29)
@@ -121,84 +121,86 @@
 				self->on_missing(self);
 			} else {
-				fsd_exc_raise_fmt(	FSD_ERRNO_INTERNAL_ERROR,"slurm_load_jobs error: %s,job_id: %s", slurm_strerror(slurm_get_errno()), self->job_id);
-			}
-		}
+				fsd_exc_raise_fmt(FSD_ERRNO_INTERNAL_ERROR,"slurm_load_jobs error: %s,job_id: %s", slurm_strerror(slurm_get_errno()), self->job_id);
+			}
+		}
+		if (job_info) {
+			fsd_log_debug(("state = %d, state_reason = %d", job_info->job_array[0].job_state, job_info->job_array[0].state_reason));
+			
+			switch(job_info->job_array[0].job_state & JOB_STATE_BASE)
+			{
+
+				case JOB_PENDING:
+					switch(job_info->job_array[0].state_reason)
+					{
+						#if SLURM_VERSION_NUMBER >= SLURM_VERSION_NUM(2,2,0)
+						case WAIT_HELD_USER:   /* job is held by user */
+							fsd_log_debug(("interpreting as DRMAA_PS_USER_ON_HOLD"));
+							self->state = DRMAA_PS_USER_ON_HOLD;
+							break;
+						#endif
+						case WAIT_HELD:  /* job is held by administrator */
+							fsd_log_debug(("interpreting as DRMAA_PS_SYSTEM_ON_HOLD"));
+							self->state = DRMAA_PS_SYSTEM_ON_HOLD;
+							break;
+						default:
+							fsd_log_debug(("interpreting as DRMAA_PS_QUEUED_ACTIVE"));
+							self->state = DRMAA_PS_QUEUED_ACTIVE;
+					}
+					break;
+				case JOB_RUNNING:
+					fsd_log_debug(("interpreting as DRMAA_PS_RUNNING"));
+					self->state = DRMAA_PS_RUNNING;
+					break;
+				case JOB_SUSPENDED:
+					if(slurm_self->user_suspended == true) {
+						fsd_log_debug(("interpreting as DRMAA_PS_USER_SUSPENDED"));
+						self->state = DRMAA_PS_USER_SUSPENDED;
+					} else {
+						fsd_log_debug(("interpreting as DRMAA_PS_SYSTEM_SUSPENDED"));
+						self->state = DRMAA_PS_SYSTEM_SUSPENDED;
+					}
+					break;
+				case JOB_COMPLETE:
+					fsd_log_debug(("interpreting as DRMAA_PS_DONE"));
+					self->state = DRMAA_PS_DONE;
+					self->exit_status = job_info->job_array[0].exit_code;
+					fsd_log_debug(("exit_status = %d -> %d",self->exit_status, WEXITSTATUS(self->exit_status)));
+					break;
+				case JOB_CANCELLED:
+					fsd_log_debug(("interpreting as DRMAA_PS_FAILED (aborted)"));
+					self->state = DRMAA_PS_FAILED;
+					self->exit_status = -1;
+				case JOB_FAILED:
+				case JOB_TIMEOUT:
+				case JOB_NODE_FAIL:
+				#if SLURM_VERSION_NUMBER >= SLURM_VERSION_NUM(2,3,0)
+				case JOB_PREEMPTED:
+				#endif
+					fsd_log_debug(("interpreting as DRMAA_PS_FAILED"));
+					self->state = DRMAA_PS_FAILED;
+					self->exit_status = job_info->job_array[0].exit_code;
+					fsd_log_debug(("exit_status = %d -> %d",self->exit_status, WEXITSTATUS(self->exit_status)));
+					break;
+				default: /*unknown state */
+					fsd_log_error(("Unknown job state: %d. Please send bug report: http://apps.man.poznan.pl/trac/slurm-drmaa", job_info->job_array[0].job_state));
+			}
+
+			if (job_info->job_array[0].job_state & JOB_STATE_FLAGS & JOB_COMPLETING) {
+				fsd_log_debug(("Epilog completing"));
+			}
+
+			if (job_info->job_array[0].job_state & JOB_STATE_FLAGS & JOB_CONFIGURING) {
+				fsd_log_debug(("Nodes booting"));
+			}
+
+			if (self->exit_status == -1) /* input,output,error path failure etc*/
+				self->state = DRMAA_PS_FAILED;
+
+			self->last_update_time = time(NULL);
 		
-		switch(job_info->job_array[0].job_state & JOB_STATE_BASE)
-		{
-			fsd_log_debug(("state = %d, state_reason = %d", job_info->job_array[0].job_state, job_info->job_array[0].state_reason));
-
-			case JOB_PENDING:
-				switch(job_info->job_array[0].state_reason)
-				{
-					#if SLURM_VERSION_NUMBER >= SLURM_VERSION_NUM(2,2,0)
-					case WAIT_HELD_USER:   /* job is held by user */
-						fsd_log_debug(("interpreting as DRMAA_PS_USER_ON_HOLD"));
-						self->state = DRMAA_PS_USER_ON_HOLD;
-						break;
-					#endif
-					case WAIT_HELD:  /* job is held by administrator */
-						fsd_log_debug(("interpreting as DRMAA_PS_SYSTEM_ON_HOLD"));
-						self->state = DRMAA_PS_SYSTEM_ON_HOLD;
-						break;
-					default:
-						fsd_log_debug(("interpreting as DRMAA_PS_QUEUED_ACTIVE"));
-						self->state = DRMAA_PS_QUEUED_ACTIVE;
-				}
-				break;
-			case JOB_RUNNING:
-				fsd_log_debug(("interpreting as DRMAA_PS_RUNNING"));
-				self->state = DRMAA_PS_RUNNING;
-				break;
-			case JOB_SUSPENDED:
-				if(slurm_self->user_suspended == true) {
-					fsd_log_debug(("interpreting as DRMAA_PS_USER_SUSPENDED"));
-					self->state = DRMAA_PS_USER_SUSPENDED;
-				} else {
-					fsd_log_debug(("interpreting as DRMAA_PS_SYSTEM_SUSPENDED"));
-					self->state = DRMAA_PS_SYSTEM_SUSPENDED;
-				}
-				break;
-			case JOB_COMPLETE:
-				fsd_log_debug(("interpreting as DRMAA_PS_DONE"));
-				self->state = DRMAA_PS_DONE;
-				self->exit_status = job_info->job_array[0].exit_code;
-				fsd_log_debug(("exit_status = %d -> %d",self->exit_status, WEXITSTATUS(self->exit_status)));
-				break;
-			case JOB_CANCELLED:
-				fsd_log_debug(("interpreting as DRMAA_PS_FAILED (aborted)"));
-				self->state = DRMAA_PS_FAILED;
-				self->exit_status = -1;
-			case JOB_FAILED:
-			case JOB_TIMEOUT:
-			case JOB_NODE_FAIL:
-			#if SLURM_VERSION_NUMBER >= SLURM_VERSION_NUM(2,3,0)
-			case JOB_PREEMPTED:
-			#endif
-				fsd_log_debug(("interpreting as DRMAA_PS_FAILED"));
-				self->state = DRMAA_PS_FAILED;
-				self->exit_status = job_info->job_array[0].exit_code;
-				fsd_log_debug(("exit_status = %d -> %d",self->exit_status, WEXITSTATUS(self->exit_status)));
-				break;
-			default: /*unknown state */
-				fsd_log_error(("Unknown job state: %d. Please send bug report: http://apps.man.poznan.pl/trac/slurm-drmaa", job_info->job_array[0].job_state));
-		}
-
-		if (job_info->job_array[0].job_state & JOB_STATE_FLAGS & JOB_COMPLETING) {
-			fsd_log_debug(("Epilog completing"));
-		}
-
-		if (job_info->job_array[0].job_state & JOB_STATE_FLAGS & JOB_CONFIGURING) {
-			fsd_log_debug(("Nodes booting"));
-		}
-
-		if (self->exit_status == -1) /* input,output,error path failure etc*/
-			self->state = DRMAA_PS_FAILED;
-
-		self->last_update_time = time(NULL);
-	
-		if( self->state >= DRMAA_PS_DONE ) {
-			fsd_log_debug(("exit_status = %d, WEXITSTATUS(exit_status) = %d", self->exit_status, WEXITSTATUS(self->exit_status)));
-			fsd_cond_broadcast( &self->status_cond );
+			if( self->state >= DRMAA_PS_DONE ) {
+				fsd_log_debug(("exit_status = %d, WEXITSTATUS(exit_status) = %d", self->exit_status, WEXITSTATUS(self->exit_status)));
+				fsd_cond_broadcast( &self->status_cond );
+			}
 		}
 	}
Index: trunk/slurm_drmaa/util.c
===================================================================
--- trunk/slurm_drmaa/util.c	(revision 28)
+++ trunk/slurm_drmaa/util.c	(revision 29)
@@ -94,10 +94,17 @@
 	else if (strcasecmp(mail_type_str, "FAIL") == 0)
 		rc = MAIL_JOB_FAIL;
+#if SLURM_VERSION_NUMBER >= SLURM_VERSION_NUM(2,2,0)
 	else if (strcasecmp(mail_type_str, "REQUEUE") == 0)
 		rc = MAIL_JOB_REQUEUE;
+#endif
 	else if (strcasecmp(mail_type_str, "ALL") == 0)
+#if SLURM_VERSION_NUMBER >= SLURM_VERSION_NUM(2,2,0)
 		rc = MAIL_JOB_BEGIN | MAIL_JOB_END | MAIL_JOB_FAIL | MAIL_JOB_REQUEUE;
-	else
-		rc = 0; /* failure */
+#else
+		rc = MAIL_JOB_BEGIN | MAIL_JOB_END | MAIL_JOB_FAIL;
+#endif
+	else {
+		fsd_log_error(("Unknown mail type: %s", mail_type_str));
+	}
 
 	return rc;
@@ -163,7 +170,8 @@
 	fsd_free(job_desc->std_err);	
 	fsd_free(job_desc->work_dir);
+	fsd_free(job_desc->exc_nodes);
+#if SLURM_VERSION_NUMBER >= SLURM_VERSION_NUM(2,2,0)
 	fsd_free(job_desc->gres);
-	fsd_free(job_desc->exc_nodes);
-
+#endif
 	
 	fsd_log_return(( "" ));
@@ -309,6 +317,10 @@
 			break;	
 		case SLURM_NATIVE_GRES:
+			#if SLURM_VERSION_NUMBER >= SLURM_VERSION_NUM(2,2,0)
 			fsd_log_debug(("# gres = %s",value));
 			job_desc->gres = fsd_strdup(value);
+			#else
+			fsd_log_error(("GRES not supported in this version of SLURM."));
+			#endif
 			break;
 		case SLURM_NATIVE_NO_KILL:
